HTML Table processing

Overview

In Quarto 1.3, we have made some changes to how tables are processed. Recent Pandoc versions have added support for parsing HTML tables into Pandoc’s native data structures (including features such as rowspans and colspans), and Quarto now leverages this to make it easier to properly formatted tables in all formats.

HTML tables are now processed in every format

Specifically, Quarto will now attempt to parse HTML tables in RawBlock Pandoc nodes and convert them to Markdown tables, in every output format (including non-html formats). As a result, you can now use HTML table syntax in your documents and they will be properly converted to Markdown tables for all formats, and libraries which emit computational tables in HTML format can work in other output formats. In addition, this will allow Lua filters to manipulate the content of tables specified in HTML format.

Embedded Markdown content can be specified

In addition, Quarto now supports the specification of embedded Markdown content in tables. This is done by providing a data attribute qmd or qmd-base64 in an embedded span or div node. These nodes can appear anywhere that such content is allowed: table headers, footers, cells, captions, etc. For example, consider following table:

<table>
  <caption><span data-qmd="As described in @Lovelace1864, computers are great."></span></caption>
  <thead>
    <tr>
      <th><span data-qmd="_Header 1_"></span></th>
      <th><span data-qmd="_Header 2_"></span></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span data-qmd=""></span></td>
      <td>Regular output</td>
    </tr>
  </tbody>
</table>

The span nodes with the data-qmd attribute will be processed as embedded Markdown content. This allows you to embed arbitrary Markdown content in your tables, including citations, videos, etc. One thing to keep in mind is that the content of data-qmd needs to be escaped properly. Authors of libraries which generate table outputs should consider using the data-qmd-base64 attribute, which will be decoded and then processed by Quarto.