Skip to content

Commit af3102d

Browse files
Add custom macro support
1 parent 5a0c448 commit af3102d

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.1
2+
3+
* Added support for custom macros by exposing `defineMacro` in `package:flutter_math/tex.dart`.
4+
15
## 0.3.0+3
26

37
* Bump `flutter_svg`.

lib/src/parser/tex/macros.dart

+1-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ import 'parse_error.dart';
3535
import 'symbols.dart';
3636
import 'token.dart';
3737

38-
Map<String, MacroDefinition> _builtinMacros = {};
39-
4038
class MacroDefinition {
4139
final MacroExpansion Function(MacroContext context) expand;
4240
const MacroDefinition(this.expand, {this.unexpandable = false});
@@ -84,8 +82,7 @@ class MacroExpansion {
8482
}
8583

8684
void defineMacro(String name, MacroDefinition body) {
87-
// _builtinMacros ??= {};
88-
_builtinMacros[name] = body;
85+
builtinMacros[name] = body;
8986
}
9087

9188
const digitToNumber = {

lib/tex.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/// Utilites for Tex encoding and parsing.
1+
/// Utilities for Tex encoding and parsing.
22
library tex;
33

44
export 'src/ast/syntax_tree.dart'
55
show SyntaxTree, SyntaxNode, GreenNode, EquationRowNode;
66
export 'src/encoder/tex/encoder.dart'
77
show TexEncoder, TexEncoderExt, ListTexEncoderExt;
88
export 'src/parser/tex/colors.dart';
9-
export 'src/parser/tex/macros.dart' show MacroDefinition;
9+
export 'src/parser/tex/macros.dart' show MacroDefinition, defineMacro;
1010
export 'src/parser/tex/parser.dart' show TexParser;
1111
export 'src/parser/tex/settings.dart';

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_math_fork
22
description: Fast and high-quality TeX math equation rendering with pure Dart & Flutter.
3-
version: 0.3.0+3
3+
version: 0.3.1
44
homepage: https://github.com/znjameswu/flutter_math
55

66
environment:

0 commit comments

Comments
 (0)