Best way to analyse DocumentLines without CodeBlock

I’m trying to develop a little new plugin which should analyze the current document (special count of customizable words) or other stuff like this. But i won’t count this special words, when they are used in codeblocks. What is the best way to access to the current file/activeView and get the line without the codeblocks?

I tried to get all the lines from the activeView and check the beginning of the codeblocks by searching the “```” in string and made an on/off-sign to overread the codeblocks. But i think that couldn’t be the way which should be used.

Has someone a hint for me ?

Do note that the code fence is at least three backticks or tildes. This means, and I’m constantly using this in forum answers, you can use more than three of either character. So ~~~~~ and ```` are also perfectly valid for fencing in code blocks.

In addition the code blocks can be indented to match up with list indentations.

So detecting them properly can be tricky, and sadly I’m not sure how to do so reliably.

Thank you for the note, that there could be more of them.

When i debug in chrome i see in activeView.editor.cm.docview.children[x].dom
that there is a type which is called div.HyperMD-codeblock.HyperMD-codeblock-bg.cm-line instead of “div.cm-line” in normal line. But i found nothing in documentation, how a can get this information in truescript.

Moved to Developers & API, and removed the “editor-legacy” tag (assuming it was applied by accident since the legacy editor is deprecated or maybe even removed at this point).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.