Open kysko opened 4 years ago
Thanks @kysko I didn't know that the SimpleTable stuff by @tarleb already had made it into master. Hopefully 2.11 will be released soon.
P.S. Note that any modifications should be made in the MoonScript code since the Lua code is autogenerated from the MoonScript code. It's OK for this comment though; I can certainly locate/translate.
BTW the reason I use pcall
is so that non-technical users will get a more sensible error message.
Just to add an idea: If you ever want to introduce row spans and col spans with the new Table scheme, one way could be through a special Div as a list item. For example, this:
::: {.lol2table}
* - foo
- bar
- baz
* - ::: {.tbcell rs=2 cs=2}
a big
chunk
:::
- one
* - two
:::
could be equivalent to this (if I use the docutils grid table notation):
+-------+-------+-----+
| foo | bar | baz |
+=======+=======+=====+
| a big | one |
| +-----+
| chunk | two |
+---------------+-----+
with a Div with the keyvals rs
and cs
for row span and col span resp, and class tbcell
to identify its purpose as a cell.
(The Div attributes can also serve for individual cells alignments, etc, even if no rs
or cs
is given.)
Of course one would have to be very careful to create a valid table, might not be self-evident with complex mix of row spans and col spans. Essentially, one would mimic what would be in the AST for the table, row by row, or as if one would construct an HTML table. (The above could require that empty cells be represented by empty list items.)
There's no pandoc-markdown reader or writer for complex tables right now, so one would need to wait for 'round-tripping'.
Anyways, that's just an idea for you if you ever want to tackle complex tables.
@kysko wrote:
If you ever want to introduce row spans and col spans with the new Table scheme, one way could be through a special Div as a list item.
Thanks. I have already thought along those lines myself. One problem with it is that I already make somewhat heavy use of divs around list item content in order to style table cell content, both for HTML/CSS styling and for injecting LaTeX code with filters. One would have to use nested divs and be careful to put any content styling div inside the cell styling div.
Actually complex tables was the only thing which I preferred to do in a WYSIWYG editor back in the days when I wrote much HTML by hand. It was hard to keep the cell/row spans straight in my head without the visual feedback. I guess using ordered lists would alleviate this a lot, since you could then just "skip" the list numbers for "merged" cells in the rows and keep track of the row numbers in the source, things which I used to do with the help of HTML comments or ids of the form my-table-2-4--3-5
, meaning a cell which spanned columns 2 to 4 and rows 3 to 5. It was very easy to get confused anyway!
I already make somewhat heavy use of divs around list item content in order to style table cell content, both for HTML/CSS styling and for injecting LaTeX code with filters.
Well then, if you already make use of cell-englobing divs, perhaps this might an advantage rather than a problem: the use of the keyvals rs
and cs
(or better, rowspan
and colspan
for that matter) would not be heavier than what one would use on td
tags in HTML.
Of course, the more details you want to support of the new scheme (at cell level), the heavier the div attributes would be... but that is also true of td
tag attributes and styling (quite similar in fact).
(It does get very heavy at other levels when introducing global header and footer, stubs, multibody...)
So you could proceed as usual, but being careful at reserving certain class names (.alignright
, .alignleft
, etc) and keyval keys for specific use (rowspan
, colspan
, etc), and mimic HTML td
tag construction. There would be no need for nested divs, just add the classes/keyvals to your already existing cell-englobing div.
But your specific real-world uses are surely more complex than the test cases, so I might not see the forest nor the trees!
@kysko you may want to check out the SimpleTable branch before I merge it with master tomorrow. [1]
It is updated to use and convert from/to SimpleTable if it exist and to throw an error if it doesn't exist and PANDOC_VERSION >= 2.10.0.
40a222bfa882a3303b18a1ff140140031bd26e6e has the main changes although some fixes were added later
[1]: Since I had omitted to state a version number I decided to use YYYYMMDD[HH] as version number, and I want the version with these updates to be version 20201001! :smiley:
After a quick look at the lua file (simpletable branch) and a quick test, it seems to look fine.
Just for fun, to kill some time, I rewrote the Lua version of lol2table
to support rowspan
, colspan
, a footer, along my last example notation above. It exports to HTML and Native in simple cases, didn't do extensive tests.
Since my use of pandoc-list-table
has only been limited to a few tests, in pure dilettantism 😄 , and not for extensive real-world use like you, it might not cover all the bases...
It's not a pull request, just a personal unpublished mod for fun, so not in MoonScript.
If you're interested, just for inspiration, I can make a temporary gist for you. You'll eventually make your choices on how to handle rowspans and colspans, but this might give you some ideas.
Nothing done for table2lol
, complex table format too rich for now for a lol
format that doesn't support yet such details, and one would need to devise a fallback to current notation.
@kysko Sure, I will be happy to have a look. There is no hurry as I'll probably not have time to look at it before the weekend.
Crazy days...
Anywhoo, I finally created the gist for the mod I was telling you about, after this and that and this and that addition/removal/changes... there's always something!
Take what you want from it. The main point is how to manipulate the information with the new richer Table format.
Moved this comment here from pandoc issues:
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:And in your
lol2table
function, at line 185, use something like: