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, }) ] };