You've already forked obsidian-visualiser
New CM6 live edition components and floating cache and persistance.
This commit is contained in:
27
shared/grammar/tag.extension.ts
Normal file
27
shared/grammar/tag.extension.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { MarkdownConfig } from '@lezer/markdown';
|
||||
import { styleTags, Tag, tags } from '@lezer/highlight';
|
||||
|
||||
export const tagTag = Tag.define('tag');
|
||||
export const tag: MarkdownConfig = {
|
||||
defineNodes: [
|
||||
'Tag',
|
||||
'TagMeta',
|
||||
],
|
||||
parseInline: [{
|
||||
name: 'Tag',
|
||||
parse(cx, next, pos)
|
||||
{
|
||||
//35 == '#'
|
||||
if (cx.slice(pos, pos + 1).charCodeAt(0) !== 35 || String.fromCharCode(next).trim() === '') return -1;
|
||||
|
||||
const end = cx.slice(pos, cx.end).search(/\s/);
|
||||
return cx.addElement(cx.elt('Tag', pos, end === -1 ? cx.end : end, [ cx.elt('TagMeta', pos, pos + 1) ]));
|
||||
},
|
||||
}],
|
||||
props: [
|
||||
styleTags({
|
||||
'Tag': tagTag,
|
||||
'TagMeta': tags.meta,
|
||||
})
|
||||
]
|
||||
};
|
||||
Reference in New Issue
Block a user