~sthagen/liitos#27: 
Bug: Mermaid captions not considered?

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.

Status
RESOLVED FIXED
Submitter
~sthagen
Assigned to
Submitted
1 year, 9 months ago
Updated
1 year, 7 months ago
Labels
Bug

~sthagen 1 year, 9 months ago

Tests indicate that the fenced_block_attributes are not working with mermaid-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.

~sthagen 1 year, 9 months ago*

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:
    1. replace all simple mermaid fenced blocks with attributed fenced code blocks that provide:
      • caption
      • label
      • filename
      • loc (folder)
      • format
      • width
    2. 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

~sthagen 1 year, 7 months ago

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.

~sthagen REPORTED FIXED 1 year, 7 months ago

Implemented the fix as clumsy AST harvesting for captions in version v.2023.4.25.

Register here or Log in to comment, or comment via email.