Skip to content

Commit

Permalink
Merge pull request #795 from kmuto/afterdl
Browse files Browse the repository at this point in the history
numbered/itemized lists should be an ending condition of dlist
  • Loading branch information
takahashim authored Jun 27, 2017
2 parents aa55cf5 + 4ea0cc8 commit 1bf5639
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/review/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def compile_dlist(f)
@strategy.dl_begin
while /\A\s*:/ =~ f.peek
@strategy.dt text(f.gets.sub(/\A\s*:/, '').strip)
@strategy.dd(f.break(/\A(\S|\s*:)/).map {|line| text(line.strip) })
@strategy.dd(f.break(/\A(\S|\s*:|\s+\d+\.\s|\s+\*\s)/).map {|line| text(line.strip) })
f.skip_blank_lines
f.skip_comment_lines
end
Expand Down
5 changes: 5 additions & 0 deletions test/test_htmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,11 @@ def test_dlist_with_comment
assert_equal %Q|<dl>\n<dt>title</dt>\n<dd>body</dd>\n<dt>title2</dt>\n<dd>body2</dd>\n</dl>\n|, actual
end

def test_dlist_beforeulol
actual = compile_block(" : foo\n foo.\n\npara\n\n : foo\n foo.\n\n 1. bar\n\n : foo\n foo.\n\n * bar\n")
assert_equal %Q|<dl>\n<dt>foo</dt>\n<dd>foo.</dd>\n</dl>\n<p>para</p>\n<dl>\n<dt>foo</dt>\n<dd>foo.</dd>\n</dl>\n<ol>\n<li>bar</li>\n</ol>\n<dl>\n<dt>foo</dt>\n<dd>foo.</dd>\n</dl>\n<ul>\n<li>bar</li>\n</ul>\n|, actual
end

def test_list
def @chapter.list(id)
Book::ListIndex::Item.new("samplelist",1)
Expand Down
5 changes: 5 additions & 0 deletions test/test_idgxmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ def test_inline_m
assert_equal %Q|<replace idref="texinline-1"><pre>\\sin</pre></replace> <replace idref="texinline-2"><pre>\\frac{1}{2}</pre></replace>|, actual
end

def test_dlist_beforeulol
actual = compile_block(" : foo\n foo.\n\npara\n\n : foo\n foo.\n\n 1. bar\n\n : foo\n foo.\n\n * bar\n")
assert_equal %Q|<dl><dt>foo</dt><dd>foo.</dd></dl><p>para</p><dl><dt>foo</dt><dd>foo.</dd></dl><ol><li aid:pstyle="ol-item" olnum="1" num="1">bar</li></ol><dl><dt>foo</dt><dd>foo.</dd></dl><ul><li aid:pstyle="ul-item">bar</li></ul>|, actual
end

def test_paragraph
actual = compile_block("foo\nbar\n")
assert_equal %Q|<p>foobar</p>|, actual
Expand Down
5 changes: 5 additions & 0 deletions test/test_latexbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ def test_dlist_with_bracket
assert_equal %Q|\n\\begin{description}\n\\item[foo\\lbrack{}bar\\rbrack{}] \\mbox{} \\\\\nfoo.bar.\n\\end{description}\n|, actual
end

def test_dlist_beforeulol
actual = compile_block(" : foo\n foo.\n\npara\n\n : foo\n foo.\n\n 1. bar\n\n : foo\n foo.\n\n * bar\n")
assert_equal %Q|\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.\n\\end{description}\n\npara\n\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.\n\\end{description}\n\n\\begin{enumerate}\n\\item bar\n\\end{enumerate}\n\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.\n\\end{description}\n\n\\begin{itemize}\n\\item bar\n\\end{itemize}\n|, actual
end

def test_cmd
actual = compile_block("//cmd{\nfoo\nbar\n\nbuz\n//}\n")
assert_equal %Q|\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n|, actual
Expand Down
5 changes: 5 additions & 0 deletions test/test_topbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ def test_inline_in_table
assert_equal %Q|◆→開始:表←◆\n★★1☆☆\t★▲2☆☆\n★3☆\t▲4☆<>&\n◆→終了:表←◆\n\n|, actual
end

def test_dlist_beforeulol
actual = compile_block(" : foo\n foo.\n\npara\n\n : foo\n foo.\n\n 1. bar\n\n : foo\n foo.\n\n * bar\n")
assert_equal %Q|★foo☆\n\tfoo.\n\t\n\npara\n\n★foo☆\n\tfoo.\n\t\n\n1\tbar\n\n★foo☆\n\tfoo.\n\t\n\n\tbar\n\n|, actual
end

def test_paragraph
actual = compile_block("foo\nbar\n")
assert_equal %Q|foobar\n|, actual
Expand Down

0 comments on commit 1bf5639

Please sign in to comment.