Implement support for inline element attributes
I needed to add target="_blank" to my links, and I tried [text](url){:target="_blank"}. It doesn't work - it renders <a href="url">text</a>{:target="_blank"} so it doesn't recognize attributes in curly braces and treats them as just text
Please create and share full example showing the problem, e.g. starting with https://go.dev/play/p/5fCza6W-r_m
https://blog.kowalczyk.info/article/cxn3/advanced-markdown-processing-in-go.html#modify-ast-tree shows how you can do this by post-processing ast tree.
Also make sure you're using the right parser and html renderer flags:
- https://pkg.go.dev/github.com/gomarkdown/markdown/html#Flags
- https://pkg.go.dev/github.com/gomarkdown/markdown/parser#Extensions
I think I'm having a similar issue: it seems like the attributes are getting applied to a <p> tag which is wrapping the element, rather than being applied to the element itself. In this case, I'm trying to get the text to flow around the image like I would with <img ... align=left>:
The input markdown is:
{align="left" style="object-fit:scale-down"}
Having
My extensions are: parser.CommonExtensions&^parser.MathJax | parser.Attributes
yes this is bug, iirc the attributes apply to to the next element, not sure if there is a clean solution (or rework the attributes entirely)