markdown-clj
markdown-clj copied to clipboard
Wrapping transformed output in additional HTML tags
Transformers seem to be designed to process markdown, rather than modify the resulting HTML. I wanted to generate custom code for images, specifically
<figure>
<img src alt…>
<figcaption>
caption goes here
</figcaption>
</figure>
Having looked at the code, there is no easy way to add that, short of rewriting the (fairly complex) img handling functions. Or post-processing the output with enlive.
I was hoping to be able to write a "transformer" that would get the parsed information about an image and return an HTML string. Sort of like supplying a new markdown.transformers/img
function.
Any hints/ideas on how to address this use case?
The transformers work on a combination of the text and a state map and each line is considered independently. The transfomers are chained together and each one sees the text after the transformations of the previous transformers in the chain have been applied. So, you could add a transformer that can look for any text and replace it with other text.