This commit is contained in:
marihachi 2021-03-27 19:54:13 +09:00
parent 3c5cd201a6
commit 32d5509898

View file

@ -61,9 +61,8 @@ block
// block: quote // block: quote
quote quote
= head:quoteLine tails:(LF line:quoteLine { return line; })* = lines:quoteLine+
{ {
const lines = [head, ...tails];
const children = applyParser(lines.join('\n'), 'fullParser'); const children = applyParser(lines.join('\n'), 'fullParser');
return createNode('quote', null, children); return createNode('quote', null, children);
} }
@ -74,11 +73,11 @@ quoteLine
// block: search // block: search
search search
= BEGIN q:searchQuery _ searchKey END = BEGIN q:searchQuery sp:_ key:searchKey END
{ {
return createNode('search', { return createNode('search', {
query: q, query: q,
content: text() content: `${ q }${ sp }${ key }`
}); });
} }
@ -86,14 +85,14 @@ searchQuery
= (!(_ searchKey END) CHAR)+ { return text(); } = (!(_ searchKey END) CHAR)+ { return text(); }
searchKey searchKey
= "[" ("検索" / "Search"i) "]" = "[" ("検索" / "Search"i) "]" { return text(); }
/ "検索" / "検索"
/ "Search"i / "Search"i
// block: codeBlock // block: codeBlock
codeBlock codeBlock
= BEGIN "```" lang:$(CHAR*) LF code:codeBlockLines LF "```" END = BEGIN "```" lang:$(CHAR*) LF code:codeBlockContent LF "```" END
{ {
lang = lang.trim(); lang = lang.trim();
return createNode('blockCode', { return createNode('blockCode', {
@ -102,13 +101,10 @@ codeBlock
}); });
} }
codeBlockLines codeBlockContent
= head:codeBlockLine tails:(LF line:codeBlockLine { return line; })* = (!(LF "```" END) CHAR)+
{ return text(); } { return text(); }
codeBlockLine
= BEGIN (!(BEGIN "```" END) CHAR)* END { return text(); }
// block: mathBlock // block: mathBlock
mathBlock mathBlock
@ -124,7 +120,7 @@ mathBlockLines
{ return text(); } { return text(); }
mathBlockLine mathBlockLine
= (!("\\]" END) CHAR)+ = (!"\\]" CHAR)+
// block: center // block: center
@ -393,10 +389,10 @@ text
// //
BEGIN "beginning of line" BEGIN "beginning of line"
= &{ return location().start.column == 1; } = LF / &{ return location().start.column == 1; }
END "end of line" END "end of line"
= &LF / EOF = LF / EOF
EOF EOF
= !. = !.