From b9314be47d7e8a184c3bb67738dffe0214681d21 Mon Sep 17 00:00:00 2001 From: Fintan Bolton Date: Thu, 12 Oct 2023 11:07:14 +0200 Subject: [PATCH] add continuation logic in visit_listitem adjusted to accomodate procedures (PR #57) --- lib/docbookrx/docbook_visitor.rb | 6 +-- spec/lib/docbookrx/docbookrx_spec.rb | 70 ++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 3 deletions(-) diff --git a/lib/docbookrx/docbook_visitor.rb b/lib/docbookrx/docbook_visitor.rb index 8c67485..47162fe 100644 --- a/lib/docbookrx/docbook_visitor.rb +++ b/lib/docbookrx/docbook_visitor.rb @@ -331,7 +331,7 @@ def after_traverse node, method else method_name = method.to_s case method_name - when "visit_itemizedlist", "visit_orderedlist" + when "visit_itemizedlist", "visit_orderedlist", "visit_procedure", "visit_substeps", "visit_stepalternatives" @list_depth -= 1 when "visit_table", "visit_informaltable" @in_table = false @@ -729,7 +729,7 @@ def visit_listitem node end local_continuation = false - unless i == 0 || first_line || (child.name == 'literallayout' || child.name == 'itemizedlist' || child.name == 'orderedlist') + unless i == 0 || first_line || (child.name == 'literallayout' || child.name == 'itemizedlist' || child.name == 'orderedlist' || child.name == 'procedure') append_line '+' @continuation = true local_continuation = true @@ -769,7 +769,7 @@ def visit_listitem node if first_line && ! local_continuation append_text ' {empty}' # necessary to fool asciidoctorj into thinking that this is a listitem end - unless local_continuation || (child.name == 'literallayout' || child.name == 'itemizedlist' || child.name == 'orderedlist') + unless local_continuation || (child.name == 'literallayout' || child.name == 'itemizedlist' || child.name == 'orderedlist' || child.name == 'procedure') append_line '+' end @continuation = false diff --git a/spec/lib/docbookrx/docbookrx_spec.rb b/spec/lib/docbookrx/docbookrx_spec.rb index 154be62..446f6ce 100644 --- a/spec/lib/docbookrx/docbookrx_spec.rb +++ b/spec/lib/docbookrx/docbookrx_spec.rb @@ -714,6 +714,76 @@ expect(output).to include(expected) end + it 'should convert itemizedlist nested inside procedure, and procedure nested inside itemizedlist correctly' do + input = <<-EOS +
+ + + simple + + + procedure inside listitem + + + first step + + + second step + + + + + break! + + + first step + + + second step + + + third step is a nested itemizedlist + + + foo + + + bar + + + + + fourth step + + +
+ EOS + + expected = <<-EOS + +* simple +* procedure inside listitem + +.. first step +.. second step + +break! + + +. first step +. second step +. third step is a nested itemizedlist +** foo +** bar +. fourth step + EOS + output = Docbookrx.convert input + + expect(output).to eql(expected) + end + it 'should add all table lines and escape | characters in table text' do input = <<-EOS