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:
@@ -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}")
|
||||
|
||||
@@ -236,6 +236,19 @@ context "Markup" do
|
||||
assert_equal expected, output
|
||||
end
|
||||
|
||||
test "~~~ code blocks #537 with lots of tildes" do
|
||||
page = 'test_rgx'
|
||||
@wiki.write_page(page, :markdown,
|
||||
%Q(~~~~~~ {#hi .ruby .sauce}
|
||||
~~
|
||||
'hi'~
|
||||
~~~~~~
|
||||
), commit_details)
|
||||
output = @wiki.page(page).formatted_data
|
||||
expected = %Q{<div class=\"highlight\"><pre><span class=\"o\">~~</span>\n<span class=\"s1\">'hi'</span><span class=\"o\">~</span>\n</pre></div>}
|
||||
assert_equal expected, output
|
||||
end
|
||||
|
||||
test "wiki link within code block" do
|
||||
@wiki.write_page("Potato", :markdown, " sed -i '' 's/[[:space:]]*$//'", commit_details)
|
||||
page = @wiki.page("Potato")
|
||||
|
||||
Reference in New Issue
Block a user