commonmarker-test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'commonmarker' | |
md = '$$\begin{align}x\\\\y\end{align}$$' | |
puts "BEFORE:" + md | |
puts "AFTER :" + CommonMarker.render_html(md) |
# $$ ... $$ を <div>$$ ... $$</div> に変換する
def wrap_mathblock(s)
t = ''
while s.match(/(\$\$.+?\$\$)/m)
pre, match, post = $`, $1, $'
match.gsub!(/\n+/, "\n")
t += "#{pre}\n<div>#{match}</div>"
s = post
end
t + s
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
==>