Canop / termimad

A library to display rich (Markdown) snippets and texts in a rust terminal application
MIT License
914 stars 31 forks source link

Feature request: please add custom style syntax #39

Open lucatrv opened 1 year ago

lucatrv commented 1 year ago

First of all thank you for this great crate! I am using termimad to implement a CLI tool which should output text in different colors, not related to bold, italic, code, or strikeout styles. In other words, once I have personalized my bold / italic / code / strikeout styles, then I also need to apply different colors to both stylized and normal text. It would be great to add the possibility to define new custom syntax. For instance, with reference to the following example:

skin.strikeout = CompoundStyle::new(Some(Red), None, Bold.into());

since I need to keep the strikeout style for some text, and also apply red bold style to some other text, it would be great to be able to write something like:

skin.custom_style("rb") = CompoundStyle::new(Some(Red), None, Bold.into());

and then apply it for instance as:

termimad::print_inline("#rb#red bold text!#rb#");
Canop commented 1 year ago

Thanks for the issue. This would probably be one of the best ways to overcome the obvious limitations of the Markdown approach. And I should probably work in this direction.

Before that, note a solution I use, which is to use dedicated skins. For example in safecloset: https://github.com/Canop/safecloset/blob/main/src/tui/skin/status_skin.rs