Skip to content

Commit

Permalink
fixed block tags ending in links
Browse files Browse the repository at this point in the history
  • Loading branch information
clragon committed Jun 3, 2024
1 parent 4e7f35e commit 5031117
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/markup/data/grammar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ class DTextGrammar extends GrammarDefinition<DTextElement> {
ref0(section),
].toChoiceParser();

Parser<void> blockMarkers() => [
ref1(blockMarker, 'quote'),
ref1(blockMarker, 'code'),
ref1(blockMarker, 'section'),
].toChoiceParser();

Parser<DTextElement> structures() => [
ref0(header),
ref0(list),
Expand Down Expand Up @@ -178,6 +184,16 @@ class DTextGrammar extends GrammarDefinition<DTextElement> {

Parser<DTextElement> character() => any().map((value) => DTextContent(value));

Parser<void> blockMarker(String tag) => (
char('['),
char('/').optional(),
stringIgnoreCase(tag),
(char('='), any().starLazy(char(']')).flatten())
.toSequenceParser()
.optional(),
char(']'),
).toSequenceParser();

Parser<DTextElement> simpleBlockTag(String tag) =>
ref3(blockTag, tag, tag, null).map((e) => e.$2);

Expand Down Expand Up @@ -273,7 +289,7 @@ class DTextGrammar extends GrammarDefinition<DTextElement> {
condense(
ref0(textElement)
.starLazy([
blocks(),
blockMarkers(),
newline(),
endOfInput(),
].toChoiceParser())
Expand All @@ -289,7 +305,7 @@ class DTextGrammar extends GrammarDefinition<DTextElement> {
condense(
ref0(textElement)
.starLazy([
blocks(),
blockMarkers(),
newline(),
endOfInput(),
].toChoiceParser())
Expand Down

0 comments on commit 5031117

Please sign in to comment.