Improve tilde fence support

More than 3 tildes can be used. The code block must end with the same amount of tildes used to open the code block.

Fix #537

http://johnmacfarlane.net/pandoc/README.html#delimited-code-blocks
This commit is contained in:
bootstraponline
2012-10-14 11:00:41 -06:00
parent f928cfa8be
commit 45547624e4
2 changed files with 21 additions and 3 deletions
+8 -3
View File
@@ -511,10 +511,15 @@ module Gollum
#
# Returns the placeholder'd String data.
def extract_code(data)
data.gsub!(/^([ \t]*)~~~ ?([^\r\n]+)?\r?\n(.+?)\r?\n\1~~~\r?$/m) do
data.gsub!(/^([ \t]*)(~~~+) ?([^\r\n]+)?\r?\n(.+?)\r?\n\1(~~~+)\r?$/m) do
m_indent = $1
m_lang = $2
m_code = $3
m_start = $2 # ~~~
m_lang = $3
m_code = $4
m_end = $5 # ~~~
# start and finish tilde fence must be the same length
return '' if m_start.length != m_end.length
lang = m_lang ? m_lang.strip : nil
id = Digest::SHA1.hexdigest("#{lang}.#{m_code}")