zyedidia / Literate

A literate programming tool for any language
https://zyedidia.github.io/literate/
Other
663 stars 45 forks source link

Table support #9

Closed BlackEdder closed 8 years ago

BlackEdder commented 8 years ago

Might be nice if it also added table support: pandoc.org/README.html#tables

zyedidia commented 8 years ago

Hmm, this is going to be tough to add because markdown does not originally support tables -- it's an "extra" feature provided by Pandoc and some other markdown compilers.

Currently I'm using dmarkdown to do the markdown compilation, but I could use a different compiler. Unfortunately, Pandoc is written in Haskell, and I'm limited to compilers written in D (dmarkdown is the only one) or C (of which there are a bunch, but none seem to provide table support). There is libpandoc which I could use to call Pandoc from D, but it would still require having Haskell and Cabal installed to build it -- something I'm not sure I want to have as a dependency.

If you find any C markdown library which supports these "extra" markdown features, let me know.

BlackEdder commented 8 years ago

Are you opposed to adding support to dmarkdown for it? I might be tempted to submit a PR is I miss tables enough :)

zyedidia commented 8 years ago

Adding support to dmarkdown would be fine, it's just I'm not the one who wrote dmarkdown and I don't know how it works very well. I'll look into it a bit though. You can submit a PR if you'd like -- just make sure to submit the PR to my fork and not to the original.

You can always make tables directly in HTML, but I understand that the markdown tables are much nicer.

BlackEdder commented 8 years ago

Sorry, since the link went to your github I thought dmarkdown was your project, but I now see it is someone else's.

There is also a markdown parser in: https://github.com/rejectedsoftware/vibe.d/blob/dddb1f607c0b77ea99119003c77ef318b7ebf959/source/vibe/textfilter/markdown.d but I don't think that supports tables either.

The other option would of course be to allow outputting to markdown and then the user could use pandoc to generate html from the markdown file. I guess supporting this shouldn't be much work (since you already use markdown as intermediate format).

zyedidia commented 8 years ago

The issue with that is that the markdown would be full of html and it would have to be in the body. Also I'm not sure if markdown allows for <style> and <script> tags, but maybe it does. If so that could work.

I think a better option would to be able to provide a markdown compiler from the command line, so for example:

lit --md-compiler pandoc file.lit

Then literate would use the pandoc command line tool instead of the built in markdown compiler (dmarkdown).

zyedidia commented 8 years ago

I've created the branch md-compiler which now supports the --md-compiler flag. Everything seems to be working now, I just need to document it and then I think I'll merge the branch.

Unfortunately it seems like pandoc messes up the katex math stuff because it tries to format inside of an html tag. I don't think this is something I can solve because it seems like it's pandoc's problem. Maybe there is some flag to fix it.