Was or is there magic that ensures captions of mermaid diagrams are considered when using the markdown attribute syntax with mermaid-filter?
It appears we need at least some documentation or have to fix the regression.
Tests indicate that the
fenced_block_attributes
are not working withmermaid-filter
(no update available to that tool) as documented ibid.E.g. caption="foo" is not considered while filename=bar and loc=images (leading to a folder) are. width=1200 also seems to be ignored as many resulting images are much smaller eg. 315x457 or 485x343 pixels (width x height).
This issue requires further analysis if implementing a memoizing markdown filter (preprocessing for pandoc) providing post pandoc latex generation patch information is worth the effort (or some upgrade of mermaid, mermaid-filter, node, or pandoc is the correct solution.
The latter is the preferred way to keep the customizations minimal.
Is it feasible and appropriate to implement a filter working on the concat markdown document before handing over to pandoc and performing the following actions (before and after the markdown to latex conversion):
- before:
- replace all simple mermaid fenced blocks with attributed fenced code blocks that provide:
- caption
- label
- filename
- loc (folder)
- format
- width
- register all resulting (prior and patched such artifacts of the concat document) in some dictionary persisted to workspace
- after patch the latex per the data from that register in the workspace
Another option is to call pandoc additionally without filter and target json format for the AST and then parse the AST into a token map of captions. The keys are the mostly unique file paths. If not unique the captions should match. Then, given the map, during caption injections hook lookup these captions. The executor helper trampoline and all called filters require and additional map parameter to hand in the lookup table.
Implemented the fix as clumsy AST harvesting for captions in version v.2023.4.25.