Skip to content

Commit 5285d99

Browse files
content test: Add test for negative margins on a vlist row in KaTeX content
Skipped currently, because the parser incorrectly doesn't filter the negative margin styles on the vlist row span after generating a `KatexNegativeMarginNode` to specifically handle negative margins.
1 parent 72483dd commit 5285d99

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

test/model/content_test.dart

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,87 @@ class ContentExample {
13101310
]),
13111311
]);
13121312

1313+
static const mathBlockNegativeMarginsOnVlistRow = ContentExample(
1314+
'math block, KaTeX negative margins on a vlist row',
1315+
'```math\nX_n\n```',
1316+
'<p>'
1317+
'<span class="katex-display"><span class="katex">'
1318+
'<span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi>X</mi><mi>n</mi></msub></mrow><annotation encoding="application/x-tex">X_n</annotation></semantics></math></span>'
1319+
'<span class="katex-html" aria-hidden="true">'
1320+
'<span class="base">'
1321+
'<span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span>'
1322+
'<span class="mord">'
1323+
'<span class="mord mathnormal" style="margin-right:0.07847em;">X</span>'
1324+
'<span class="msupsub">'
1325+
'<span class="vlist-t vlist-t2">'
1326+
'<span class="vlist-r">'
1327+
'<span class="vlist" style="height:0.1514em;">'
1328+
'<span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;">'
1329+
'<span class="pstrut" style="height:2.7em;"></span>'
1330+
'<span class="sizing reset-size6 size3 mtight">'
1331+
'<span class="mord mathnormal mtight">n</span></span></span></span>'
1332+
'<span class="vlist-s">​</span></span>'
1333+
'<span class="vlist-r">'
1334+
'<span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></span></p>', [
1335+
MathBlockNode(
1336+
texSource: 'X_n',
1337+
nodes: [
1338+
KatexSpanNode(
1339+
styles: KatexSpanStyles(),
1340+
text: null,
1341+
nodes: [
1342+
KatexStrutNode(heightEm: 0.8333, verticalAlignEm: -0.15),
1343+
KatexSpanNode(
1344+
styles: KatexSpanStyles(),
1345+
text: null,
1346+
nodes: [
1347+
KatexSpanNode(
1348+
styles: KatexSpanStyles(
1349+
marginRightEm: 0.07847,
1350+
fontFamily: 'KaTeX_Math',
1351+
fontStyle: KatexSpanFontStyle.italic),
1352+
text: 'X',
1353+
nodes: null),
1354+
KatexSpanNode(
1355+
styles: KatexSpanStyles(textAlign: KatexSpanTextAlign.left),
1356+
text: null,
1357+
nodes: [
1358+
KatexVlistNode(
1359+
rows: [
1360+
KatexVlistRowNode(
1361+
verticalOffsetEm: -2.55 + 2.7,
1362+
node: KatexSpanNode(
1363+
styles: KatexSpanStyles(),
1364+
text: null,
1365+
nodes: [
1366+
KatexNegativeMarginNode(
1367+
leftOffsetEm: -0.0785,
1368+
nodes: [
1369+
KatexSpanNode(
1370+
styles: KatexSpanStyles(marginRightEm: 0.05),
1371+
text: null,
1372+
nodes: [
1373+
KatexSpanNode(
1374+
styles: KatexSpanStyles(fontSizeEm: 0.7),
1375+
text: null,
1376+
nodes: [
1377+
KatexSpanNode(
1378+
styles: KatexSpanStyles(
1379+
fontFamily: 'KaTeX_Math',
1380+
fontStyle: KatexSpanFontStyle.italic),
1381+
text: 'n',
1382+
nodes: null),
1383+
]),
1384+
]),
1385+
]),
1386+
])),
1387+
]),
1388+
]),
1389+
]),
1390+
]),
1391+
]),
1392+
]);
1393+
13131394
static const imageSingle = ContentExample(
13141395
'single image',
13151396
// https://chat.zulip.org/#narrow/stream/7-test-here/topic/Thumbnails/near/1900103
@@ -2405,6 +2486,10 @@ void main() async {
24052486
testParseExample(ContentExample.mathBlockKatexSubSuperScript);
24062487
testParseExample(ContentExample.mathBlockKatexRaisebox);
24072488
testParseExample(ContentExample.mathBlockKatexNegativeMargins);
2489+
testParseExample(ContentExample.mathBlockNegativeMarginsOnVlistRow,
2490+
// TODO fix parser to filter negative margins styles from
2491+
// vlist row span styles.
2492+
skip: true);
24082493

24092494
testParseExample(ContentExample.imageSingle);
24102495
testParseExample(ContentExample.imageSingleNoDimensions);

0 commit comments

Comments
 (0)