You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The format_text method in lib/docbookrx/docbookrx_visitors.rb calls @lines.pop, which causes problems when we have nested elements.
For example:
<listitem>
<para>get all process definitions</para>
<para>
<programlisting>Collection definitions = runtimeDataService.getProcesses(new QueryContext());</programlisting>
</para>
</listitem>
<listitem>
<para>get active process instances
<programlisting>Collection<processinstancedesc> instances = runtimeDataService.getProcessInstances(new QueryContext());</programlisting></para>
</listitem>
The first listitem is formatted correctly -- while the second is not. The problem is that the code doesn't expect the <para> element to contain the <programlisting>, and pops the formatting for the [source] ("----" in this case), so that you get something that looks like this:
* get all process definitions
+
[source]
----
Collection definitions = runtimeDataService.getProcesses(new QueryContext());
----
[source]
----
Collection<processinstancedesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
* ----
get active nodes for given process instance
The problem is that we have the following code in format_text:
defvisit_listitemnodeelements=node.elements.to_aitem_text=ifelements.size > 0format_textelements.shiftelseformat_textnodeend# create line with marker and item_text and append it..
This means that the text is appended to @lines, then the <programlisting> element is processed (and added to @lines by proceed node in format_text) and only then is the marker added.. which gives us the incorrect asciidoc shown above.
The text was updated successfully, but these errors were encountered:
mrietveld
changed the title
Nested <programlisting> element in <para> not handled correctly
Nested <programlisting> element in <para> in <listitem> not handled correctly
May 10, 2016
Thanks for this fix. What worries, me though, is that it seems like this is invalid DocBook and there are a lot of such scenarios that perhaps we shouldn't fix. Is it even valid to have a program listing inside a paragraph?
I'm okay with addressing corner cases that appear frequently, perhaps like this one, but I think we should have a least some restrictions on what DocBook we allow. We can expect some cleanup occur before we touch the DocBook. (Another goal, perhaps, for the planned contributing guide).
This is related to #25:
This is actually a bug.
The
format_text
method inlib/docbookrx/docbookrx_visitors.rb
calls@lines.pop
, which causes problems when we have nested elements.For example:
The first
listitem
is formatted correctly -- while the second is not. The problem is that the code doesn't expect the<para>
element to contain the<programlisting>
, and pops the formatting for the[source]
("----" in this case), so that you get something that looks like this:The problem is that we have the following code in
format_text
:and in
visit_listitem
we have:This means that the text is appended to
@lines
, then the<programlisting>
element is processed (and added to@lines
byproceed node
informat_text
) and only then is the marker added.. which gives us the incorrect asciidoc shown above.The text was updated successfully, but these errors were encountered: