lib/polytexnic/preprocessors/polytex.rb
# Caches raw LaTeX commands to be passed through the pipeline.
Caches raw LaTeX commands to be passed through the pipeline.
Caches raw LaTeX commands to be passed through the pipeline .
def cache_raw_latex(markdown)
        command_regex = /(
                          ^[ \t]*\\\w+.*\}[ \t]*$ # Command on line with arg
                          |
                          ~\\ref\{.*?\}     # reference with a tie
                          |
                          ~\\eqref\{.*?\}   # eq reference with a tie
                          |
                          \\[^\s]+\{.*?\}   # command with one arg
                          |
                          \\\w+             # normal command
                          |
                          \\-               # hyphenation
                          |
                          \\[ %&$\#@]       # space or special character
                          |
                          \\\\              # double backslashes
                          )
                        /x
        markdown.gsub!(command_regex) do
          content = $1
          puts content.inspect if debug?
          key = digest(content)
          key += $label_salt if content.include?('\label')
          $cache[key] = content
          if content =~ /\{table\}|\\caption\{/
            "\n#{key}\n"
          else
            key
          end
        end
      end
def cache_raw_latex ( markdown ) command_regex = / (
                          ^[  \t ]* \\ \w +.* \} [  \t ]*$ # Command on line with arg
                          |
                          ~ \\ ref \{ .*? \}      # reference with a tie
                          |
                          ~ \\ eqref \{ .*? \}    # eq reference with a tie
                          |
                           \\ [^ \s ]+ \{ .*? \}    # command with one arg
                          |
                           \\ \w +             # normal command
                          |
                           \\ -               # hyphenation
                          |
                           \\ [ %&$ \# @]       # space or special character
                          |
                           \\ \\               # double backslashes
                          )
                         /x markdown . gsub! ( command_regex ) do content = $1 puts content . inspect if debug? key = digest ( content ) key += $label_salt if content . include? ( '\label' ) $cache [ key ] = content if content =~ / \{ table \} | \\ caption \{ / "\n#{key}\n" else key end end end
Caches raw LaTeX commands to be passed through the pipeline.
Caches raw LaTeX commands to be passed through the pipeline .
# Used to speed up has_label? in convert_standalone_image. # Pad tables & captions with newlines for kramdown compatibility.
markdown