Skip to content
Snippets Groups Projects
Commit b09c3d46 authored by marihachi's avatar marihachi
Browse files

Parser: improve performance

parent e412bcd1
No related branches found
No related tags found
No related merge requests found
......@@ -63,7 +63,7 @@
//
fullParser
= nodes:(&. n:(block / inline) { return n; })* { return mergeText(nodes); }
= nodes:(&. n:full { return n; })* { return mergeText(nodes); }
plainParser
= nodes:(&. n:(emojiCode / unicodeEmoji / plainText) { return n; })* { return mergeText(nodes); }
......@@ -72,20 +72,56 @@ inlineParser
= nodes:(&. n:inline { return n; })* { return mergeText(nodes); }
//
// block rules
// syntax list
//
block
= quote
/ search
/ codeBlock
/ mathBlock
/ center
full
= quote // block
/ codeBlock // block
/ mathBlock // block
/ center // block
/ emojiCode
/ unicodeEmoji
/ big
/ bold
/ small
/ italic
/ strike
/ inlineCode
/ mathInline
/ mention
/ hashtag
/ url
/ link
/ fn
/ search // block
/ inlineText
inline
= emojiCode
/ unicodeEmoji
/ big
/ bold
/ small
/ italic
/ strike
/ inlineCode
/ mathInline
/ mention
/ hashtag
/ url
/ link
/ fn
/ inlineText
//
// block rules
//
// block: quote
quote
= head:quoteMultiLine tails:quoteMultiLine+
= &(BEGIN ">") head:quoteMultiLine tails:quoteMultiLine+
{
const children = applyParser([head, ...tails].join('\n'), 'fullParser');
return QUOTE(children);
......@@ -161,23 +197,6 @@ center
// inline rules
//
inline
= emojiCode
/ unicodeEmoji
/ big
/ bold
/ small
/ italic
/ strike
/ inlineCode
/ mathInline
/ mention
/ hashtag
/ url
/ link
/ fn
/ inlineText
// inline: emoji code
emojiCode
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment