jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.91k stars 3.39k forks source link

ODT writer drops tables in lists #3430

Open HT2313 opened 7 years ago

HT2313 commented 7 years ago

Hi, I'm using Pandoc 1.19.2.1, to create the ODT files from DocBook with the command that follows: pandoc -S -s -f docbook -t odt simple.xml -o simple.odt --file-scope

When DocBook file contains table defined within the list, in generated ODT file table is not visible.

Following is the DocBook file with table defined within the list item:

<?xml version="1.0" encoding="UTF-8"?>
<article xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en">
  <orderedlist numeration="arabic">
    <listitem>
      <simpara>Element 1</simpara>
    </listitem>
    <listitem>
      <simpara>Element 2<?asciidoc-br?>
      Table:</simpara>
      <informaltable frame="all" rowsep="1" colsep="1">
        <tgroup cols="2">
          <colspec colname="col_1" colwidth="50*"/>
          <colspec colname="col_2" colwidth="50*"/>
          <tbody>
            <row>
              <entry align="left" valign="top">
                <simpara>1</simpara>
              </entry>
              <entry align="left" valign="top">
                <simpara>2</simpara>
              </entry>
            </row>
            <row>
              <entry align="left" valign="top">
                <simpara>3</simpara>
              </entry>
              <entry align="left" valign="top">
                <simpara>4</simpara>
              </entry>
            </row>
          </tbody>
        </tgroup>
      </informaltable>
      <simpara>More text for element 2</simpara>
    </listitem>
    <listitem>
      <simpara>Element 3</simpara>
    </listitem>
  </orderedlist>
</article>

Generated ODT file has following content:

<?xml version="1.0" encoding="utf-8" ?>
<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.2">
  <office:font-face-decls>
    <style:font-face style:name="Courier New" style:font-family-generic="modern" style:font-pitch="fixed" svg:font-family="'Courier New'" />
  </office:font-face-decls>
  <office:automatic-styles>
    <text:list-style style:name="L1">
      <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="1" style:num-suffix=".">
        <style:list-level-properties text:space-before="0.25in" text:min-label-width="0.25in" />
      </text:list-level-style-number>
    </text:list-style>
    <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L1">
    </style:style>
    <style:style style:name="Table1" style:family="table">
      <style:table-properties table:align="center" />
    </style:style>
    <style:style style:name="Table1.A" style:family="table-column">
      <style:table-column-properties style:rel-column-width="32767*" />
    </style:style>
    <style:style style:name="Table1.B" style:family="table-column">
      <style:table-column-properties style:rel-column-width="32767*" />
    </style:style>
    <style:style style:name="Table1.A1" style:family="table-cell">
      <style:table-cell-properties fo:border="none" />
    </style:style>
  </office:automatic-styles>
<office:body>
<office:text>
<text:list text:style-name="L1">
  <text:list-item>
    <text:p text:style-name="P1">Element 1</text:p>
  </text:list-item>
  <text:list-item>
    <text:p text:style-name="P1">Element 2<text:line-break />Table:</text:p>
    <table:table table:name="Table1" table:style-name="Table1">
      <table:table-column table:style-name="Table1.A" />
      <table:table-column table:style-name="Table1.B" />
      <table:table-row>
        <table:table-cell table:style-name="Table1.A1" office:value-type="string">
          <text:p text:style-name="Table_20_Contents">1</text:p>
        </table:table-cell>
        <table:table-cell table:style-name="Table1.A1" office:value-type="string">
          <text:p text:style-name="Table_20_Contents">2</text:p>
        </table:table-cell>
      </table:table-row>
      <table:table-row>
        <table:table-cell table:style-name="Table1.A1" office:value-type="string">
          <text:p text:style-name="Table_20_Contents">3</text:p>
        </table:table-cell>
        <table:table-cell table:style-name="Table1.A1" office:value-type="string">
          <text:p text:style-name="Table_20_Contents">4</text:p>
        </table:table-cell>
      </table:table-row>
    </table:table>
    <text:p text:style-name="P1">More text for element 2</text:p>
  </text:list-item>
  <text:list-item>
    <text:p text:style-name="P1">Element 3</text:p>
  </text:list-item>
