Skip to content

Tokenize entire <cite> element in line of text #3306

Answered by UziTech
starsbit asked this question in Q&A
Discussion options

You must be logged in to vote

You will need to write a custom extension.

Something like:

const citeExtension = {
  name: 'cite',
  level: 'inline',
  start(src) { return src.indexOf("<cite"); },
  tokenizer(src, tokens) {
    const rule = /^<cite>([\s\S]+?)<\/cite>/;
    const match = rule.exec(src);
    if (match) {
      return {
        type: 'html',
        pre: false,
        text: match[0],
        block: false,
        raw: match[0],
      };
    }
  }
};

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@starsbit
Comment options

@UziTech
Comment options

Answer selected by starsbit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants