Along the same lines as previous tinkering, I was thinking about how the YAML block at the beginning of each note really helps set it apart so that it’s obvious each note is coming from a different file. It seemed logical that Pandoc could preserve that if I found the right switches, and it turns out it can.
The switch is just to enable yaml_metadata_block in the output type.
For example, all notes mentioning Pandoc:
rg -l 'pandoc' notes | \ parallel pandoc --template=resources/template.markdown \ --shift-heading-level-by=1 -t markdown+yaml_metadata_block \ --reference-links --reference-location=document {} \; echo \ | bat -t md
The only problem is that I can’t see the file name of the note something came from, so I can’t edit one of the files I see by name. Not too big of a deal, as I can use nvim $(rg -l 'some phrase' notes) and open the file based on content.
I can almost use this same logic on the entire set of my notes to fix formatting, links, and table styles so that everything is well in Obsidian, too.
Here’s a little preview:
rg -l 'pandoc' notes | parallel pandoc --template=resources/template.markdown \ --shift-heading-level-by=1 \ -t markdown+yaml_metadata_block+pipe_tables-simple_tables \ --reference-links --reference-location=document {} \; echo | bat -t md
And here’s what that looks like:
asciinema captureasciinema capture
This would replace all the tables with the only format Obsidian supports (not that I’m bitter) make all the links into reference links for better Gemini formatting, and preserve the YAML meta data that I use internally.
The only issue is that the template I reference above is the one that formats my Gemini posts. The issue here is that it puts the note title at the top of the note in heading 1, hence the --shift-heading-level-by=1 to demote all the remaining headers down a level.
I’ll need to make a new template and not do the heading shifts. I’ll try this out a bit over the next few days and if it produces decent output I’ll convert and review everything. Then I’ll probably make a macro for calling Pandoc from within my editor so I can maintain consistent formatting going forward.
updated: 2023-11-05 17:25:29
generated: 2024-08-16