</text:list>
</office:text>
</office:body>
</office:document-content>

The table is not visible in because it is defined within the <text:list-item> element.

Following is the algorithm for processing lists with tables:

  1. Create <text:list> element
  2. Create <text:list-item> element
  3. Process the elements of list item. If element of the list item is not table add element to <text:list-item>
  4. If element of the list item is table element then CLOSE both <text:list-item> and <text:list> elements
  5. Create table
  6. Create new <text:list> element with text:continue-numbering="true" attribute
  7. If the table element is not last element of the previously closed list item then add <text:list-header> element and in that element place the rest of the list item elements
  8. Continue processing list elements

Here is the expected ODT file content:

<?xml version="1.0" encoding="utf-8" ?>
<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.2">
  <office:font-face-decls>
    <style:font-face style:name="Courier New" style:font-family-generic="modern" style:font-pitch="fixed" svg:font-family="'Courier New'" />
  </office:font-face-decls>
  <office:automatic-styles>
    <text:list-style style:name="L1">
      <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="1" style:num-suffix=".">
        <style:list-level-properties text:space-before="0.25in" text:min-label-width="0.25in" />
      </text:list-level-style-number>
    </text:list-style>
    <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L1">
    </style:style>
    <style:style style:name="Table1" style:family="table">
      <style:table-properties table:align="center" />
    </style:style>
    <style:style style:name="Table1.A" style:family="table-column">
      <style:table-column-properties style:rel-column-width="32767*" />
    </style:style>
    <style:style style:name="Table1.B" style:family="table-column">
      <style:table-column-properties style:rel-column-width="32767*" />
    </style:style>
    <style:style style:name="Table1.A1" style:family="table-cell">
      <style:table-cell-properties fo:border="none" />
    </style:style>
  </office:automatic-styles>
<office:body>
<office:text>
<text:list text:style-name="L1">
  <text:list-item>
    <text:p text:style-name="P1">Element 1</text:p>
  </text:list-item>
  <text:list-item>
    <text:p text:style-name="P1">Element 2<text:line-break />Table:</text:p>
  </text:list-item>
</text:list>
<table:table table:name="Table1" table:style-name="Table1">
  <table:table-column table:style-name="Table1.A" />
  <table:table-column table:style-name="Table1.B" />
  <table:table-row>
    <table:table-cell table:style-name="Table1.A1" office:value-type="string">
      <text:p text:style-name="Table_20_Contents">1</text:p>
    </table:table-cell>
    <table:table-cell table:style-name="Table1.A1" office:value-type="string">
      <text:p text:style-name="Table_20_Contents">2</text:p>
    </table:table-cell>
  </table:table-row>
  <table:table-row>
    <table:table-cell table:style-name="Table1.A1" office:value-type="string">
      <text:p text:style-name="Table_20_Contents">3</text:p>
    </table:table-cell>
    <table:table-cell table:style-name="Table1.A1" office:value-type="string">
      <text:p text:style-name="Table_20_Contents">4</text:p>
    </table:table-cell>
  </table:table-row>
</table:table>
<text:list text:style-name="L1" text:continue-numbering="true">
  <text:list-header>
    <text:p text:style-name="P1">More text for element 2</text:p>
  </text:list-header>
  <text:list-item>
    <text:p text:style-name="P1">Element 3</text:p>
  </text:list-item>
</text:list>
</office:text>
</office:body>
</office:document-content>

Table in nested list

Here is the DocBook file content that contains table in nested list:

