bpj / pandoc-list-table Goto Github PK
View Code? Open in Web Editor NEWPandoc filter which converts lists-of-lists <--> tables
License: Other
Pandoc filter which converts lists-of-lists <--> tables
License: Other
Moved this comment here from pandoc issues:
Note that it currently only works with pandoc < 2.10 (if anybody understands the pandoc 2.10 table model a pull request is most welcome! :-)
Check the latest pandoc nightly for SimpleTable support by tarleb, or next pandoc 2.11.
In your table2lol
function, at line 233, use something like:
--local tab = div.content[1]
local tab = pandoc.utils.to_simple_table(div.content[1])
And in your lol2table
function, at line 185, use something like:
--local ok, res = pcall(pandoc.Table, caption, aligns, widths, headers, rows)
local ok, res = pcall(pandoc.SimpleTable, caption, aligns, widths, headers, rows)
assert(ok, "Error converting list to table in " .. tostring(div_id) .. ": " .. tostring(res)) -- no change here
res = pandoc.utils.from_simple_table(res) -- ugly, but you get the point
-- or without the pcall:
-- local res = pandoc.utils.from_simple_table( pandoc.SimpleTable(caption, aligns, widths, headers, rows) )
Very useful filter, thank you. Alleviates the pain of markdown's finicky table syntax.
Is there a way to have table2lol output something like
* - foo
- bar
- baz
$> pandoc --lua-filter pandoc-list-table.lua
::: lol2table
* - 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>
Is there a way to tell pandoc-list-table to not add a cell next to c?
Thank you!
Updated: I looked at the codebase and found the code below. Maybe I could try just removing it?
-- Make sure all rows are the same length by adding empty
-- cells until they are the same length as the longest row
for row in *rows
while #row < col_count
row[#row+1] = {}
Pandoc has changed the Lua type of its objects from table to userdata, which necessitates some changes in this filter. I'll probably push a fix in the first week of 2022.
::: {.lol2table #some-id .some-class lang=en}
A table of stuff.
- - foo
- bar
- baz
- - - tic
- pic
- - tac
- pac
- - toc
- poc
:::
currently produces <table>...</table>
. I would expect it to produce:
<table id="some-id" class="some-class" lang="en">...</table>
(sometimes you want/need to add attributes directly to the table as opposed to a wrapping div)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.