Let me describe what I really want.
I’m using markdown extension, to render markdown. My users also use HTML tags with certain attributes embeded in them. Based on the attributed and names, the html tags “act” differently. And by that I mean I want to add different decoration, highlights, autocompletes, keymaps to them. Basically I need something to make certain HTMLTags behave as if they were another Markdown entity, even though I perfectly know that they aren’t. They’re just regular HTML tags as markdown is concerned. But I would like the parser to differentiate them somehow. Actually, it doesn’t have to be a parser. I would like to simply add some “user data” to it,. so that when I write deccorations, autocomplete, keymaps, highlights I can just do node.type === 'SPECIAL_TYPE'
and just check it , without having to duplicate the “html-checking” logic in autocomplete, keymaps, decorations etc. Maybe assigning different tags to them would also be helpful.
What would be the best way to achive this?
I would simply like to add to the code mirror “something” that would allow me to mark or specify certain nodes, and then simply read that info in further places of the lib.
For example, I might have markdown like this
#heading
some kontent with inline kbd tag: somebody wants to use <kbd>Ctrl</kbd> key.
Someone below, might want to add block tag
<iframe src="href">
I know that from the markdown perspective, these tags are similar, there’s no real distingishment between them as far as parsing is concerned.
But I would like to somehow iterate them and mark them, so that the fruther parts of the library can use that distinction, instead of recomputing it again.
And the tags, must follow certain conditions (length, attributes, allowed keys inside). I would like a single place where I can distinguish/predicate them, and maybe assign a tag to the nodes or something; and then, in further parts of the app (autocomplete, decorations, keymaps) simply read those values from a boolean or something.