Adding support for the additional inline syntax to Markdown

You should be able to do something like this (slight change to the GFM strikethrough extension in the markdown parser);

import {MarkdownConfig} from "lezer-markdown"
import {styleTags, tags} from "@codemirror/highlight"

const HighlightDelim = {resolve: "Highlight", mark: "Highlight"}

const Highlight: MarkdownConfig = {
  defineNodes: ["Highlight", "HighlightMark"],
  parseInline: [{
    name: "Highlight",
    parse(cx, next, pos) {
      if (next != 61 /* '=' */ || cx.char(pos + 1) != 61) return -1
      return cx.addDelimiter(HighlightDelim, pos, pos + 2, true, true)
    },
    after: "Emphasis"
  }],
  props: [
    styleTags({
      HighlightMark: tags.processingInstruction,
      Highlight: tags.special(tags.strong)
    })
  ]
}

And then add an extension like this to your editor:

  markdown({
    base: markdownLanguage,
    extensions: [Highlight]
  })
1 Like