public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Sergio Correia <sergio.correia-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: Markdown, tables and CSV
Date: Wed, 25 May 2016 22:42:50 -0700 (PDT)	[thread overview]
Message-ID: <b9147aed-bf8e-4136-8fd2-949dea1034ea@googlegroups.com> (raw)
In-Reply-To: <471daa3c-e2ec-4445-b4fd-44e5c8a3fd6b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 6462 bytes --]

A bit late to the party, but:

1) An alternative to using extensions to indicate the required action would 
be to use protocols.
For instance, this example pandoc filter:

http://scorreia.com/software/panflute/guide.html#calling-external-programs

Thus, you can do

[Caption of the Table](csv://some/path.csv)

Or maybe

[some/path.md](include://)



2) For tables, I would also suggest to take a look at this filter:

http://scorreia.com/software/panflute/guide.html#yaml-code-blocks

It allows markdown like this:

Some text

~~~ csv
title: Some Title
has-header: True
---
Col1, Col2, Col3
1, 2, 3
10, 20, 30
~~~

More text


This combines pure CSV with options set up in YAML, so you can add captions 
and customize the table.

Since the CSV is handled by python's CSV library, it is quite powerful. 
Also, complex things like selecting a subset of rows/cols, or adding 
format, could be done in 1-2 lines of code. If you are interested, shoot me 
an email and I can add a more complex working example.

Cheers,
S


On Wednesday, May 25, 2016 at 7:18:10 AM UTC-7, Frank Colcord wrote:
>
> I'd like to second this proposal. As a simple Pandoc user, these would be 
> very helpful:
>
>  
>     ![an image](foo.jpg)
>  
>     ![an include](foo.txt)
>  
>     ![a csv to be rendered as a table](foo.csv)
>  
> thanks for all the development.
>
> Frank
>
> On Friday, May 20, 2016 at 6:55:10 PM UTC+1, jgabriele wrote:
>>
>> Hi Martin,
>>  
>> There's also [issue 553](https://github.com/jgm/pandoc/issues/553 
>> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fjgm%2Fpandoc%2Fissues%2F553&sa=D&sntz=1&usg=AFQjCNHFocHh8P3j2zM42EMAMvPZ-kfuPA>
>> ).
>>  
>> Personally, I think I like (from that issue thread) anton-k's original 
>> idea:
>>  
>>     ![an image](foo.jpg)
>>  
>>     ![an include](foo.txt)
>>  
>>     ![a csv to be rendered as a table](foo.csv)
>>  
>> (that is, based on filename extension)
>>  
>> Those seem sensible, symmetrical, easy to remember, and I think fit well 
>> with what pandoc already does (`![]()` is already like an include).
>>  
>> As for a syntax to allow writing your csv data right into your md file, 
>> ... Pandoc already supports a generous number of table formats that are 
>> pretty easy to type. And for larger tables that you might be tempted to 
>> copy/paste in, might be better easier to bang-include them (as in, 
>> `![]()`), rather than muck up your pretty markdown file with a giant bunch 
>> of csv data. :)
>>  
>> -- John
>>  
>>  
>>  
>>  
>> On Fri, May 20, 2016, at 05:38 AM, Martin Fenner wrote:
>>
>> Dear group,
>>  
>> The topic of CSV support in Pandoc has come up several times on this 
>> list, includes this thread from 2014:
>> https://groups.google.com/forum/#!topic/pandoc-discuss/kBdJU_JktzI
>>  
>> Since last year I work for an organisation that frequently deals with 
>> tabular data (and helped organize CSVconf earlier this month), and I have 
>> done some thinking on how CSV could fit into Pandoc. I see two important 
>> use cases:
>>  
>> * CSV reader that converts to tables in HTML, docx, latex, etc.
>> * CSV has a format to describe tables in markdown
>>  
>> For the first use case I wrote a hack for the Jekyll blogging platform 
>> this week that turns CSV files into markdown grid tables format that is 
>> then processed by Pandoc (https://github.com/datacite/jekyll-csvy). I 
>> would rather use Pandoc with a CSV reader, but my Haskell isn't good enough 
>> to write one. But for now I can generate blog posts directly from CSV 
>> files. Other people have done similar things with Pandoc and CSV.
>>  
>> For the second use case I see a clear advantage of CSV over the various 
>> attempts to format tables in markdown (simple_tables, multiline_tables, 
>> grid_tables, pipe_tables). Everyone (and many tools) understands the CSV 
>> format, and you can do most of the things with CSV that the other table 
>> formats allow (multi-column formats and column alignment are a bit 
>> trickier). This has been done before using Pandoc filters, but I think a 
>> Pandoc "csv_tables" Pandoc extension would make this easier for the casual 
>> user. Using the grid_tables example from the Pandoc documentation, this 
>> could look like this:
>>  
>> : Sample csv table.
>>  
>> ,,,
>> Fruit,Price,Advantages
>> Bananas,$1.34,- built-in wrapper\n- bright color
>> Oranges,$2.10, - cures scurvy\n- tasty
>> ,,,
>>  
>> I like three commas on a new line to indicate the start and end of a 
>> table, but that is of course open for discussion. The format is much easier 
>> to read and edit for humans compared to grid tables, the only tricky bit is 
>> maybe the \n for multiline columns. I would think we could add metadata to 
>> the fenced table blog similar to code blocks, e.g.
>>  
>> ,,,{ #mytable .numberRows }
>>  
>> One challenge with CSV is that it is an ill-defined format somewhat 
>> similar to markdown before CommonMark. It may make things easier to only 
>> support a specific CSV variant (e.g. comma as separator, header required, 
>> comment lines not allowed).
>>  
>> Thoughts?
>>  
>> Best,
>>  
>> Martin
>>  
>>  
>>  
>>
>>
>> --
>> 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>> To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/20BF19CB-A2B0-4B19-A749-D750CDD89736%40martinfenner.org 
>> <https://groups.google.com/d/msgid/pandoc-discuss/20BF19CB-A2B0-4B19-A749-D750CDD89736%40martinfenner.org?utm_medium=email&utm_source=footer>
>> .
>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/b9147aed-bf8e-4136-8fd2-949dea1034ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 11720 bytes --]

  parent reply	other threads:[~2016-05-26  5:42 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <047d7b86ebe83c062b05332eab9b@google.com>
     [not found] ` <047d7b86ebe83c062b05332eab9b-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2016-05-20  9:38   ` Martin Fenner
     [not found]     ` <20BF19CB-A2B0-4B19-A749-D750CDD89736-+Z+QprJ1jbpwFuiNLMe2Ig@public.gmane.org>
2016-05-20 17:55       ` John Gabriele
     [not found]         ` <1463766905.1918988.613990665.6CD67781-2RFepEojUI2N1INw9kWLP6GC3tUn3ZHUQQ4Iyu8u01E@public.gmane.org>
2016-05-20 19:15           ` BP Jonsson
2016-05-25 14:18           ` Frank Colcord
     [not found]             ` <471daa3c-e2ec-4445-b4fd-44e5c8a3fd6b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-05-26  5:42               ` Sergio Correia [this message]
     [not found]                 ` <b9147aed-bf8e-4136-8fd2-949dea1034ea-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-05-26  8:04                   ` Martin Fenner
     [not found]                     ` <B4779237-F368-454A-8E43-93EBCDFDF8AB-i39mICoz+qVg9hUCZPvPmw@public.gmane.org>
2016-05-26 11:48                       ` Frank Colcord
     [not found]                         ` <CADZiF+X6AuYJEnnNCs1M=spfbp9Fn4X2GBVkxXKp9g9SSNH16A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-05-27  6:33                           ` John Gabriele
     [not found]                             ` <1464330807.2727387.620260561.2CC32090-2RFepEojUI2N1INw9kWLP6GC3tUn3ZHUQQ4Iyu8u01E@public.gmane.org>
2016-05-27 10:24                               ` Frank Colcord
     [not found]                                 ` <e1ffce2d-9cc0-4367-a652-a46fa5c141a6-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-05-27 14:02                                   ` John Gabriele
2016-05-27 15:48                               ` 'Jason White' via pandoc-discuss
2016-05-26 12:50                   ` BPJ
2016-05-20 18:36       ` John MACFARLANE
     [not found]         ` <20160520183616.GB95956-nFAEphtLEs/fysO+viCLMa55KtNWUUjk@public.gmane.org>
2016-05-20 19:05           ` John Muccigrosso
2016-05-20 19:30           ` John Gabriele
     [not found]             ` <1463772643.1938448.614055033.793EA897-2RFepEojUI2N1INw9kWLP6GC3tUn3ZHUQQ4Iyu8u01E@public.gmane.org>
2016-05-20 19:37               ` BP Jonsson
2016-05-20 19:32           ` BP Jonsson
2016-05-21 17:03       ` kurt.pfeifle via pandoc-discuss
     [not found]         ` <fbcb1ece-48c7-4451-be2f-1b6cd70b2969-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-05-29 12:45           ` mb21
     [not found]             ` <f0058def-bd69-40c1-82b4-e7bdd151c46c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-05-29 15:59               ` kurt.pfeifle via pandoc-discuss
     [not found]                 ` <001833c9-e40d-4079-ba79-c88c852780a5-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-05-30  7:47                   ` mb21
     [not found]                     ` <27f2fe62-8115-4513-b13a-c995f625f60d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-05-31 14:28                       ` kurt.pfeifle via pandoc-discuss
2016-05-23  4:42       ` Martin Fenner
     [not found]         ` <a1503704-4f58-47f7-a9e8-1c60dad8e935-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-05-23 20:22           ` John MACFARLANE
2016-05-27 19:50       ` D L
2016-11-14  7:40       ` Kolen Cheung
     [not found]         ` <14b8fa54-dc04-4874-bf47-fb268fc9f298-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-11-14 14:38           ` Melroch
     [not found]             ` <CADAJKhBcAxdQxytFdiug2iqxL+VxwECtWD-nMH4qPcfUUZUzUA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-11-14 23:32               ` Kolen Cheung
2016-11-15  1:33               ` Sergio Correia
     [not found]                 ` <12c01cfd-f9de-4dd9-bb80-fcac75c808be-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-11-15  6:03                   ` Kolen Cheung
     [not found]                     ` <38bfec67-90f0-4d71-b054-1eedfd853d96-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-11-15  9:07                       ` BP Jonsson
     [not found]                         ` <CAFC_yuQU3BRFaJW7QQof_bvU7muAUZGKg7DRc4gEp=4ZibAjHw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-11-15  9:29                           ` Kolen Cheung
     [not found]                             ` <d4c5aaa1-4bb7-4b6c-82bc-e0763555651d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-11-16  8:46                               ` Kolen Cheung
2016-11-18  9:22       ` mb21
     [not found]         ` <78b88082-90cb-4ec8-ab45-9e2be24d6dc4-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-11-18 10:39           ` Kolen Cheung
     [not found]             ` <d847d3af-73fd-41d1-96e8-2c3a0dc9d70a-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-11-23 10:52               ` Kolen Cheung
2016-12-04 12:59           ` Kolen Cheung
     [not found]             ` <40e755f4-b03d-453e-90d6-13d1ba596f60-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-08-01  9:10               ` Kolen Cheung
     [not found]                 ` <6ad9a315-1887-4e88-af53-99eaa87d39fa-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-08-01 13:43                   ` Sergio Correia
2016-11-29 22:13       ` Kolen Cheung
     [not found]         ` <a668593c-b4f2-4f57-909b-3f16dfb40990-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-11-29 22:30           ` Sergio Correia
     [not found]             ` <7e398825-a285-4e73-ad3d-908f1f141589-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-11-30  2:06               ` Kolen Cheung

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b9147aed-bf8e-4136-8fd2-949dea1034ea@googlegroups.com \
    --to=sergio.correia-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).