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!(/\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]\n\n")
|
||||
str.gsub!(/\s*\[table\](?!\])\s*/m, "\n\n[table]\n\n")
|
||||
@@ -217,7 +217,16 @@ class DText
|
||||
else
|
||||
"<#{tag}>" + parse_inline(content, options) + "</#{tag}>"
|
||||
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*\*+ /
|
||||
parse_list(block, options)
|
||||
|
||||
|
||||
@@ -75,6 +75,10 @@ class DTextTest < ActiveSupport::TestCase
|
||||
def test_headers
|
||||
assert_equal("<h1>header</h1>", p("h1. header"))
|
||||
end
|
||||
|
||||
def test_headers_with_ids
|
||||
assert_equal("<h1 id=\"header-id\">header</h1>", p("h1#header-id. header"))
|
||||
end
|
||||
|
||||
def test_quote_blocks
|
||||
assert_equal('<blockquote><p>test</p></blockquote>', p("[quote]\ntest\n[/quote]"))
|
||||
|
||||
Reference in New Issue
Block a user