diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index 312d03da..a02d8aa0 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -124,30 +124,17 @@ module Gollum # # Returns the placeholder'd String data. def extract_tex(data) - # Random string to escape the `$` character (might be overkill) - esc = "/%%/" data.gsub(/\\\[\s*(.*?)\s*\\\]/m) do tag = CGI.escapeHTML($1) id = Digest::SHA1.hexdigest(tag) @texmap[id] = [:block, tag] id - end.gsub(/'\$/, esc). # Replace `'$` with the `esc` string in order to escape it - gsub(/\$\$\s*(.*?)\s*\$\$/m) do - tag = CGI.escapeHTML($1) - id = Digest::SHA1.hexdigest(tag) - @texmap[id] = [:block, tag] - id end.gsub(/\\\(\s*(.*?)\s*\\\)/m) do tag = CGI.escapeHTML($1) id = Digest::SHA1.hexdigest(tag) @texmap[id] = [:inline, tag] id - end.gsub(/\$\s*(.*?)\s*\$/m) do # match inline $$ - tag = CGI.escapeHTML($1) - id = Digest::SHA1.hexdigest(tag) - @texmap[id] = [:inline, tag] - id - end.gsub(/#{esc}/, '$') # replace the `esc` string back to `$` + end end # Process all TeX from the texmap and replace the placeholders with the