Skip to content

Commit f845c6d

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 39c53bd commit f845c6d

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
@@ -1280,6 +1280,87 @@ class ContentExample {
12801280
]),
12811281
]);
12821282

1283+
static const mathBlockNegativeMarginsOnVlistRow = ContentExample(
1284+
'math block, KaTeX negative margins on a vlist row',
1285+
'```math\nX_n\n```',
1286+
'<p>'
1287+
'<span class="katex-display"><span class="katex">'
1288+
'<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>'
1289+
'<span class="katex-html" aria-hidden="true">'
1290+
'<span class="base">'
1291+
'<span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span>'
1292+
'<span class="mord">'
1293+
'<span class="mord mathnormal" style="margin-right:0.07847em;">X</span>'
1294+
'<span class="msupsub">'
1295+
'<span class="vlist-t vlist-t2">'
1296+
'<span class="vlist-r">'
1297+
'<span class="vlist" style="height:0.1514em;">'
1298+
'<span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;">'
1299+
'<span class="pstrut" style="height:2.7em;"></span>'
1300+
'<span class="sizing reset-size6 size3 mtight">'
1301+
'<span class="mord mathnormal mtight">n</span></span></span></span>'
1302+
'<span class="vlist-s">​</span></span>'
1303+
'<span class="vlist-r">'
1304+
'<span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></span></p>', [
1305+
MathBlockNode(
1306+
texSource: 'X_n',
1307+
nodes: [
1308+
KatexSpanNode(
1309+
styles: KatexSpanStyles(),
1310+
text: null,
1311+
nodes: [
1312+
KatexStrutNode(heightEm: 0.8333, verticalAlignEm: -0.15),
1313+
KatexSpanNode(
1314+
styles: KatexSpanStyles(),
1315+
text: null,
1316+
nodes: [
1317+
KatexSpanNode(
1318+
styles: KatexSpanStyles(
1319+
marginRightEm: 0.07847,
1320+
fontFamily: 'KaTeX_Math',
1321+
fontStyle: KatexSpanFontStyle.italic),
1322+
text: 'X',
1323+
nodes: null),
1324+
KatexSpanNode(
1325+
styles: KatexSpanStyles(textAlign: KatexSpanTextAlign.left),
1326+
text: null,
1327+
nodes: [
1328+
KatexVlistNode(
1329+
rows: [
1330+
KatexVlistRowNode(
1331+
verticalOffsetEm: -2.55 + 2.7,
1332+
node: KatexSpanNode(
1333+
styles: KatexSpanStyles(),
1334+
text: null,
1335+
nodes: [
1336+
KatexNegativeMarginNode(
1337+
leftOffsetEm: -0.0785,
1338+
nodes: [
1339+
KatexSpanNode(
1340+
styles: KatexSpanStyles(marginRightEm: 0.05),
1341+
text: null,
1342+
nodes: [
1343+
KatexSpanNode(
1344+
styles: KatexSpanStyles(fontSizeEm: 0.7),
1345+
text: null,
1346+
nodes: [
1347+
KatexSpanNode(
1348+
styles: KatexSpanStyles(
1349+
fontFamily: 'KaTeX_Math',
1350+
fontStyle: KatexSpanFontStyle.italic),
1351+
text: 'n',
1352+
nodes: null),
1353+
]),
1354+
]),
1355+
]),
1356+
])),
1357+
]),
1358+
]),
1359+
]),
1360+
]),
1361+
]),
1362+
]);
1363+
12831364
static const imageSingle = ContentExample(
12841365
'single image',
12851366
// https://chat.zulip.org/#narrow/stream/7-test-here/topic/Thumbnails/near/1900103
@@ -2376,6 +2457,10 @@ void main() async {
23762457
testParseExample(ContentExample.mathBlockKatexRaisebox);
23772458
testParseExample(ContentExample.mathBlockKatexNegativeMargin);
23782459
testParseExample(ContentExample.mathBlockKatexLogo);
2460+
testParseExample(ContentExample.mathBlockNegativeMarginsOnVlistRow,
2461+
// TODO fix parser to filter negative margins styles from
2462+
// vlist row span styles.
2463+
skip: true);
23792464

23802465
testParseExample(ContentExample.imageSingle);
23812466
testParseExample(ContentExample.imageSingleNoDimensions);

0 commit comments

Comments
 (0)