How to add classes to lines?

I’m trying to figure out how to add extra classes to lines to identify code blocks in markdown. Is there a supported way to do this in CodeMirror 6?

It looks like this might be what I’m looking for, but I’m still not entirely sure how to implement a line decoration. Anyone have any examples of this?

https://codemirror.net/6/docs/ref/#view.Decoration^line

This example might help.

1 Like

That is perfect. Thanks!

Okay, after digging in a bit more, the piece I’m struggling with now is figuring out how to dig into the markdown parser to determine whether a given line is part of a code block. I will continue digging into the source code, but if you have any tips, I’d appreciate it! :grin:

Iterating over the syntax tree is probably the easiest approach.

1 Like