From 35d4462261799fdc1adb8a5e6d48f413ca7389c5 Mon Sep 17 00:00:00 2001 From: takahashim Date: Sat, 29 Jun 2019 14:29:36 +0900 Subject: [PATCH] MARKDOWNBuilder: support listnum --- lib/review/markdownbuilder.rb | 7 +++++++ test/test_markdownbuilder.rb | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/review/markdownbuilder.rb b/lib/review/markdownbuilder.rb index 624f113a7..9971195c5 100644 --- a/lib/review/markdownbuilder.rb +++ b/lib/review/markdownbuilder.rb @@ -80,6 +80,13 @@ def list_body(_id, lines, _lang) puts '```' end + def listnum_body(lines, _lang) + lines.each_with_index do |line, i| + puts((i + 1).to_s.rjust(2) + ": #{detab(line)}") + end + puts '```' + end + def ul_begin blank if @ul_indent == 0 @ul_indent += 1 diff --git a/test/test_markdownbuilder.rb b/test/test_markdownbuilder.rb index 2d1b05ffe..f415b1374 100644 --- a/test/test_markdownbuilder.rb +++ b/test/test_markdownbuilder.rb @@ -187,6 +187,23 @@ def test_list_lang EOS end + def test_listnum + def @chapter.list(_id) + Book::ListIndex::Item.new('test', 1) + end + actual = compile_block("//listnum[test][this is @{test}<&>_]{\nfoo\nbar\n\tbuz\n//}\n") + expected = <<-EOS +リスト1.1 this is **test**<&>_ + +``` + 1: foo + 2: bar + 3: buz +``` +EOS + assert_equal expected, actual + end + def test_emlist_lang actual = compile_block(<<-EOS) //emlist[caption][ruby]{