Micron Document
more toying with rg and pandoc

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 T383838yaml_metadata_block in the output type.

For example, all notes mentioning Pandoc:

T282828
rg -l Ta5d6ff'pandoc' notes Tb4b4b4| Tffea00\
parallel pandoc --templateTff7b72=resources/template.markdown Tffea00\
--shift-heading-level-byTff7b72=T79c0ff1 -t markdown+yaml_metadata_block Tffea00\
--reference-links --reference-locationTff7b72=document Tff7b72{Tff7b72} Tffea00\; Tffa657echo Tffea00\
Tb4b4b4| 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 T383838nvim $(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:

T282828
rg -l Ta5d6ff'pandoc' notes Tb4b4b4| parallel pandoc --templateTff7b72=resources/template.markdown Tffea00\
--shift-heading-level-byTff7b72=T79c0ff1 Tffea00\
-t markdown+yaml_metadata_block+pipe_tables-simple_tables Tffea00\
--reference-links --reference-locationTff7b72=document Tff7b72{Tff7b72} Tffea00\; Tffa657echo Tb4b4b4| bat -t md


And here's what that looks like:


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 T383838--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.

Tags: rg, pandoc

Tags
Navigation



created: 2023-11-01

updated: 2023-11-05 17:25:29

(re)generated: 2026-07-17