-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
131 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:flutter_markdown_latex/flutter_markdown_latex.dart'; | ||
import 'package:markdown/markdown.dart'; | ||
|
||
class BingLatexBlockSyntax extends LatexBlockSyntax { | ||
@override | ||
List<Line> parseChildLines(BlockParser parser) { | ||
final childLines = super.parseChildLines(parser); | ||
|
||
return [Line("\\begin{aligned}"), ...childLines, Line("\\end{aligned}")]; | ||
} | ||
} | ||
|
||
class BingLatexInlineSyntax extends InlineSyntax { | ||
BingLatexInlineSyntax() | ||
: super(r'(\\\()(?![\n])(.*?)(\\\))(?=[\s?!\.,:?!。,:]|$)'); | ||
|
||
@override | ||
bool onMatch(InlineParser parser, Match match) { | ||
Element element = Element.text('latex', match[2] ?? ''); | ||
element.attributes['displayMode'] = | ||
match[1]?.length == 2 ? 'true' : 'false'; | ||
parser.addNode(element); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
extension SuffixOperation on String { | ||
String removeSuffix(String suffix) { | ||
if (endsWith(suffix)) { | ||
return substring(0, length - suffix.length); | ||
} | ||
return this; | ||
} | ||
|
||
String replaceSuffix(String suffix, String replacement) { | ||
if (endsWith(suffix)) { | ||
return substring(0, length - suffix.length) + replacement; | ||
} | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters