Sha256: 5d06706625e9f4e6d3095466b1c12c127f14dd18c0d4c3a0c24b8849631b1d4b

Contents?: true

Size: 1.48 KB

Versions: 11

Compression:

Stored size: 1.48 KB

Contents

require 'asciidoctor'
require 'asciidoctor/extensions'

# a postprocessor to map the nonsense
# string 'DOLLOD' back to '$'
#
# This is used in for the LaTeX backend
# in conjunction with the code
# in 'tex_preprocessor' which maps '\$' to
# 'DOLLOD'
#
# There should be a better solution to the
# vexing proble of dealing with both $ ... $
# for mathematics and '\$' for currency. But
# this works and wil have to do for now.
#
# @jirutka: Advice?
#
module Asciidoctor::LaTeX
  # Map @@DOLLAR: to \$
  class TexPostprocessor < Asciidoctor::Extensions::Postprocessor

    def process document, output
      output = output.gsub('ESCAMPERSAND', '\\&')
      output = output.gsub('ESCUNDERSCORE', '\\_')
      output = output.gsub('ESCDOLLAR', '\\$')
      output = output.gsub('CHEMRIGHTARROW','->').gsub('CHEMLEFTARROW','<-').gsub('CHEMLEFTRIGHTARROW','<-->')
      output = output.gsub('\\(','$').gsub('\\)','$')
      output.gsub('!!!BACKSLASH', '\\')
    end

  end

  class HTMLPostprocessor < Asciidoctor::Extensions::Postprocessor

    def process document, output
      output = output.gsub('ESCAMPERSAND', '&')
      output = output.gsub('ESCUNDERSCORE', '_')
      output = output.gsub('ESCDOLLAR', '$')
      output = output.gsub('\DOLLOD', '\$')
      # match_data = output.match /%%(.*)%%/
      # if match_data
      #  output = output.gsub(match_data[0], match_data[1])
      # end
      output.gsub('!!!BACKSLASH', '\\')
      # output.gsub('%', '\%')  This messes up the html bigtimw
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
asciidoctor-latex-1.5.0.17.dev lib/asciidoctor/latex/tex_postprocessor.rb
asciidoctor-latex-1.5.0.16.dev lib/asciidoctor/latex/tex_postprocessor.rb
asciidoctor-latex-1.5.0.15.dev lib/asciidoctor/latex/tex_postprocessor.rb
asciidoctor-latex-1.5.0.14.dev lib/asciidoctor/latex/tex_postprocessor.rb
asciidoctor-latex-1.5.0.13.dev lib/asciidoctor/latex/tex_postprocessor.rb
asciidoctor-latex-1.5.0.12.dev lib/asciidoctor/latex/tex_postprocessor.rb
asciidoctor-latex-1.5.0.11.dev lib/asciidoctor/latex/tex_postprocessor.rb
asciidoctor-latex-1.5.0.10.dev lib/asciidoctor/latex/tex_postprocessor.rb
asciidoctor-latex-1.5.0.9.dev lib/asciidoctor/latex/tex_postprocessor.rb
asciidoctor-latex-1.5.0.8b.dev lib/asciidoctor/latex/tex_postprocessor.rb
asciidoctor-latex-1.5.0.7.dev lib/asciidoctor/latex/tex_postprocessor.rb