This is the source markdown:
\n1*\n\n2* suffix\n\n_prefix_ 3*\n\nprefix 4*\n\nprefix 5* suffixIt seems to be unable to work if there is text before it. It works if the text is tokenized(like italic or bold) but not if it is plain text.
\nI tried to do additional inline parsing but I cannot prepend the text to my own token so this is not working at all.
ah, this worked:
\nconst rating = {\n name: 'rating',\n level: 'inline',\n start(src) { return src.match(/[1-5]\\*/)?.index; }, <-- no caret\n tokenizer(src) {\n const match = src.match(/^([1-5])\\*/); <--- caret\n if (match) {\n return {\n type: 'rating',\n raw: match[0],\n rating: parseInt(match[1]),\n };\n }\n }\n};-
|
I have a rating inline token which is const rating = {
name: 'rating',
level: 'inline',
start(src) { return src.match(/^[1-5]\*/)?.index; },
tokenizer(src) {
const match = src.match(/^([1-5])\*/);
if (match) {
return {
type: 'rating',
raw: match[0],
rating: parseInt(match[1]),
};
}
}
};This is the source markdown: 1*
2* suffix
_prefix_ 3*
prefix 4*
prefix 5* suffixIt seems to be unable to work if there is text before it. It works if the text is tokenized(like italic or bold) but not if it is plain text. |
Beta Was this translation helpful? Give feedback.
-
|
Your start regex has a ^ so it will only match if the text is at the beginning |
Beta Was this translation helpful? Give feedback.
ah, this worked: