Hacker News new | past | comments | ask | show | jobs | submit login

One thing I love about pandoc that I don't see mentioned here is the ability to apply filters to transform documents mid-conversion.

I'm using Pandoc to write my PhD thesis at the moment, from Markdown source, using certain filters to "augment" what Markdown can do. Examples:

https://github.com/LaurentRDC/pandoc-plot

https://github.com/lierdakil/pandoc-crossref

More info here: https://pandoc.org/filters.html




Yeah, filters are great. Writing filters is easy: Pandoc basically converts the input document into a universal AST (json), and a filter is just any program that takes this json as an input and outputs a modified json AST.

I wrote a filter that automatically converts URL citstions in markdown to "real" citations in any style you want - very useful for writing papers without fighting with bibtex and managing bibliographies manually: https://github.com/phiresky/pandoc-url2cite


What a coincidence! I am also writing my PhD thesis with pandoc and filters, but I use panflute for the latter: http://scorreia.com/software/panflute/


I'm the author of panflute, and--in fact--wrote my PhD thesis in pandoc+panflute!


I'll be starting a PhD soon and would love to use a pandoc-based workflow (with MD or another format) for the gross of my writing.

How did you all structure the commenting on your writing? I find converting to odt/doc before sending, managing all the exported versions with comments etc. becomes quite tedious. But I'm a bit reluctant to force my supervisors to use eg. git+criticmarkup[1]. I would love to hear you experiences!

[1]: http://criticmarkup.com


A few things:

- In my case, my supervisors mostly had handwritten notes which rendered that point a bit moot. However, when I send the almost-complete draft to a professional copy editor, it was indeed a pain to add the comments. Either handwritten+scanned, as acrobat comments, or word comments, they had to be manually input into the markdown file.

- Everything else worked relatively better. It was a bit tedious to type loooong pandoc commands "pandoc --filter=... etc etc" so I recently coded pandocmk [1] to make my life easier. It's not super well documented (but it's a quite short script, so readable), but the idea is that you type the command line options as metadata at the top.

[1] https://github.com/sergiocorreia/pandocmk


I've used that to process tables, essentially using markdown as a commented CSV format. The only nuisance is that a table can't yet have attributes — https://github.com/jgm/pandoc/issues/6317 — the workaround being a pre-filter to copy them from a surrounding div.

I've also toyed with using it to process code blocks, as a dead-simple literate programming tool.


Pandoc tables can have attributes now! see https://github.com/jgm/pandoc-types/blob/master/src/Text/Pan...


This is going on a decade old, but I wrote my bachelor's thesis in pandoc. It made the otherwise painful very straightforward.


I wrote my MSc in markdown with Pandoc. Loved it.


my uni requires MS Word...


That is the point of pandoc.

You can write in markdown and then convert it to word for your uni.


What do you do when your advisor sends you back changes using the Word track feature? Can Pandoc apply the diff?


yes, see the `--track-changes` option: https://pandoc.org/MANUAL.html#option--track-changes


For MS Word Pandoc is a blessing: I configured a master file and now pandoc does all the tedious formatting!


It must be pretty slow if you have time to change the settings while it is converting?


Not sure if this is a joke but if you read the linked docs [0] you'll see that the concept of filters is that you the user can write programs (essentially plugin-style) that modify the AST Pandoc generates in order to perform the conversion. But this explanation is ultimately worse than the actual doc page, so I'd recommend just reading that.

https://pandoc.org/filters.html


None of this has anything to do with how much time is taken. The whole thing could run in a millisecond.


> One thing I love about pandoc that I don't see mentioned here is the ability to apply filters to transform documents mid-conversion.

I read that as "mid-conversion" meaning that he can apply filters while the document is being converted


Pandoc applies the filters, not the user.


like using Middleware




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: