Closed not-my-profile closed 2 years ago
Thanks for this! Is there any way to mark added fields?
I tried something like this but couldn't figure out how to fix it.
for i = 1, #list.content do
assert(#list.content[i] == 1, "expected item to contain only one block")
assert(list.content[i][1].t == "BulletList",
"expected bullet list, found " .. list.content[i][1].t)
table.insert(rows, list.content[i][1].content)
local rows1 = list.content[i][1]
for j = 1, #rows1 do
local row = rows1[j].content
while #row < col_count do
row_copy = {content={}}
row_copy[1].content[1].text = 'ADDED_FIELD'
row[#row + 1] = row_copy
end
end
end
You're welcome :) I am afraid I don't understand what you're trying to achieve. What are "added fields"? Why do you want to mark them?
Sorry, I should've explained more!
$> pandoc --lua-filter list-table.lua
::: list-table
* - a
- b
* - c
:::
<table>
<caption></caption>
<thead>
<tr class="header">
<th>a</th>
<th>b</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>c</td>
<td></td> <!-- <<< added-->
</tr>
</tbody>
</table>
The optimal solution would be to add colspan=2, but I don't think this filter supports that, and it would require some work I believe. So as a workaround, if any added fields could be marked somehow, so I could later remove using .replace('<td>MAGIC_STRING</td>', '')
.
Thank you!
Inspired by reStructuredText and the feature request https://github.com/jgm/pandoc/issues/7305.