Hello, I’m struggling with extending my markdown parser to work like it did in Code Mirror 5.
I can see examples but I have no idea what these numbers correlate to, they don’t seem to be javascript keycodes. e.g (Yes this specific character is shown in a comment but that doesn’t allow me to know what other characters would be)
Below is what I had in Code Mirror 5, for context this token is very simple and if possible I’d rather just use regex instead of streams, but am willing to work with whichever.
The corresponding regex would be RegExp(/\?-(.*?)-\?/g)
Code Mirror 5 Example
(TLDR it finds matches between: ?- here -? )
export const FIB_MODE = 'fib';
CodeMirror.defineMode(FIB_MODE, function (config, parserConfig) {
const fibOverlay = {
token: function (stream, state) {
let ch;
if (stream.match('?-')) {
while ((ch = stream.next()) != null)
if (ch == '-' && stream.next() == '?') {
stream.eat('?');
return FIB_MODE;
}
}
// Necessary
while (stream.next() != null && !stream.match('?-', false)) {}
return null;
},
};
return CodeMirror.overlayMode(
CodeMirror.getMode(config, parserConfig.backdrop || 'markdown'),
fibOverlay
);
});
i.e. Is there an example of extending markdown in CodeMirror 6 and how do I know what those numbers in the inline parser correlate to?
Characters have numbers (see String.charCodeAt and the Unicode standard), and that’s what is being used here. You should be able to define an inline parser to parse this syntax, but it’s going to require some programming and reading of docs.