chore: upgrade to markdown 4.0.0
This commit is contained in:
parent
285b14912a
commit
4f32168017
|
|
@ -32,30 +32,27 @@ class LinebreakSyntax extends InlineSyntax {
|
||||||
}
|
}
|
||||||
|
|
||||||
class SpoilerSyntax extends TagSyntax {
|
class SpoilerSyntax extends TagSyntax {
|
||||||
Map<String, String> reasonMap = <String, String>{};
|
SpoilerSyntax() : super(r'\|\|', requiresDelimiterRun: true);
|
||||||
SpoilerSyntax()
|
|
||||||
: super(
|
|
||||||
r'\|\|(?:([^\|]+)\|(?!\|))?',
|
|
||||||
requiresDelimiterRun: true,
|
|
||||||
end: r'\|\|',
|
|
||||||
);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool onMatch(InlineParser parser, Match match) {
|
Node close(InlineParser parser, Delimiter opener, Delimiter closer,
|
||||||
if (super.onMatch(parser, match)) {
|
{List<Node> Function() getChildren}) {
|
||||||
reasonMap[match.input] = match[1];
|
var reason = '';
|
||||||
return true;
|
final children = getChildren();
|
||||||
|
if (children.isNotEmpty) {
|
||||||
|
final te = children[0];
|
||||||
|
if (te is Text) {
|
||||||
|
final tx = te.text;
|
||||||
|
final ix = tx.indexOf('|');
|
||||||
|
if (ix > 0) {
|
||||||
|
reason = tx.substring(0, ix);
|
||||||
|
children[0] = Text(tx.substring(ix + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
final element = Element('span', children);
|
||||||
}
|
element.attributes['data-mx-spoiler'] = htmlAttrEscape.convert(reason);
|
||||||
|
return element;
|
||||||
@override
|
|
||||||
bool onMatchEnd(InlineParser parser, Match match, TagState state) {
|
|
||||||
final element = Element('span', state.children);
|
|
||||||
element.attributes['data-mx-spoiler'] =
|
|
||||||
htmlAttrEscape.convert(reasonMap[match.input] ?? '');
|
|
||||||
parser.addNode(element);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,14 +94,12 @@ class EmoteSyntax extends InlineSyntax {
|
||||||
}
|
}
|
||||||
|
|
||||||
class InlineLatexSyntax extends TagSyntax {
|
class InlineLatexSyntax extends TagSyntax {
|
||||||
InlineLatexSyntax() : super(r'\$', requiresDelimiterRun: true);
|
InlineLatexSyntax() : super(r'\$([^\s$]([^\$]*[^\s$])?)\$');
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool onMatchEnd(InlineParser parser, Match match, TagState state) {
|
bool onMatch(InlineParser parser, Match match) {
|
||||||
final latex =
|
final element = Element('span', [Element.text('code', match[1])]);
|
||||||
htmlEscape.convert(parser.source.substring(state.endPos, match.start));
|
element.attributes['data-mx-maths'] = match[1];
|
||||||
final element = Element('span', [Element.text('code', latex)]);
|
|
||||||
element.attributes['data-mx-maths'] = latex;
|
|
||||||
parser.addNode(element);
|
parser.addNode(element);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ dependencies:
|
||||||
http: ^0.13.0
|
http: ^0.13.0
|
||||||
mime: ^1.0.0
|
mime: ^1.0.0
|
||||||
canonical_json: ^1.0.0
|
canonical_json: ^1.0.0
|
||||||
markdown: ^3.0.0
|
markdown: ^4.0.0
|
||||||
html_unescape: ^1.0.2
|
html_unescape: ^1.0.2
|
||||||
moor: ^4.0.0
|
moor: ^4.0.0
|
||||||
random_string: ^2.1.0
|
random_string: ^2.1.0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue