Idempotent in this case means pantable and pantable2csv are “inverse” to each other. e.g. pandoc -t markdown -F pantable -F pantable2csv test.md should be identical to test.md. This can be done because pantable2csv losslessly represents all info in the pandoc’s AST into YAML+CSV in code-block. The only cases it ain’t lossless are

  1. when pandoc parses the markdown in each cell to AST, and pantable2csv passes those AST back into markdown by using pandoc. i.e. whether this is idempotent or not depends on pandoc’s markdown -> AST -> markdown conversion.

  2. Potentially the width might have some truncation error, especially when the to-format and from-format are not the same.

When I say I achieve P^3=P^2, it means that pandoc -t native -F pantable -F pantable2csv -F pantable -F pantable2csv -F pantable -F pantable2csv csv_table.md = pandoc -t native -F pantable -F pantable2csv -F pantable -F pantable2csv csv_table.md (which is part of the unit test). The diff between P^2 and P is exactly from (1).

A corollary to (1) is that it is kind of slow, since each table cells call pandoc for the conversion once. Probably nothing can be improved except to reinvent the parsing of tables (probably there’s no way to tell pandoc to ignore markdown in cell, while not escaping character sequences). (And tables has m \times n cells so inherently it will be slow.) But I don’t quite worry about the performance aspect if it is going to solve a workflow problem.

Eventually I think I’m going to make a thin wrapper of both to provide a cli version. And then automator scripts can be created. Then basically I can select the table in text editors and call system services to convert it in place. i.e. highlight table, convert to csv, edit, highlight and convert to table. This system-service-part won’t be cross-platform though. (By the way, a sad news is Apple just fired the one responsible for Automator and Applescripts, and kill the whole team! This used be the forte of OS X!)

In a sense, pantable2csv gives one the power to edit the table “in AST directly” easily, while pantable provide a way to pretty-print it back in native markdown. Note that after commit 298e6f3, all pandoc table’s info has a markdown representation (grid_tables only misses alignment which is added in that commit).

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/e6213b58-11e9-4948-80c2-650347e26c2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.