Adding Pandoc Arguments in BBEdit

TIL: How to add command-line arguments to pandoc when exporting Markdown to HTML from BBEdit.


This content originally appeared on Thoughts From Eric and was authored by Eric Meyer

Thanks to the long and winding history of my blog, I write posts in Markdown in BBEdit, export them to HTML, and paste the resulting HTML into WordPress. I do it that way because switching WordPress over to auto-parsing Markdown in posts causes problems with rendering the markup of some posts I wrote 15-20 years ago, and finding and fixing every instance is a lengthy project for which I do not have the time right now.

(And I don’t use the block editor because whenever I use it to edit an old post, the markup in those posts get mangled so much that it makes me want to hurl. This is as much the fault of my weird idiosyncratic bespoke-ancient setup as of WordPress itself, but it’s still super annoying and so I avoid it entirely.)

Anyway, the point here is that I write Markdown in BBEdit, and export it from there. This works okay, but there have always been things missing, like a way to easily add attributes to elements like my code blocks. BBEdit’s default Markdown exporter, CommonMark, sort of supports that, except it doesn’t appear to give me control over the class names: telling it I want a class value of css on a preformatted block means I get a class value of language-css instead. Also it drops that class value on the code element it inserts into the pre element, instead of attaching it directly to the pre element. Not good, unless I start using Prism, which I may one day but am not yet.

Pandoc, another exporter you can use in BBEdit, offers much more robust and yet simple element attribute attachment: you put {.class #id} or whatever at the beginning of any element, and you get those things attached directly to the element. But by default, it also wraps elements around, and adds attributes to, the pre element, apparently in anticipation of some other kind of syntax highlighting.

I spent an hour reading the Pandoc man page (just kidding, I was actually skimming, that’s the only way I could possibly get through all that in an hour) and found the --no-highlight option. Perfect! So I dropped into Preferences > Languages > Language-specific settings:Markdown > Markdown, set the “Markdown processor” dropdown to “Custom”, and filled in the following:

Command pandoc
Arguments --no-highlight

Done and done. I get a more powerful flavor of Markdown in an editor I know and love. It’s not perfect — I still have to manually tweak table markup by hand, for example — but it’s covering probably 95% of my use cases for writing blog posts.

Now all I need to do is find a Pandoc Markdown option or extensions or whatever that keeps it from collapsing the whitespace between elements in its HTML output, and I’ll be well and truly satisfied.


Have something to say to all that? You can add a comment to the post, or email Eric directly.


This content originally appeared on Thoughts From Eric and was authored by Eric Meyer


Print Share Comment Cite Upload Translate Updates
APA

Eric Meyer | Sciencx (2021-05-13T19:08:34+00:00) Adding Pandoc Arguments in BBEdit. Retrieved from https://www.scien.cx/2021/05/13/adding-pandoc-arguments-in-bbedit/

MLA
" » Adding Pandoc Arguments in BBEdit." Eric Meyer | Sciencx - Thursday May 13, 2021, https://www.scien.cx/2021/05/13/adding-pandoc-arguments-in-bbedit/
HARVARD
Eric Meyer | Sciencx Thursday May 13, 2021 » Adding Pandoc Arguments in BBEdit., viewed ,<https://www.scien.cx/2021/05/13/adding-pandoc-arguments-in-bbedit/>
VANCOUVER
Eric Meyer | Sciencx - » Adding Pandoc Arguments in BBEdit. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/13/adding-pandoc-arguments-in-bbedit/
CHICAGO
" » Adding Pandoc Arguments in BBEdit." Eric Meyer | Sciencx - Accessed . https://www.scien.cx/2021/05/13/adding-pandoc-arguments-in-bbedit/
IEEE
" » Adding Pandoc Arguments in BBEdit." Eric Meyer | Sciencx [Online]. Available: https://www.scien.cx/2021/05/13/adding-pandoc-arguments-in-bbedit/. [Accessed: ]
rf:citation
» Adding Pandoc Arguments in BBEdit | Eric Meyer | Sciencx | https://www.scien.cx/2021/05/13/adding-pandoc-arguments-in-bbedit/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.