<?xml version="1.0" encoding="UTF-8"?>
<article xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en">
  <orderedlist numeration="arabic">
    <listitem>
      <simpara>Element 1</simpara>
    </listitem>
    <listitem>
      <simpara>Element 2</simpara>
      <orderedlist numeration="loweralpha">
        <listitem>
          <simpara>Element 2.1</simpara>
        </listitem>
        <listitem>
          <simpara>Element 2.1</simpara>
          <simpara>Table:</simpara>
          <informaltable frame="all" rowsep="1" colsep="1">
            <tgroup cols="2">
              <colspec colname="col_1" colwidth="50*"/>
              <colspec colname="col_2" colwidth="50*"/>
              <tbody>
                <row>
                  <entry align="left" valign="top"><simpara>1</simpara></entry>
                  <entry align="left" valign="top"><simpara>2</simpara></entry>
                </row>
                <row>
                  <entry align="left" valign="top"><simpara>3</simpara></entry>
                  <entry align="left" valign="top"><simpara>4</simpara></entry>
                </row>
              </tbody>
            </tgroup>
          </informaltable>
        </listitem>
        <listitem>
          <simpara>Element 2.3</simpara>
        </listitem>
      </orderedlist>
    </listitem>
    <listitem>
      <simpara>Element 3</simpara>
    </listitem>
  </orderedlist>
</article>

Expected ODT content is:

<?xml version="1.0" encoding="utf-8" ?>
<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.2">
  <office:font-face-decls>
    <style:font-face style:name="Courier New" style:font-family-generic="modern" style:font-pitch="fixed" svg:font-family="'Courier New'" />
  </office:font-face-decls>
  <office:automatic-styles>
    <text:list-style style:name="L1">
      <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-format="1" text:start-value="1" style:num-suffix=".">
        <style:list-level-properties text:space-before="0.25in" text:min-label-width="0.25in" />
      </text:list-level-style-number>
      <text:list-level-style-number text:level="2" text:style-name="Numbering_20_Symbols" style:num-format="a" text:start-value="1" style:num-suffix=".">
        <style:list-level-properties text:space-before="0.5in" text:min-label-width="0.25in" />
      </text:list-level-style-number>
    </text:list-style>
    <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L1">
    </style:style>
    <style:style style:name="Table1" style:family="table">
      <style:table-properties table:align="center" />
    </style:style>
    <style:style style:name="Table1.A" style:family="table-column">
      <style:table-column-properties style:rel-column-width="32767*" />
    </style:style>
    <style:style style:name="Table1.B" style:family="table-column">
      <style:table-column-properties style:rel-column-width="32767*" />
    </style:style>
    <style:style style:name="Table1.A1" style:family="table-cell">
      <style:table-cell-properties fo:border="none" />
    </style:style>
  </office:automatic-styles>
<office:body>
<office:text>
<text:list text:style-name="L1">
  <text:list-item>
    <text:p text:style-name="P1">Element 1</text:p>
  </text:list-item>
  <text:list-item>
    <text:p text:style-name="P1">Element 2</text:p>
    <text:list>
      <text:list-item>
        <text:p text:style-name="P1">Element 2.1</text:p>
      </text:list-item>
      <text:list-item>
        <text:p text:style-name="P1">Element 2.1</text:p>
        <text:p text:style-name="P1">Table:</text:p>
      </text:list-item>
    </text:list>
  </text:list-item>
</text:list>
<table:table table:name="Table1" table:style-name="Table1">
  <table:table-column table:style-name="Table1.A" />
  <table:table-column table:style-name="Table1.B" />
  <table:table-row>
    <table:table-cell table:style-name="Table1.A1" office:value-type="string">
      <text:p text:style-name="Table_20_Contents">1</text:p>
    </table:table-cell>
    <table:table-cell table:style-name="Table1.A1" office:value-type="string">
      <text:p text:style-name="Table_20_Contents">2</text:p>
    </table:table-cell>
  </table:table-row>
  <table:table-row>
    <table:table-cell table:style-name="Table1.A1" office:value-type="string">
      <text:p text:style-name="Table_20_Contents">3</text:p>
    </table:table-cell>
    <table:table-cell table:style-name="Table1.A1" office:value-type="string">
      <text:p text:style-name="Table_20_Contents">4</text:p>
    </table:table-cell>
  </table:table-row>
</table:table>
<text:list text:style-name="L1" text:continue-numbering="true">
  <text:list-item>
    <text:list>
      <text:list-item>
        <text:p text:style-name="P1">Element 2.3</text:p>
      </text:list-item>
    </text:list>
  </text:list-item>
  <text:list-item>
    <text:p text:style-name="P1">Element 3</text:p>
  </text:list-item>
