Files
Luan Nico fbc58053dd feat: Support custom attributes syntax to allow for multiple styles in the text rendering pipeline (#3519)
This is a proposal to extend both our text rendering pipeline and our
markdown-parsing capabilities to support more fine-grained styling by
leveraging a subset of the extended markdown definition of "custom
attributes" (for example, see
[markdown-it-attrs](https://www.npmjs.com/package/markdown-it-attrs) as
an exemplary implementation).

On the markdown side, the syntax will look like this:

```markdown
[This is a custom class]{.my-custom-class}
This word will be [red]{.red} and this one will be [blue]{.blue}.
```

Note that the current implementation only supports specifying the class
name and will skip other possible permutations.

On the Flame side, we add a new `customStyles` map to the
`DocumentStyle` class, allowing users to provide as many styles as
desired.

Example:


![image](https://github.com/user-attachments/assets/fcc200c1-62cf-4977-990c-ab6c0701fdb7)

![image](https://github.com/user-attachments/assets/13c492c0-c2e6-486f-bd3a-4b7ed64b605c)

Currently, users have to hijack the existing syntaxes for the desired
styles; with the addition of code and strike-through recently I have
doubled the possibilities for custom styles, but the solution still
remained a hack. Also I now need more styles, and the only way forward
is to support arbitrary styling.

While we could consider supporting other attributes, such as id, css
styling, etc, within the attribute syntax, the class name is the most
flexible and versatile option, and it already solves all use cases, as
class names can be used as ids (if desired) and can be used to apply the
styling indirectly. I don't see any immediate advantage to supporting
more complex constructs within the attributes block (though of course we
can iterate as needed).
2025-03-12 09:38:15 -04:00
..