Simplest possible example of a decorating editor extension?

I’m putting together a plugin that will apply styles to markdown-like sequences marked with semicolons. Like hel;sub;lo; will show hello, and ;sc;hello; will show hello (imagine that’s in small-caps if this forum really won’t let me style an HTML span tag).

I’ve got this working in reading mode (thanks to the sample plugin!) and I’m ready to tackle live-preview mode. I understand I’ll probably have to write an editor extension that applies a decoration. Is there some extremely simple plugin that does something similar to this that I can shamelessly stea… I mean… draw inspiration from?

I’m aware of Nothingislost’s obsidian-cm6-attributes. It seems to do at least three times more than I want to, and it looks like it would take fully mastering Code Mirror to figure out which two-thirds I could ignore. Is there an even simpler example out there somewhere? If not, are there any gotchas I should keep in mind when trying to wrap my head around obsidian-cm6-attributes (like maybe recent Obsidian changes that have broken it)?

Thanks!

CM6 is a beast. I am not sure it can be made simple. I think what you want is to use the Regex parser. Here is how I do it in SNW:

1 Like

Thanks for this! I’m still not very optimistic for my success, but your pointers will at least make my efforts over Christmas less frustrating.