Missing (Quarto) shortcode when used as first item in table
Hi,
this is a mixed bug report, since I'm using Quarto as frontend to Pandoc, however this extension is described as the solution to some problems with grid tables (see) in Quarto.
So, when having a Quarto file with list-table extension and a shortcode providing extension like fancy-text:
---
title: Untitled
format:
pdf: default
filters:
- pandoc-ext/list-table
- quarto-ext/fancy-text
author: me
date: last-modified
---
- {{< latex >}} Fancy Latex is there
:::{.list-table}
* - {{< latex >}} Fancy Latex missing
* - From {{< latex >}} to {{< bibtex >}}
:::
I get the first shortcode content missing in my table.
The reason is that a Span can be also used to tweak the style of the table and while handling this it gets moved to the attributes of the table.
I was able to fix it for me against the current version around here: https://github.com/pandoc-ext/list-table/blob/5f6d1a809c5f34a4d1986e9c216fab29e6c8c79a/_extensions/list-table/list-table.lua#L124 but I don't know if this is generally valid, so please check:
128a129,132
> if contents[1].content[1].attr.attributes.__quarto_custom ~= nil and
> contents[1].content[1].attr.attributes.__quarto_custom then
> goto continue
> end
136a141
> ::continue::
So does {{< latex >}} expand to something that starts with an empty Span with attributes? Please could you slightly expand your example to show the problematic span? Thanks.
Sure, and yes. The bullet list is seen in list-table as:
[BulletList [[Plain [Span ("",[],[("__quarto_custom","true"),("__quarto_custom_type","Shortcode"),("__quarto_custom_context","Inline"),("__quarto_custom_id","2")]) [],Space,Str "Fancy",Space,Str "Latex",Space,Str "missing"]]]]
[Plain [Span ("",[],[("__quarto_custom","true"),("__quarto_custom_type","Shortcode"),("__quarto_custom_context","Inline"),("__quarto_custom_id","2")]) [],Space,Str "Fancy",Space,Str "Latex",Space,Str "missing"]]
[BulletList [[Plain [Str "From",Space,Span ("",[],[("__quarto_custom","true"),("__quarto_custom_type","Shortcode"),("__quarto_custom_context","Inline"),("__quarto_custom_id","3")]) [],Space,Str "to",Space,Span ("",[],[("__quarto_custom","true"),("__quarto_custom_type","Shortcode"),("__quarto_custom_context","Inline"),("__quarto_custom_id","4")]) []]]]]
If you need more, I can provide it..
Sorry... I know I should be able to work with that but could you provide the markdown equivalent, or else something that I can give to pandoc via -t native (pandoc doesn't like the above)?
I just want to see what it is that {{< latex >}} expands to (or at least the beginning bit). I understand what your fix is doing but I'm wondering whether there's a way of using an extra level of (probably) span that would avoid the need.
OK. I have fiddle a bit around, since I'm not familar with Pandoc.
Oh sorry, I assumed you'd have this info. Pandoc is happy with the first of your three paragraphs:
[BulletList [[Plain [Span ("",[],[
("__quarto_custom","true"),
("__quarto_custom_type","Shortcode"),
("__quarto_custom_context","Inline"),
("__quarto_custom_id","2")]) [],Space,Str "Fancy",Space,Str "Latex",Space,Str "missing"]]]]
It becomes this markdown:
- []{__quarto_custom="true" __quarto_custom_type="Shortcode"
__quarto_custom_context="Inline" __quarto_custom_id="2"} Fancy Latex
missing
What about putting a dummy empty span before your shortcode? Something like this:
:::{.list-table}
* - []{} {{< latex >}} Fancy Latex missing
* - From {{< latex >}} to {{< bibtex >}}
:::
This works OK with try pandoc but I'm not sure whether it's a good idea not to specify any span attributes (this might be a bit fragile).
Does it work for you? If so, is this an acceptable solution?
First of all, thanks for looking into this!
Well, coming from Quarto, I would consider this a workaround... but as I said, I have something working for the Quarto case.
However, my thought with this was, that Quarto people should step in here, since the grid table with shortcodes is broken and list-tables is considered the solution. So I'd assume that a more elegant solution would be prefered (this is my personal opinion).
Maybe, @cscheid can comment on this?
Hi! It is true that shortcodes are converted into an empty span. With that said, the list table filter is now bundled with Quarto are now built in to Quarto, and so we should figure out how to make shortcodes work well there. I consider this to be a Quarto bug instead of a list-table issue. @MBe-iUS can you file an issue at quarto-dev/quarto-cli? Thanks.
Great. I just wanted to note that I believe that list-table will pass any attributes (from the empty span) that it doesn't understand to the Cell constructor.
For example, this input:
% cat quarto.md
:::{.list-table}
* - []{--quarto-custom="true" --quarto-custom-type="Shortcode"
--quarto-custom-context="Inline" --quarto-custom-id="2"} Fancy Latex missing
* - From {{< latex >}} to {{< bibtex >}}
:::
gives this output:
% pandoc -L list-table.lua quarto.md
<table>
<thead>
<tr>
<th class="unnumbered" data-quarto-custom="true"
data-quarto-custom-type="Shortcode" data-quarto-custom-context="Inline"
data-quarto-custom-id="2"> Fancy Latex missing</th>
</tr>
</thead>
<tbody>
<tr>
<td>From {{< latex >}} to {{< bibtex >}}</td>
</tr>
</tbody>
</table>