Sha256: d66fc8fc1b49e3e59f450cb2fd6f488edd5e48cf11acab8a8cbb63e631254cda

Contents?: true

Size: 711 Bytes

Versions: 4

Compression:

Stored size: 711 Bytes

Contents

require 'polytexnic/literal'

module Polytexnic
  module Postprocessor
    module Latex

      # Restores literal environments (verbatim, code, math, etc.).
      def replace_hashes(polytex)
        puts polytex if debug?
        polytex.tap do
          literal_cache.each do |key, value|
            puts value.inspect if debug?
            polytex.gsub!(key, extra_escape(escape_backslashes(value)))
          end
        end
      end

      # Escapes backslashes even more.
      # Have I mentioned how much I hate backslashes?
      def extra_escape(string)
        string.gsub('\\', '\\\\\\').
               gsub("\\'", '\\\\' + "'").
               gsub('\\\\\\', '\\\\\\')
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
polytexnic-1.10.2 lib/polytexnic/postprocessors/latex.rb
polytexnic-1.10.1 lib/polytexnic/postprocessors/latex.rb
polytexnic-1.10.0 lib/polytexnic/postprocessors/latex.rb
polytexnic-1.9.2 lib/polytexnic/postprocessors/latex.rb