mirror of
https://activitypub.software/TransFem-org/sfm-js
synced 2024-11-28 17:03:03 +00:00
[wip] #34
This commit is contained in:
parent
3c5cd201a6
commit
32d5509898
1 changed files with 10 additions and 14 deletions
|
@ -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
|
||||||
= !.
|
= !.
|
||||||
|
|
Loading…
Reference in a new issue