One possible problem with including metadata as YAML is that it may become harder for filters earlier in the chain to query the metadata or inject a CSV block using the normal attribute interface, if any, of the filter engine, not to mention parsing the CSV, query or alter it and write it back. For that reason I think it be better if the content of the code block is the pure CSV data. FWIW I tried both strategies with my unpublished filters, so I'm not just speculating.

Also since there are many filters doing the same thing the identifying class should better not be just `csv` but also identify the filter expected to handle the data.


Den 14 nov 2016 08:41 skrev "Kolen Cheung" <christian.kolen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:

Yet Another Pandoc Filters on CSV Tables

For those who are interested in using CSV tables in pandoc markdown, I’m writing a filter that build upon one of panflute’s example. And I’m still thinking about which exact syntax to use. Feel free to give suggestions.

Features

What separate this to existing filters is the automatic calculation of the column-width (in contrast with pandoc-placetable) and write to pandoc AST directly (in contrast with pandoc-csv2table), as well as specifying the table width (a ratio to the line-width). And comparing with the 2 said filters, panflute’s example use YAML to store data, rather than the attributes of the code-block (which I think is more natural for data).

There’s a notebook in ickc/pandoc-table-csv-test/panflute-csv2table.ipynb and the the filter is at ickc/pandoc-table-csv-test/csv-tables.py.

The current syntax is this (borrow much from panflute’s example, and the csv is borrowed from pandoc-csv2table):

~~~csv
title: "*Great* Title"
has-header: False
column-width:
  - 0.1
  - 0.2
  - 0.3
  - 0.4
table-width: 0.8
alignment: LRC
markdown: True
---
1,2,3,4
~~~

A Comparison of Metadata Keys Between Pandoc Filters on CSV Tables

My biggest questions is which metadata keys to use. Backward-compatibility-wise, since pandoc-csv2table and pandoc-placetable use attributes to store metadata, while panflute’s example and mine use YAML to store, the only one I need to consider backward-compatibility is panflute’s. But I actually think pandoc-csv2table/placetable’s keys make more sense. e.g. header vs has-header, caption vs title.

And for alignment, pandoc-csv2table/placetable use aligns. For width, placetable use widths. I’m not sure if I should follow them.

A comparison of the keys: (The output is generated by my filter)

+--------+----------------------------+-------------------+--------------------+--------------------------+
|        | pandoc-csv2table           | pandoc-placetable | panflute example   | my proposal              |
+========+============================+===================+====================+==========================+
| type   | type=simple|multiline|grid |                   |                    |                          |
|        | |pipe                      |                   |                    |                          |
+--------+----------------------------+-------------------+--------------------+--------------------------+
| header | header=yes|no              | header=yes|no     | has-header:        | header: True|False       |
|        |                            |                   | True|False         |                          |
+--------+----------------------------+-------------------+--------------------+--------------------------+
| captio | caption                    | caption           | title              | caption                  |
| n      |                            |                   |                    |                          |
+--------+----------------------------+-------------------+--------------------+--------------------------+
| source | source                     | file              | source             | source                   |
+--------+----------------------------+-------------------+--------------------+--------------------------+
| aligns | aligns=LRCD                | aligns=LRCD       |                    | alignment: LRCD          |
+--------+----------------------------+-------------------+--------------------+--------------------------+
| width  |                            | widths="0.5 0.2   |                    | column-width: \[0.5,     |
|        |                            | 0.3"              |                    | 0.2, 0.3\]               |
+--------+----------------------------+-------------------+--------------------+--------------------------+
|        |                            | inlinemarkdown    |                    | markdown: True|False     |
+--------+----------------------------+-------------------+--------------------+--------------------------+
|        |                            | delimiter         |                    |                          |
+--------+----------------------------+-------------------+--------------------+--------------------------+
|        |                            | quotechar         |                    |                          |
+--------+----------------------------+-------------------+--------------------+--------------------------+
|        |                            | id (wrapped by    |                    |                          |
|        |                            | div)              |                    |                          |
+--------+----------------------------+-------------------+--------------------+--------------------------+

--
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@googlegroups.com.
To post to this group, send email to pandoc-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/14b8fa54-dc04-4874-bf47-fb268fc9f298%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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/CADAJKhBcAxdQxytFdiug2iqxL%2BVxwECtWD-nMH4qPcfUUZUzUA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.