From 4d86ec95000a09fcca5ca69ddbb73467a0597aec Mon Sep 17 00:00:00 2001 From: Fintan Bolton Date: Mon, 2 Jan 2017 17:36:24 +0100 Subject: [PATCH] add continuation logic in visit_listitem adjusted to accomodate procedures --- 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 b6b55f3..f7b10cb 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 @@ -717,7 +717,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 @@ -757,7 +757,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 f5c4b90..f147900 100644 --- a/spec/lib/docbookrx/docbookrx_spec.rb +++ b/spec/lib/docbookrx/docbookrx_spec.rb @@ -672,6 +672,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 include(expected) + end + it 'should add all table lines and escape | characters in table text' do input = <<-EOS