mirror of
https://activitypub.software/TransFem-org/sfm-js
synced 2024-11-25 07:25:13 +00:00
Parser: improve performance
This commit is contained in:
parent
e412bcd179
commit
b09c3d4691
1 changed files with 45 additions and 26 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue