You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
marked.use({extensions: [{name: "underline",level: "inline",start: (src)=>{returnsrc.match(/__(.*?)__/)?.index;},tokenizer(src,tokens){varmatch=src.match(/__(.*?)__/);if(match){vartoken={type: "underline",raw: match[0],text: this.lexer.inlineTokens(match[1].trim(),[])};returntoken;}},renderer(token){return`<u>${this.parser.parseInline(token.text,null)}</u>`;},}]});varmd=`# Header**This** is a normal text writted in \`JavaScript\` for \`Marked\`.__test__`;marked.parse(md);
For supporting underline in Marked. But for some reasons it didn't work. Can someone explain what I did wrong? Thanks.
Expectation
<h1>Header</h1><p><strong>This</strong> is a normal text writted in <code>JavaScript</code> for <code>Marked</code>.
<u>test</u></p>
Before making this issue I attempt to looking some source codes of other extensions of Marked but it did not help. Plus I took a look at the documentation but still no luck. I tried fixing the RegEx in RegExR but it seems good. I probably didn't understand something and did a mistake in the tokenizer section but I don't know what it is, can someone help me please? Thanks in advance 👍.
The text was updated successfully, but these errors were encountered:
One common mistake: you need to add a ^ to the start of your Tokenizer match regex (but not the "start" match regex).
Otherwise the Tokenizer will start finding your underline tokens way out in the middle of your document before handling earlier tokens first, and your resulting output becomes out of order or duplicated.
Marked version: 4.2.12
Markdown flavor: n/a (?)
I tried to add an extension like this:
For supporting underline in Marked. But for some reasons it didn't work. Can someone explain what I did wrong? Thanks.
Expectation
Result
What was attempted
Before making this issue I attempt to looking some source codes of other extensions of Marked but it did not help. Plus I took a look at the documentation but still no luck. I tried fixing the RegEx in RegExR but it seems good. I probably didn't understand something and did a mistake in the
tokenizer
section but I don't know what it is, can someone help me please? Thanks in advance 👍.The text was updated successfully, but these errors were encountered: