Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for inline element attributes #278

Open
aleybovich opened this issue Mar 14, 2023 · 3 comments
Open

Implement support for inline element attributes #278

aleybovich opened this issue Mar 14, 2023 · 3 comments

Comments

@aleybovich
Copy link

aleybovich commented Mar 14, 2023

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

@kjk
Copy link
Contributor

kjk commented Mar 14, 2023

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:

@weberc2
Copy link

weberc2 commented Apr 28, 2024

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>:

image

The input markdown is:

{align="left" style="object-fit:scale-down"}
![Fallout cover art](/assets/posts/fallout-macos-install/fallout.jpg)Having

My extensions are: parser.CommonExtensions&^parser.MathJax | parser.Attributes

@miekg
Copy link
Collaborator

miekg commented Jan 7, 2025

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants