Skip to content

Commit

Permalink
add continuation logic in visit_listitem adjusted to accomodate proce…
Browse files Browse the repository at this point in the history
…dures (PR #57)
  • Loading branch information
fbolton authored Oct 12, 2023
1 parent 873b12e commit b9314be
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/docbookrx/docbook_visitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
70 changes: 70 additions & 0 deletions spec/lib/docbookrx/docbookrx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
<article xmlns='http://docbook.org/ns/docbook'
xmlns:xl="http://www.w3.org/1999/xlink"
version="5.0" xml:lang="en">
<itemizedlist>
<listitem>
<para>simple</para>
</listitem>
<listitem>
<para>procedure inside listitem</para>
<procedure>
<step>
<para>first step</para>
</step>
<step>
<para>second step</para>
</step>
</procedure>
</listitem>
</itemizedlist>
<para>break!</para>
<procedure>
<step>
<para>first step</para>
</step>
<step>
<para>second step</para>
</step>
<step>
<para>third step is a nested itemizedlist</para>
<itemizedlist>
<listitem>
<para>foo</para>
</listitem>
<listitem>
<para>bar</para>
</listitem>
</itemizedlist>
</step>
<step>
<para>fourth step</para>
</step>
</procedure>
</article>
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
<article xmlns='http://docbook.org/ns/docbook'
Expand Down

0 comments on commit b9314be

Please sign in to comment.