comark icon indicating copy to clipboard operation
comark copied to clipboard

Add plugin for simple inline text styling

Open xMrAfonso opened this issue 7 months ago • 16 comments

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, bg
  • font, size
  • weight, 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.

xMrAfonso avatar Apr 20 '26 19:04 xMrAfonso

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"}

farnabaz avatar Apr 21 '26 10:04 farnabaz

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.

xMrAfonso avatar Apr 21 '26 10:04 xMrAfonso

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.

xMrAfonso avatar Apr 21 '26 22:04 xMrAfonso

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

atinux avatar Apr 22 '26 14:04 atinux

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

xMrAfonso avatar Apr 22 '26 23:04 xMrAfonso

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?

xMrAfonso avatar Apr 30 '26 18:04 xMrAfonso

Could I get a potential update on this?

xMrAfonso avatar May 18 '26 18:05 xMrAfonso

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 avatar Jun 11 '26 10:06 atinux

@atinux I mean, if there is a standard structure/template you'd prefer for me to use, sure. Otherwise I can look into it.

xMrAfonso avatar Jun 11 '26 21:06 xMrAfonso

We don't at the moment but I think you can use something like https://tsdown.dev/guide/getting-started#starter-templates

atinux avatar Jun 13 '26 07:06 atinux

@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

farnabaz avatar Jun 18 '26 12:06 farnabaz

@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 avatar Jun 18 '26 12:06 xMrAfonso

@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 avatar Jun 18 '26 12:06 farnabaz

@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

xMrAfonso avatar Jun 18 '26 12:06 xMrAfonso

@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.

farnabaz avatar Jun 18 '26 12:06 farnabaz

Closing this in favor or our https://comark.dev/ecosystem page for all community plugins :)

farnabaz avatar Nov 18 '26 13:11 farnabaz