carta
carta copied to clipboard
HIghlight based on condition
I liked this library, simple to use and elegant. I was thinking is there a way we can highlight a text based on the text string? If you tell me the approach I can also try to contribute for this feature.
Hi, can you explain a bit more what you're trying to achieve? Would you like to modify how text is highlighted in the input? If that's the case, you need to inject some custom grammar and highlighting rules. Carta uses Shiki, which itself uses TextMate grammar. Here is an example taken from the emoji plugin:
https://github.com/BearToCode/carta/blob/bd45020cfd4e9a8bb1c16dc50115b1bdb2d0c60d/packages/plugin-emoji/src/lib/index.ts#L64-L86
Before saving the text, I am parsing the data, and if there is some word not satisfying the condition (yes similar to grammar check) then want to highlight it. I think what you have explained that should work. I'll study more and implement. I will update you soon. Thanks