Skip to content

Commit 465fe60

Browse files
committed
Fix #526
1 parent 7c299a8 commit 465fe60

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

Rules/Intent/general.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,18 +824,19 @@
824824
match: "count(*) > 1 and
825825
($TableProperty = 'piecewise' or $TableProperty = 'system-of-equations' or $TableProperty = 'lines') and
826826
(self::m:mlabeledtr or *[contains(@intent, ':equation-label')])"
827+
variables: [Label: "*[contains(@intent, ':equation-label')]"]
827828
replace:
828829
- intent:
829830
name: "mlabeledtr"
830831
children:
831-
- x: "*[contains(@intent, ':equation-label')]"
832+
- x: "IfThenElse($Label, $Label, (*[1]))"
832833
- intent:
833834
name: "mtd"
834835
children:
835836
- intent:
836837
name: "mrow"
837838
attrs: "id='concat(@id, \"-mrow\")'"
838-
children: [x: "*[not(contains(@intent, ':equation-label'))]"]
839+
children: [x: "IfThenElse($Label, (*[not(contains(@intent, ':equation-label'))]), (*[position() > 1]))"]
839840

840841
-
841842
# convert a mtr to a mlabeledtr

tests/Languages/intent/tables.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,5 +313,36 @@ fn lines() -> Result<()> {
313313
</math>";
314314
test_intent(mathml, intent, vec![])?;
315315
return Ok(());
316+
}
317+
316318

319+
#[test]
320+
fn mlabelledtr_bug_526() -> Result<()> {
321+
let mathml = r#"<math><mtable>
322+
<mlabeledtr>
323+
<mtd>
324+
<mtext>foo</mtext>
325+
</mtd>
326+
<mtd>
327+
<mi>m</mi>
328+
</mtd>
329+
</mlabeledtr>
330+
</mtable></math>"#;
331+
let intent = "<math data-from-mathml='math'>
332+
<lines data-from-mathml='mtable'>
333+
<mlabeledtr data-from-mathml='mlabeledtr'>
334+
<TEMP_NAME>
335+
<mtext data-from-mathml='mtext'>foo</mtext>
336+
</TEMP_NAME>
337+
<mtd data-from-mathml='mlabeledtr'>
338+
<mrow data-from-mathml='mlabeledtr'>
339+
<mi data-from-mathml='mi'>m</mi>
340+
</mrow>
341+
</mtd>
342+
</mlabeledtr>
343+
</lines>
344+
</math>";
345+
test_intent(mathml, intent, vec![])?;
346+
return Ok(());
317347
}
348+

0 commit comments

Comments
 (0)