Add plugin for simple inline text styling
It would be useful to support lightweight text styling directly in Markdown without falling back to HTML.
Proposed syntax:
[text]{color=#ff00ff | font=Poppins}
Examples:
Hello [world]{color=#ff00ff}
[Important]{color=red | weight=bold}
[Code]{font=monospace | bg=#f5f5f5}
Why this helps:
- Keeps Markdown clean and readable
- Avoids inline HTML
- Easy to extend with more properties later
- Simple to parse and implement
Supported properties (initial):
color,bgfont,sizeweight,style
This could be implemented as an optional plugin that converts the syntax into a <span style="..."> under the hood.
Happy to help with implementation if this direction makes sense.
This syntax is already supported in Comark and you can create span using [content]{attributes} syntax. Checkout https://comark.dev/syntax/attributes#span-attributes
There is not alias for styling to fonts, you can simply pass class, id, styles or any html attribute to span elements.
[Code]{style="background: #f5f5f5"}
Oh interesting, I somehow missed that. Thanks @farnabaz !
How does this work in terms of security and limiting. For instance, if I allow user generated content, then I want to limit which attributes they can use. Additionally, would also like to limit use of url(), etc to avoid injections.
I just had a deeper look at attributes.
They are quite cool, but it gives more power than it should. I am proposing for a styling only specific syntax/plugin.
The current syntax for styling something would be essentially inline css, which is both annoying and may be unwanted by administrators/devs which only want to give users very limited and specific power.
Hey @xMrAfonso
I can see it as a community plugin at first, if you want to create one and publish it as comark-plugin-text-styling for example, I would be happy to add a Community Plugins section to list it 😊
How does this work in terms of security and limiting. For instance, if I allow user generated content, then I want to limit which attributes they can use. Additionally, would also like to limit use of url(), etc to avoid injections.
This is a very good comment and I believe we could also improve the Security Plugin in this area
Hey @atinux
Yeah, would gladly do one when I have some free time.
I was actually also looking into adding a plugin that adds support for minimessage-js. Looks like a cool syntax, specially the way it handles colors.
Regarding the improvement, I would really love if there were more configurations into core features like being able to disable attributes fully without having to configure the security plugin...
Hey @atinux,
Played around a bit with the initial proposal and noticed it was trying to cover too much. So, I choose to just go with just text coloring in specific.
I created this quick demo to show how it would work (thanks codex)
Would there be interest in making this an official plugin or should I continue the community plugin route?
Could I get a potential update on this?
Sorry about not answering before @xMrAfonso, I found the demo nice! I think a community plugin to start would be great! Would you need help somehow for a comark plugin starter repo maybe?
@atinux I mean, if there is a standard structure/template you'd prefer for me to use, sure. Otherwise I can look into it.
We don't at the moment but I think you can use something like https://tsdown.dev/guide/getting-started#starter-templates
@xMrAfonso we just created a plugin template, you can use this template to create and publish your plugin.
Checkout: https://github.com/comarkdown/comark-plugin-template
@xMrAfonso we just created a plugin template, you can use this template to create and publish your plugin.
Checkout: https://github.com/comarkdown/comark-plugin-template
Hey, did you by any chance read the rest of the conversation? You suggested that already and I already explained it is not what I am speaking about nor use case.
@xMrAfonso What is your goal and use case? I don't see this feature as part of Comark core and it can be a community plugin and documented in docs.
@farnabaz yes, that has been mentioned already and is the current plan.
In terms of goal, the demo I have sent shows a pretty good example, which is firstly usability/user experience for coloring texts. And secondly meant to be used in user generated contexts
@farnabaz yes, that has been mentioned already and is the current plan.
In terms of goal, the demo I have sent shows a pretty good example, which is firstly usability/user experience for coloring texts. And secondly meant to be used in user generated contexts
Indeed I saw your demo. I agree with rest of conversation and just sent you a plugin starter, it is your decision to use or not.
Closing this in favor or our https://comark.dev/ecosystem page for all community plugins :)