Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for conversion of procedure element #57

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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
Expand Down Expand Up @@ -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
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 @@ -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
<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