Skip to content

Commit 7b952ee

Browse files
content: Record ancestor CSS classes in KaTeX parser
This will be use in later commits to apply styles based on some preconditions that depend on a class being present on an ancestor.
1 parent a795c3f commit 7b952ee

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/model/katex.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ class _KatexParser {
161161
final unsupportedCssClasses = <String>[];
162162
final unsupportedInlineCssProperties = <String>[];
163163

164+
final List<String> _ancestorClasses = [];
165+
164166
List<KatexNode> parseKatexHtml(dom.Element element) {
165167
assert(element.localName == 'span');
166168
assert(element.className == 'katex-html');
@@ -177,7 +179,9 @@ class _KatexParser {
177179
: 'unsupported html node');
178180
}
179181

182+
_ancestorClasses.add(node.className);
180183
final span = _parseSpan(node);
184+
assert(_ancestorClasses.removeLast() == node.className);
181185

182186
if (span is KatexSpanNode) {
183187
final marginRightEm = span.styles.marginRightEm;

0 commit comments

Comments
 (0)