-
Notifications
You must be signed in to change notification settings - Fork 321
KaTeX(5/n): Handle 'position' & 'top' property in KaTeX span inline style #1627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -643,6 +643,72 @@ class KatexExample extends ContentExample { | |
text: '∗'), | ||
]), | ||
]); | ||
|
||
static final bigOperators = KatexExample.block( | ||
r'big operators: \int', | ||
// https://chat.zulip.org/#narrow/channel/7-test-here/topic/Rajesh/near/2240766 | ||
r'\int dx', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I wasn't clear enough — for making this example more complex, I really did mean just the screenshots 🙂. In the test code, it's nice to keep it as simple as possible. (And this test doesn't really gain anything from having the additional elements.) |
||
'<p>' | ||
'<span class="katex-display"><span class="katex">' | ||
'<span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mo>∫</mo><mi>d</mi><mi>x</mi></mrow><annotation encoding="application/x-tex">\\int dx</annotation></semantics></math></span>' | ||
'<span class="katex-html" aria-hidden="true">' | ||
'<span class="base">' | ||
'<span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span>' | ||
'<span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span>' | ||
'<span class="mspace" style="margin-right:0.1667em;"></span>' | ||
'<span class="mord mathnormal">d</span>' | ||
'<span class="mord mathnormal">x</span></span></span></span></span></p>', [ | ||
KatexSpanNode(nodes: [ | ||
KatexStrutNode(heightEm: 2.2222, verticalAlignEm: -0.8622), | ||
KatexSpanNode( | ||
styles: KatexSpanStyles( | ||
topEm: -0.0011, | ||
marginRightEm: 0.44445, | ||
fontFamily: 'KaTeX_Size2', | ||
position: KatexSpanPosition.relative), | ||
text: '∫'), | ||
KatexSpanNode(styles: KatexSpanStyles(marginRightEm: 0.1667), nodes: []), | ||
KatexSpanNode( | ||
styles: KatexSpanStyles(fontFamily: 'KaTeX_Math', fontStyle: KatexSpanFontStyle.italic), | ||
text: 'd'), | ||
KatexSpanNode( | ||
styles: KatexSpanStyles(fontFamily: 'KaTeX_Math', fontStyle: KatexSpanFontStyle.italic), | ||
text: 'x'), | ||
]), | ||
]); | ||
|
||
static final colonEquals = KatexExample.block( | ||
r'\colonequals relation', | ||
// https://chat.zulip.org/#narrow/channel/7-test-here/topic/Rajesh/near/2244936 | ||
r'\colonequals', | ||
'<p>' | ||
'<span class="katex-display"><span class="katex">' | ||
'<span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mo><mi mathvariant="normal">≔</mi></mo></mrow><annotation encoding="application/x-tex">\\colonequals</annotation></semantics></math></span>' | ||
'<span class="katex-html" aria-hidden="true">' | ||
'<span class="base">' | ||
'<span class="strut" style="height:0.4306em;"></span>' | ||
'<span class="mrel">' | ||
'<span class="mrel">' | ||
'<span class="mop" style="position:relative;top:-0.0347em;">:</span></span>' | ||
'<span class="mrel">' | ||
'<span class="mspace" style="margin-right:-0.0667em;"></span></span>' | ||
'<span class="mrel">=</span></span></span></span></span></span></p>', [ | ||
KatexSpanNode(nodes: [ | ||
KatexStrutNode(heightEm: 0.4306, verticalAlignEm: null), | ||
KatexSpanNode(nodes: [ | ||
KatexSpanNode(nodes: [ | ||
KatexSpanNode( | ||
styles: KatexSpanStyles(topEm: -0.0347, position: KatexSpanPosition.relative), | ||
text: ':'), | ||
]), | ||
KatexSpanNode(nodes: [ | ||
KatexSpanNode(nodes: []), | ||
KatexNegativeMarginNode(leftOffsetEm: -0.0667, nodes: []), | ||
]), | ||
KatexSpanNode(text: '='), | ||
]), | ||
]), | ||
]); | ||
} | ||
|
||
void main() async { | ||
|
@@ -663,6 +729,8 @@ void main() async { | |
testParseExample(KatexExample.textColor); | ||
testParseExample(KatexExample.customColorMacro); | ||
testParseExample(KatexExample.phantom); | ||
testParseExample(KatexExample.bigOperators); | ||
testParseExample(KatexExample.colonEquals); | ||
|
||
group('parseCssHexColor', () { | ||
const testCases = [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,15 @@ void main() { | |
('X', Offset(0.00, 7.04), Size(17.03, 25.00)), | ||
('n', Offset(17.03, 15.90), Size(8.63, 17.00)), | ||
]), | ||
(KatexExample.bigOperators, skip: false, [ | ||
('∫', Offset(0.00, 12.02), Size(11.43, 25.00)), | ||
('d', Offset(24.00, 12.03), Size(10.69, 25.00)), | ||
('x', Offset(34.70, 12.03), Size(11.76, 25.00)), | ||
]), | ||
Comment on lines
+76
to
+80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe even leave this one out of this widget test, since the test isn't sensitive enough to pick up whether the code is working. |
||
(KatexExample.colonEquals, skip: false, [ | ||
(':', Offset(0.00, 3.45), Size(5.72, 25.00)), | ||
('=', Offset(5.72, 3.92), Size(16.00, 25.00)), | ||
]), | ||
]; | ||
|
||
for (final testCase in testCases) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assert still seems quite relevant — but only in the case where
position
is null.