pandoc / lua-filters

A collection of lua filters for pandoc
MIT License
602 stars 165 forks source link

Update list-table #204

Closed not-my-profile closed 2 years ago

not-my-profile commented 2 years ago

The new version introduces support for:

Furthermore the documentation has been improved.

Please don't squash my commits ;)

mustafa0x commented 2 years ago

Well, this is simply incredible.

tarleb commented 2 years ago

This is great, thank you!

A heads-up: we are in the process of making tables a bit more user-friendly. E.g., we now have types and constructors pandoc.TableHead, pandoc.TableFoot, and pandoc.Row instead of using Attr-value pairs. This breaks backwards compatibility. See https://github.com/jgm/pandoc/issues/7718 for some context. I'm open to add limited backwards compatibility so your filter won't break, but you'd probably want to update some code either way.

Since you put significant time into working with tables, it would be great to hear your ideas on how to make the Lua interface better. Please feel free to open new issues if anything comes to mind.

not-my-profile commented 2 years ago

Hey :) I don't mind updating my filter when the new Pandoc version with these constructors is released, so you don't have to add backwards compatibility just for my filter.

Since you put significant time into working with tables, it would be great to hear your ideas on how to make the Lua interface better.

I noticed something about SimpleTable, which I reported yesterday (https://github.com/jgm/pandoc/issues/7776).

I am actually not very familiar with Lua so I don't think I can say much about the API design.

I think the formatting of the Lua API docs could be improved by making it more vertically compact (i.e. displaying parameter name and description next to each other). document.body.scrollHeight reports 75987px for me which I think translates to 20 meters ... that's a bit long. With all of this up and down scrolling it's easy to get lost. Apart from making the page more compact, adding some table of contents that shows your current position would also help.

h2 and h3 look very similar ... maybe if h2 were bold they were easier to spot and could help with orientation.

image

image

mustafa0x commented 2 years ago

Minor: this failed to produce any output on pandoc 2.14.2 (no error though). Upgrading to latest (2.16.2) fixed.

$>pandoc --lua-filter list-table.lua --verbose

:::list-table
   * - row 1, column 1
     - row 1, column 2
     - row 1, column 3

   * - row 2, column 1
     -
     - row 2, column 3

   * - row 3, column 1
     - row 3, column 2
:::

[INFO] Running filter list-table.lua
[INFO] Completed filter list-table.lua in 6 ms
tarleb commented 2 years ago

Curious. That usually happens when pandoc failed to retrieve the Table object. You could try to wrap the Table in a list to get different behavior and hopefully an error message.

We did a complete overhaul of the Lua subsystem in pandoc 2.15 and 2.16, in part to avoid these kind of cryptic problems. Error reporting is much better now – but still has weak points and needs a bit more work.

mustafa0x commented 2 years ago

Another minor issue: colspan doesn't work with headers unless a redundant field is added. Worse, it'll remove later fields (see how no "cell 2" in output).

::: list-table
*  - []{colspan=2}header
*  - cell 1
   - cell 2
:::
<table>
  <thead>
    <tr class="header">
      <th>header</th>
    </tr>
  </thead>
  <tbody>
    <tr class="odd">
      <td>cell 1</td>
    </tr>
  </tbody>
</table>

With redundant header field:

::: list-table
*  - []{colspan=2}header
   - IGNORED
*  - cell 1
   - cell 2
:::
<table>
  <thead>
    <tr class="header">
      <th colspan="2">header</th>
    </tr>
  </thead>
  <tbody>
    <tr class="odd">
      <td>cell 1</td>
      <td>cell 2</td>
    </tr>
  </tbody>
</table>

This problem doesn't occur when using colspan for later rows.

not-my-profile commented 2 years ago

@mustafa0x ah yeah, my bad ... will be fixed by #205.