Hi, Problem =======
When exporting a DocBook LyX document to a DocBook SGML/XML file there's a problem with the generation of <listitem> tags. When a sub list (embedded list) is present, Lyx opens a new <listitem> tag for the sub list after closing the already open tag instead of including the sub list within the already open <listitem>. The problem first appeared around April 2006 when I started using Lyx 1.4.x and moved from lyxformat 221 to lyxformat 245. I only got a chance to debug the issue last week. LinuxDoc export does not have the same issue, because it doesn't close <item> tags. Patch ===== lyx-1.4.3-docbook-list.patch The problem is in file: src/output_docbook.C function: ParagraphList::const_iterator makeEnvironment() NOTE: The 'break' statement was added only because it made debugging easier. Testing ======= * Testcase: testcase-docbook-list.lyx * Incorrect output: testcase-docbook-list.incorrect.sgml * Correct output: testcase-docbook-list.correct.sgml NOTE: 4 files attached. cya, #
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.2//EN" [ <!ENTITY % output.print.png "IGNORE"> <!ENTITY % output.print.pdf "IGNORE"> <!ENTITY % output.print.eps "IGNORE"> <!ENTITY % output.print.bmp "IGNORE"> ]> <!-- SGML file was created by LyX 1.4.3 See http://www.lyx.org/ for more information --> <article lang="en"> <itemizedlist> <listitem><para>Depth One Item One</para></listitem><listitem><para>Depth One Item Two</para><itemizedlist> <listitem><para>Depth Two Item One</para></listitem><listitem><para>Depth Two Item Two</para></listitem></itemizedlist></listitem><listitem><para>Depth One Item Three</para></listitem></itemizedlist></article>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.2//EN" [ <!ENTITY % output.print.png "IGNORE"> <!ENTITY % output.print.pdf "IGNORE"> <!ENTITY % output.print.eps "IGNORE"> <!ENTITY % output.print.bmp "IGNORE"> ]> <!-- SGML file was created by LyX 1.4.3 See http://www.lyx.org/ for more information --> <article lang="en"> <itemizedlist> <listitem><para>Depth One Item One</para></listitem><listitem><para>Depth One Item Two</para></listitem><listitem><itemizedlist> <listitem><para>Depth Two Item One</para></listitem><listitem><para>Depth Two Item Two</para></listitem></itemizedlist></listitem><listitem><para>Depth One Item Three</para></listitem></itemizedlist></article>
testcase-docbook-list.lyx
Description: application/lyx
diff -ru lyx-1.4.3.orig/src/output_docbook.C lyx-1.4.3/src/output_docbook.C --- lyx-1.4.3.orig/src/output_docbook.C 2006-03-24 23:37:15.000000000 +0600 +++ lyx-1.4.3/src/output_docbook.C 2007-01-01 22:07:38.000000000 +0530 @@ -160,7 +160,13 @@ sgml::closeTag(os, bstyle->labeltag()); } wrapper = defaultstyle->latexname(); - sgml::openTag(os, bstyle->itemtag()); + // If a sub list (embedded list) appears next with a + // different depth, then there is no need to open + // another tag at the current depth. + if(par->params().depth() == pbegin->params().depth()) { + sgml::openTag(os, bstyle->itemtag()); + } + break; default: break; } @@ -197,7 +203,17 @@ } break; case LATEX_ITEM_ENVIRONMENT: - sgml::closeTag(os, bstyle->itemtag()); + // If a sub list (embedded list) appears next, then + // there is no need to close the current tag. + // par should have already been incremented to the next + // element. So we can compare the depth of the next + // element with pbegin. + // We need to be careful, that we don't dereference par + // when par == pend but at the same time that the + // current tag is closed. + if((par != pend && par->params().depth() == pbegin->params().depth()) || par == pend) { + sgml::closeTag(os, bstyle->itemtag()); + } if (!bstyle->labeltag().empty()) sgml::closeTag(os, bstyle->innertag()); break;