refactor: Update markdown
This commit is contained in:
parent
9376af619d
commit
5dd444daf2
|
|
@ -32,12 +32,17 @@ class LinebreakSyntax extends InlineSyntax {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SpoilerSyntax extends TagSyntax {
|
class SpoilerSyntax extends DelimiterSyntax {
|
||||||
SpoilerSyntax() : super(r'\|\|', requiresDelimiterRun: true);
|
SpoilerSyntax() : super(r'\|\|', requiresDelimiterRun: true);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Node close(InlineParser parser, Delimiter opener, Delimiter closer,
|
Iterable<Node>? close(
|
||||||
{required List<Node> Function() getChildren}) {
|
InlineParser parser,
|
||||||
|
Delimiter opener,
|
||||||
|
Delimiter closer, {
|
||||||
|
required String tag,
|
||||||
|
required List<Node> Function() getChildren,
|
||||||
|
}) {
|
||||||
final children = getChildren();
|
final children = getChildren();
|
||||||
final newChildren = <Node>[];
|
final newChildren = <Node>[];
|
||||||
var searchingForReason = true;
|
var searchingForReason = true;
|
||||||
|
|
@ -67,7 +72,7 @@ class SpoilerSyntax extends TagSyntax {
|
||||||
Element('span', searchingForReason ? children : newChildren);
|
Element('span', searchingForReason ? children : newChildren);
|
||||||
element.attributes['data-mx-spoiler'] =
|
element.attributes['data-mx-spoiler'] =
|
||||||
searchingForReason ? '' : htmlAttrEscape.convert(reason);
|
searchingForReason ? '' : htmlAttrEscape.convert(reason);
|
||||||
return element;
|
return [element];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,7 +115,7 @@ class EmoteSyntax extends InlineSyntax {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class InlineLatexSyntax extends TagSyntax {
|
class InlineLatexSyntax extends DelimiterSyntax {
|
||||||
InlineLatexSyntax() : super(r'\$([^\s$]([^\$]*[^\s$])?)\$');
|
InlineLatexSyntax() : super(r'\$([^\s$]([^\$]*[^\s$])?)\$');
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -131,16 +136,16 @@ class BlockLatexSyntax extends BlockSyntax {
|
||||||
final endPattern = RegExp(r'^(.*)\$\$\s*$');
|
final endPattern = RegExp(r'^(.*)\$\$\s*$');
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<String> parseChildLines(BlockParser parser) {
|
List<Line?> parseChildLines(BlockParser parser) {
|
||||||
final childLines = <String>[];
|
final childLines = <Line>[];
|
||||||
var first = true;
|
var first = true;
|
||||||
while (!parser.isDone) {
|
while (!parser.isDone) {
|
||||||
final match = endPattern.firstMatch(parser.current);
|
final match = endPattern.firstMatch(parser.current.content);
|
||||||
if (match == null || (first && match[1]!.trim().isEmpty)) {
|
if (match == null || (first && match[1]!.trim().isEmpty)) {
|
||||||
childLines.add(parser.current);
|
childLines.add(parser.current);
|
||||||
parser.advance();
|
parser.advance();
|
||||||
} else {
|
} else {
|
||||||
childLines.add(match[1]!);
|
childLines.add(Line(match[1]!));
|
||||||
parser.advance();
|
parser.advance();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ dependencies:
|
||||||
http: ^0.13.0
|
http: ^0.13.0
|
||||||
image: ^4.0.15
|
image: ^4.0.15
|
||||||
js: ^0.6.3
|
js: ^0.6.3
|
||||||
markdown: ^4.0.0
|
markdown: ^7.1.1
|
||||||
matrix_api_lite: ^1.7.0
|
matrix_api_lite: ^1.7.0
|
||||||
mime: ^1.0.0
|
mime: ^1.0.0
|
||||||
olm: ^2.0.2
|
olm: ^2.0.2
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue