OliverBalfour / obsidian-pandoc

Pandoc document export plugin for Obsidian (https://obsidian.md)
MIT License
718 stars 60 forks source link

Running Export as .. (HTML) in batches / via CLI? #84

Closed sondregronas closed 2 years ago

sondregronas commented 3 years ago

Greetings, and thanks for making this fantastic plugin!

I'm hosting a docs website for a classroom, where the webpages are written in Obsidian with wikilinks. The idea is to open up for student collaboration and update the page using git. My current workflow is clicking through every file in my Obsidian vault manually and hitting the shortcut for Pandoc: Export as HTML. This gets a bit tedious, but I can't seem to get pandoc to interpret the files as well as this plugin does. Maybe I'm missing out on something obvious, but it feels like I've tried every formatting option they offer.

I'm specifically having issues with the <code> tags and the [[WikiLinks]], they parse just the way I want them to when running the Export as HTML command in Obsidian.

Is there a way to get pandoc to essentially parse the files the way this plugin does? (Alternatively doing a batch export on a folder within Obsidian itself).

The ideal workflow would be something like:

#!/bin/sh
git pull
for f in *.md ; do pandoc -s -f obsidian-pandoc -t html $f -o ${f%%.*}.html ; done
# more stuff - i.e. remove the absolute path from links:
for f in *.html ; do sed -i -n -e '/\<pre/,/\/pre\>/! s/ href="[^"]*\\/ href="/g;p' $f ; done

Apologies if this question is more related to Pandoc rather than the plugin itself - to be fair it would probably be better if Obsidian itself had a CLI to run plugin commands from - shame it doesn't do so yet to my knowledge.

Thanks in advance!