jgm / pandocfilters

A python module for writing pandoc filters, with a collection of examples
BSD 3-Clause "New" or "Revised" License
508 stars 115 forks source link

Format captions with PlantUML #81

Open fuhrmanator opened 4 years ago

fuhrmanator commented 4 years ago

Using the examples/plantuml.py I would like to use markdown formatting in the caption, e.g.,

```{.plantuml caption="This is *not* the UML your grandmother told you about." #label }

But the *not* is not processed as markdown (to get italics). Is there a way to do this with the filter API?

fuhrmanator commented 4 years ago

I worked around this (it's actually not just a problem with PlantUML) by modifying the filters to generate a file, which is then used in the markdown right after with ![here's my markdown caption](file_generated_by_filter.ext){#label}

I also posted a question on stackoverflow.

fuhrmanator commented 3 years ago

I created a solution to this by

  1. running pandoc (again) on the caption text to convert it from markdown to the current format.
  2. returning the caption as a RawInline element.

However, I'm not happy with the first step, as it seems broken to invoke pandoc externally when we're already in a filter.

@jgm would you know of a way to perform the markdown-to-X conversion without using another pandoc external command? Does the pandocfilters API need to be extended to do this?