Fix #2598 for old parser
This commit is contained in:
@@ -193,7 +193,7 @@ class DText
|
|||||||
str.gsub!(/\[\/code\]\s*/m, "\n\n[/code]\n\n")
|
str.gsub!(/\[\/code\]\s*/m, "\n\n[/code]\n\n")
|
||||||
str.gsub!(/\s*\[spoilers?\](?!\])\s*/m, "\n\n[spoiler]\n\n")
|
str.gsub!(/\s*\[spoilers?\](?!\])\s*/m, "\n\n[spoiler]\n\n")
|
||||||
str.gsub!(/\s*\[\/spoilers?\]\s*/m, "\n\n[/spoiler]\n\n")
|
str.gsub!(/\s*\[\/spoilers?\]\s*/m, "\n\n[/spoiler]\n\n")
|
||||||
str.gsub!(/^(h[1-6]\.\s*.+)$/, "\n\n\\1\n\n")
|
str.gsub!(/^(h[1-6](\#[A-z][_A-z0-9-]+)?\.\s*.+)$/, "\n\n\\1\n\n")
|
||||||
str.gsub!(/\s*\[expand(\=[^\]]*)?\](?!\])\s*/m, "\n\n[expand\\1]\n\n")
|
str.gsub!(/\s*\[expand(\=[^\]]*)?\](?!\])\s*/m, "\n\n[expand\\1]\n\n")
|
||||||
str.gsub!(/\s*\[\/expand\]\s*/m, "\n\n[/expand]\n\n")
|
str.gsub!(/\s*\[\/expand\]\s*/m, "\n\n[/expand]\n\n")
|
||||||
str.gsub!(/\s*\[table\](?!\])\s*/m, "\n\n[table]\n\n")
|
str.gsub!(/\s*\[table\](?!\])\s*/m, "\n\n[table]\n\n")
|
||||||
@@ -217,7 +217,16 @@ class DText
|
|||||||
else
|
else
|
||||||
"<#{tag}>" + parse_inline(content, options) + "</#{tag}>"
|
"<#{tag}>" + parse_inline(content, options) + "</#{tag}>"
|
||||||
end
|
end
|
||||||
|
when /\A(h[1-6])\#([A-z][_A-z0-9-]+)\.\s*(.+)\Z/
|
||||||
|
tag = $1
|
||||||
|
header_id = $2
|
||||||
|
content = $3
|
||||||
|
|
||||||
|
if options[:inline]
|
||||||
|
"<h6 id=\"#{header_id}\">" + parse_inline(content, options) + "</h6>"
|
||||||
|
else
|
||||||
|
"<#{tag} id=\"#{header_id}\">" + parse_inline(content, options) + "</#{tag}>"
|
||||||
|
end
|
||||||
when /^\s*\*+ /
|
when /^\s*\*+ /
|
||||||
parse_list(block, options)
|
parse_list(block, options)
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ class DTextTest < ActiveSupport::TestCase
|
|||||||
assert_equal("<h1>header</h1>", p("h1. header"))
|
assert_equal("<h1>header</h1>", p("h1. header"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_headers_with_ids
|
||||||
|
assert_equal("<h1 id=\"header-id\">header</h1>", p("h1#header-id. header"))
|
||||||
|
end
|
||||||
|
|
||||||
def test_quote_blocks
|
def test_quote_blocks
|
||||||
assert_equal('<blockquote><p>test</p></blockquote>', p("[quote]\ntest\n[/quote]"))
|
assert_equal('<blockquote><p>test</p></blockquote>', p("[quote]\ntest\n[/quote]"))
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user