</text:list>
</office:text>
</office:body>
</office:document-content>

Note that in this case when table element is found all opened <text:list-item> and <text:list> elements have to be closed. After table is added reopen appropriate number of <text:list> and <text:list-item> elements and continue with list processing. Only the first reopened <text:list> element should have text:continue-numbering="true" attribute.

This issue is related to #2027.

mb21 commented 7 years ago

So this is a bug in the ODT writer? (to test: e.g. the HTML output is correct for the posted docbook input, right?)

HT2313 commented 7 years ago

Yes. For the DocBook file with single level list with table:

<?xml version="1.0" encoding="UTF-8"?>
<article xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en">
  <orderedlist numeration="arabic">
    <listitem>
      <simpara>Element 1</simpara>
    </listitem>
    <listitem>
      <simpara>Element 2<?asciidoc-br?>
      Table:</simpara>
      <informaltable frame="all" rowsep="1" colsep="1">
        <tgroup cols="2">
          <colspec colname="col_1" colwidth="50*"/>
          <colspec colname="col_2" colwidth="50*"/>
          <tbody>
            <row>
              <entry align="left" valign="top">
                <simpara>1</simpara>
              </entry>
              <entry align="left" valign="top">
                <simpara>2</simpara>
              </entry>
            </row>
            <row>
              <entry align="left" valign="top">
                <simpara>3</simpara>
              </entry>
              <entry align="left" valign="top">
                <simpara>4</simpara>
              </entry>
            </row>
          </tbody>
        </tgroup>
      </informaltable>
      <simpara>More text for element 2</simpara>
    </listitem>
    <listitem>
      <simpara>Element 3</simpara>
    </listitem>
  </orderedlist>
</article>

The HTML output is fine:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title></title>
  <style type="text/css">code{white-space: pre;}</style>
</head>
<body>
  <ol style="list-style-type: decimal">
    <li><p>Element 1</p></li>
    <li><p>Element 2<br />
      Table:</p>
      <table>
        <colgroup>
          <col width="50%" />
          <col width="50%" />
        </colgroup>
        <tbody>
          <tr class="odd">
            <td><p>1</p></td>
            <td><p>2</p></td>
          </tr>
          <tr class="even">
            <td><p>3</p></td>
            <td><p>4</p></td>
          </tr>
        </tbody>
      </table>
      <p>More text for element 2</p></li>
    <li><p>Element 3</p></li>
  </ol>
</body>
</html>

And for the table in nested list:

<?xml version="1.0" encoding="UTF-8"?>
<article xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en">
  <orderedlist numeration="arabic">
    <listitem>
      <simpara>Element 1</simpara>
    </listitem>
    <listitem>
      <simpara>Element 2</simpara>
      <orderedlist numeration="loweralpha">
        <listitem>
          <simpara>Element 2.1</simpara>
        </listitem>
        <listitem>
          <simpara>Element 2.1</simpara>
          <simpara>Table:</simpara>
          <informaltable frame="all" rowsep="1" colsep="1">
            <tgroup cols="2">
              <colspec colname="col_1" colwidth="50*"/>
              <colspec colname="col_2" colwidth="50*"/>
              <tbody>
                <row>
                  <entry align="left" valign="top"><simpara>1</simpara></entry>
                  <entry align="left" valign="top"><simpara>2</simpara></entry>
                </row>
                <row>
                  <entry align="left" valign="top"><simpara>3</simpara></entry>
                  <entry align="left" valign="top"><simpara>4</simpara></entry>
                </row>
              </tbody>
            </tgroup>
          </informaltable>
        </listitem>
        <listitem>
          <simpara>Element 2.3</simpara>
        </listitem>
      </orderedlist>
    </listitem>
    <listitem>
      <simpara>Element 3</simpara>
    </listitem>
  </orderedlist>
</article>

The output HTML file is also correct:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title></title>
  <style type="text/css">code{white-space: pre;}</style>
