md4w icon indicating copy to clipboard operation
md4w copied to clipboard

feat: customize rendering links

Open pi0 opened this issue 7 months ago • 3 comments

Some tags like <a> are simply rendered as <a href. For customizing theming, it is often common to need to add some classes. Also sometimes adding target and rel to links (to make them external)

I undrestand having dynamic callback fn might imply performance and complexity, but would it possible to have simple option to customize default templates in zig code?

pi0 avatar May 28 '25 16:05 pi0

i think we can add two flags for this:

LINK_REL_EXTERNAL // rel="external"
LINK_TARGET_BLANK // target="_blank"

what do you think?

ije avatar May 28 '25 17:05 ije

That would be nice! Also, perhaps the ability to set the default class or artibrary attrs string? (for styles, it is possible to use a wrapper class like .md a but when using md4w to embed partial renders, it becomes more tricky.

pi0 avatar May 29 '25 09:05 pi0

it's a bit complex to pass string to wasm, the flags option is just a number no memory alloc needed

ije avatar May 29 '25 11:05 ije