</head>
<body>
  <ol style="list-style-type: decimal">
    <li><p>Element 1</p></li>
    <li><p>Element 2</p>
      <ol style="list-style-type: lower-alpha">
        <li><p>Element 2.1</p></li>
        <li><p>Element 2.1</p>
          <p>Table:</p>
          <table>
            <colgroup>
              <col width="50%" />
              <col width="50%" />
            </colgroup>
            <tbody>
              <tr class="odd">
                <td><p>1</p></td>
                <td><p>2</p></td>
              </tr>
              <tr class="even">
                <td><p>3</p></td>
                <td><p>4</p></td>
              </tr>
            </tbody>
          </table></li>
        <li><p>Element 2.3</p></li>
      </ol></li>
    <li><p>Element 3</p></li>
  </ol>
</body>
</html>

When converting to ODT the table is created but it is placed in <list-item> element, which is not allowed by the the spec. To get around of this problem, when you found table inside of the list you have to close that list , put table and then continue with the list. (At least LibreOffice work in this way).

mb21 commented 7 years ago

So this issue seems pretty much a duplicate of #2027 then: the ODT writer should handle tables in lists differently.

schrieveslaach commented 7 years ago

I have the same issue with nested tables in LaTeX.

I'm trying to fix this, but I need some help. Here is a diff for transforming the document:

diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs
index 395ef0a9..b880525d 100644
--- a/src/Text/Pandoc/Writers/ODT.hs
+++ b/src/Text/Pandoc/Writers/ODT.hs
@@ -86,7 +86,8 @@ pandocToODT opts doc@(Pandoc meta _) = do
   -- handle formulas and pictures
   -- picEntriesRef <- P.newIORef ([] :: [Entry])
   doc' <- walkM (transformPicMath opts) $ walk fixDisplayMath doc
-  newContents <- lift $ writeOpenDocument opts{writerWrapText = WrapNone} doc'
+  doc'' <- walkM (transformLists opts) doc'
+  newContents <- lift $ writeOpenDocument opts{writerWrapText = WrapNone} doc''
   epochtime <- floor `fmap` (lift P.getPOSIXTime)
   let contentEntry = toEntry "content.xml" epochtime
                      $ fromStringLazy newContents
@@ -210,3 +211,9 @@ transformPicMath _ (Math t math) = do
                                         , ("xlink:actuate", "onLoad")]

 transformPicMath _ x = return x
+
+-- | transform list elements: moving tables to the outside
+transformLists :: PandocMonad m => WriterOptions -> Block -> O m Block
+transformLists opts (BulletList list) = return list
+
+transformLists _ x = return x

With this changes I get an compiler error:

src/Text/Pandoc/Writers/ODT.hs:217:41: error:
    • Couldn't match type ‘[[Block]]’ with ‘Block’
      Expected type: O m Block
        Actual type: StateT ODTState m [[Block]]
    • In the expression: return list
      In an equation for ‘transformLists’:
          transformLists opts (BulletList list) = return list

@jgm, do have any suggestions?

mb21 commented 4 years ago

@HT2313 so ODT has no way to have a table inside a list item? So what would be the expected ODT output XML for this markdown input?


1) Lorem ipsum

   | Name               | Description        |
   | -------------------|--------------------|
   | `param_1`          | Lorem ipsum        |
   | `param_2`          | Lorem ipsum        |

2) Dolor sit amet

Actually, the output of pandoc 2.9 is pretty good? (rename .zip to .odt) output.zip

At least when I view it in calibre's ebook-viewer:

Screenshot 2019-12-15 at 12 57 28

maybe it's different in LibreOffice and/or OpenOffice?

In Apple's TextEdit it's somewhat funny as well:

Screenshot 2019-12-15 at 12 56 01
AugustH commented 4 years ago

no table in libreoffice 6.0 (linux mint)

AugustH commented 4 years ago

libre

mb21 commented 4 years ago

So what would be the expected XML? or can you post the expected file? is there really no way to have a table inside the list in libreoffice?

AugustH commented 4 years ago

It seems that libreoffice makes it hard to create a table within a list. The table gets always created "full width", but the numbered list continues around/after the table - see example (.odt renamed to .zip) libre.zip

PRESFIL commented 2 years ago

Any updates on this?