Skip to content

Commit 8e2f3c5

Browse files
committed
Allow label on mtd to be in any column.
These are converted into `mlabeledtr` (with the label in the first column)
1 parent 57f905b commit 8e2f3c5

File tree

12 files changed

+87
-55
lines changed

12 files changed

+87
-55
lines changed

Rules/Intent/general.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -805,31 +805,33 @@
805805
# Note: child hasn't been processed, so 'intent' hasn't been processed/turned into data-intent-property
806806
match: "count(*) > 1 and
807807
($TableProperty = 'piecewise' or $TableProperty = 'system-of-equations' or $TableProperty = 'lines') and
808-
(self::m:mlabeledtr or *[1][contains(@intent, ':equation-label')])"
808+
(self::m:mlabeledtr or *[contains(@intent, ':equation-label')])"
809809
replace:
810810
- intent:
811811
name: "mlabeledtr"
812812
children:
813-
- x: "*[1]"
813+
- x: "*[contains(@intent, ':equation-label')]"
814814
- intent:
815815
name: "mtd"
816-
attrs: "id='*[2]/@id'"
816+
attrs: "id=*[not(contains(@intent, ':equation-label'))][1]/*[1]/@id"
817817
children:
818818
- intent:
819819
name: "mrow"
820-
attrs: "id='*[2]/*[1]/@id'"
821-
children: [x: "*[position()>1]"]
820+
attrs: "id=*[not(contains(@intent, ':equation-label'))][1]/*[1]/@id"
821+
children: [x: "*[not(contains(@intent, ':equation-label'))]"]
822822

823823
-
824824
# convert a mtr to a mlabeledtr
825825
name: mlabeledtr
826826
tag: mtr
827827
# Note: child hasn't been processed, so 'intent' hasn't been processed/turned into data-intent-property
828-
match: "count(*) > 1 and *[1][contains(@intent, ':equation-label')]"
828+
match: "count(*) > 1 and *[contains(@intent, ':equation-label')]"
829829
replace:
830830
- intent:
831831
name: "mlabeledtr"
832-
children: [x: "*"]
832+
children:
833+
- x: "*[contains(@intent, ':equation-label')]"
834+
- x: "*[not(contains(@intent, ':equation-label'))]"
833835

834836
-
835837
# merge all the mtd into a single mtd
@@ -853,9 +855,11 @@
853855

854856
-
855857
# We need to preserve any intent properties that are on the mtd (e.g., :pause)
858+
# Note: at this point "intent" has been processed so we look at @data-intent-property
856859
name: mtd-to-mrow
857860
tag: mtd
858-
match: "$TableProperty = 'piecewise' or $TableProperty = 'system-of-equations' or $TableProperty = 'lines'"
861+
match: "($TableProperty = 'piecewise' or $TableProperty = 'system-of-equations' or $TableProperty = 'lines') and
862+
not(contains(@data-intent-property, ':equation-label'))"
859863
replace:
860864
- test:
861865
if: "@data-intent-property"

Rules/Languages/en/ClearSpeak_Rules.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -702,11 +702,11 @@
702702
then: [t: "step"] # phrase(this is a 'step' by step process)
703703
# else 'None -- don't say anything'
704704
- x: "count(preceding-sibling::*[not(contains(@data-intent-property, ':continued-row:'))]) + 1"
705-
- test:
706-
if: "self::m:mlabeledtr"
707-
then:
708-
- t: "with label" # phrase(the diagram is complete 'with label')
709-
- x: "*[1]/*"
705+
- test:
706+
if: "self::m:mlabeledtr"
707+
then:
708+
- t: "with label" # phrase(the diagram is complete 'with label')
709+
- x: "*[1]/*"
710710
- test:
711711
- if: "$ClearSpeak_MultiLineLabel='None'"
712712
then: [pause: xlong] # need a very long pause with no line labels

Rules/Languages/en/SharedRules/default.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,9 @@
411411

412412
- name: default
413413
tag: mtable
414-
variables: [IsColumnSilent: false()]
414+
variables:
415+
- IsColumnSilent: "false()"
416+
- NumColumns: "count(*[1]/*) - IfThenElse(*/self::m:mlabeledtr, 1, 0)"
415417
match: "."
416418
replace:
417419
- t: "table with" # phrase(the 'table with' 3 rows)
@@ -421,9 +423,9 @@
421423
then: [t: "row"] # phrase(the table with 1 'row')
422424
else: [t: "rows"] # phrase(the table with 3 'rows')
423425
- t: "and" # phrase(the table with 3 rows 'and' 4 columns)
424-
- x: "count(*[1]/*)"
426+
- x: "$NumColumns"
425427
- test:
426-
if: "count(*[1]/*)=1"
428+
if: "NumColumns=1"
427429
then: [t: "column"] # phrase(the table with 3 rows and 1 'column')
428430
else: [t: "columns"] # phrase(the table with 3 rows and 4 'columns')
429431
- pause: long
@@ -439,14 +441,14 @@
439441
- t: "row" # phrase(the first 'row' of a matrix)
440442
- x: "count(preceding-sibling::*)+1"
441443
- test:
442-
if: .[self::m:mlabeledtr]
444+
if: self::m:mlabeledtr
443445
then:
444446
- t: "with label" # phrase(the line 'with label' first equation)
445447
- x: "*[1]/*"
446448
- pause: short
447449
- pause: medium
448450
- test:
449-
if: .[self::m:mlabeledtr]
451+
if: self::m:mlabeledtr
450452
then: [x: "*[position()>1]"]
451453
else: {x: "*"}
452454

@@ -461,7 +463,7 @@
461463
if: "not($IsColumnSilent)"
462464
then:
463465
- t: "column" # phrase(the first 'column' of the matrix)
464-
- x: "count(preceding-sibling::*)+1"
466+
- x: "count(preceding-sibling::*)+IfThenElse(parent::m:mlabeledtr, 0, 1)"
465467
- pause: medium
466468
- x: "*"
467469
- test:

Rules/Languages/es/SharedRules/default.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,9 @@
358358

359359
- name: default
360360
tag: mtable
361-
variables: [IsColumnSilent: false()]
361+
variables:
362+
- IsColumnSilent: "false()"
363+
- NumColumns: "count(*[1]/*) - IfThenElse(*/self::m:mlabeledtr, 1, 0)"
362364
match: "."
363365
replace:
364366
- T: "tabla con"
@@ -368,9 +370,9 @@
368370
then: [T: "fila"]
369371
else: [T: "filas"]
370372
- T: y
371-
- x: "count(*[1]/*)"
373+
- x: "$NumColumns"
372374
- test:
373-
if: "count(*[1]/*)=1"
375+
if: "$NumColumns"
374376
then: [T: "columna"]
375377
else: [t: "columnas"]
376378
- pause: long
@@ -389,7 +391,7 @@
389391
match: "."
390392
replace:
391393
- T: "columna"
392-
- x: "count(preceding-sibling::*)+1"
394+
- x: "count(preceding-sibling::*)+IfThenElse(parent::m:mlabeledtr, 0, 1)"
393395
- pause: medium
394396
- x: "*" # speak the entry
395397
- pause: long

Rules/Languages/fi/SharedRules/default.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,9 @@
401401

402402
- name: default
403403
tag: mtable
404-
variables: [IsColumnSilent: false()]
404+
variables:
405+
- IsColumnSilent: "false()"
406+
- NumColumns: "count(*[1]/*) - IfThenElse(*/self::m:mlabeledtr, 1, 0)"
405407
match: "."
406408
replace:
407409
- T: "taulukko, jossa" # phrase(the 'table with' 3 rows)
@@ -411,9 +413,9 @@
411413
then: [T: "rivi"] # phrase(the table with 1 'row') # FI: singular
412414
else: [T: "riviä"] # phrase(the table with 3 'rows') # FI: plural
413415
- T: "ja" # phrase(the table with 3 rows 'and' 4 columns)
414-
- x: "count(*[1]/*)"
416+
- x: "$NumColumns"
415417
- test:
416-
if: "count(*[1]/*)=1"
418+
if: "$NumColumns"
417419
then: [T: "sarake"] # phrase(the table with 3 rows and 1 'column') # FI: singular
418420
else: [T: "saraketta"] # phrase(the table with 3 rows and 4 'columns') # FI: plural
419421
- pause: long
@@ -429,14 +431,14 @@
429431
- T: "rivi" # phrase(the first 'row' of a matrix)
430432
- x: "count(preceding-sibling::*)+1"
431433
- test:
432-
if: .[self::m:mlabeledtr]
434+
if: self::m:mlabeledtr
433435
then:
434436
- T: "merkinnällä" # phrase(the line 'with label' first equation)
435437
- x: "*[1]/*"
436438
- pause: short
437439
- pause: medium
438440
- test:
439-
if: .[self::m:mlabeledtr]
441+
if: self::m:mlabeledtr
440442
then: [{x: "*[position()>1]"}]
441443
else: {x: "*"}
442444

@@ -451,7 +453,7 @@
451453
if: "not($IsColumnSilent)"
452454
then:
453455
- T: "sarake" # phrase(the first 'column' of the matrix)
454-
- x: "count(preceding-sibling::*)+1"
456+
- x: "count(preceding-sibling::*)+IfThenElse(parent::m:mlabeledtr, 0, 1)"
455457
- pause: medium
456458
- x: "*"
457459
- test:

Rules/Languages/id/SharedRules/default.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,9 @@
294294

295295
- name: default
296296
tag: mtable
297-
variables: [{IsColumnSilent: false()}]
297+
variables:
298+
- IsColumnSilent: "false()"
299+
- NumColumns: "count(*[1]/*) - IfThenElse(*/self::m:mlabeledtr, 1, 0)"
298300
match: "."
299301
replace:
300302
- T: 'tabel dengan'
@@ -304,9 +306,9 @@
304306
then: {T: 'baris'}
305307
else: {T: 'baris'}
306308
- T: dan
307-
- x: "count(*[1]/*)"
309+
- x: "$NumColumns"
308310
- test:
309-
if: "count(*[1]/*)=1"
311+
if: "$NumColumns"
310312
then: {T: 'kolom'}
311313
else: {T: 'kolom'}
312314
- pause: long

Rules/Languages/sv/SharedRules/default.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,9 @@
415415
then: [T: "rad"] # phrase(the table with 1 'row')
416416
else: [T: "rader"] # phrase(the table with 3 'rows')
417417
- T: "och" # phrase(the table with 3 rows 'and' 4 columns)
418-
- x: "count(*[1]/*)"
418+
- x: "$NumColumns"
419419
- test:
420-
if: "count(*[1]/*)=1"
420+
if: "$NumColumns"
421421
then: [T: "kolumn"] # phrase(the table with 3 rows and 1 'column')
422422
else: [T: "kolumner"] # phrase(the table with 3 rows and 4 'columns')
423423
- pause: long
@@ -433,14 +433,14 @@
433433
- T: "rad" # phrase(the first 'row' of a matrix)
434434
- x: "count(preceding-sibling::*)+1"
435435
- test:
436-
if: .[self::m:mlabeledtr]
436+
if: self::m:mlabeledtr
437437
then:
438438
- T: "med etiketten" # phrase(the line 'with label' first equation)
439439
- x: "*[1]/*"
440440
- pause: short
441441
- pause: medium
442442
- test:
443-
if: .[self::m:mlabeledtr]
443+
if: self::m:mlabeledtr
444444
then: [{x: "*[position()>1]"}]
445445
else: {x: "*"}
446446

@@ -455,7 +455,7 @@
455455
if: "not($IsColumnSilent)"
456456
then:
457457
- T: "kolumn" # phrase(the first 'column' of the matrix)
458-
- x: "count(preceding-sibling::*)+1"
458+
- x: "count(preceding-sibling::*)+IfThenElse(parent::m:mlabeledtr, 0, 1)"
459459
- pause: medium
460460
- x: "*"
461461
- test:

Rules/Languages/vi/SharedRules/default.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,9 @@
422422

423423
- name: default
424424
tag: mtable
425-
variables: [{IsColumnSilent: false()}]
425+
variables:
426+
- IsColumnSilent: "false()"
427+
- NumColumns: "count(*[1]/*) - IfThenElse(*/self::m:mlabeledtr, 1, 0)"
426428
match: "."
427429
replace:
428430
- T: "bảng gồm"
@@ -432,9 +434,9 @@
432434
then: {T: "dòng"}
433435
else: {T: "dòng"}
434436
- T:
435-
- x: "count(*[1]/*)"
437+
- x: "$NumColumns"
436438
- test:
437-
if: "count(*[1]/*)=1"
439+
if: "$NumColumns"
438440
then: {T: "cột"}
439441
else: {T: "cột"}
440442
- pause: long
@@ -450,14 +452,14 @@
450452
- T: "dòng" # phrase(the first 'row' of a matrix)
451453
- x: "count(preceding-sibling::*)+1"
452454
- test:
453-
if: .[self::m:mlabeledtr]
455+
if: self::m:mlabeledtr
454456
then:
455457
- T: "có nhãn" # phrase(the line 'with label' first equation)
456458
- x: "*[1]/*"
457459
- pause: short
458460
- pause: medium
459461
- test:
460-
if: .[self::m:mlabeledtr]
462+
if: self::m:mlabeledtr
461463
then: [{x: "*[position()>1]"}]
462464
else: {x: "*"}
463465

@@ -472,7 +474,7 @@
472474
if: "not($IsColumnSilent)"
473475
then:
474476
- T: "cột" # phrase(the first 'column' of the matrix)
475-
- x: "count(preceding-sibling::*)+1"
477+
- x: "count(preceding-sibling::*)+IfThenElse(parent::m:mlabeledtr, 0, 1)"
476478
- pause: medium
477479
- x: "*"
478480
- test:

Rules/Languages/zh/tw/SharedRules/default.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,9 @@
401401

402402
- name: default
403403
tag: mtable
404-
variables: [IsColumnSilent: false()]
404+
variables:
405+
- IsColumnSilent: "false()"
406+
- NumColumns: "count(*[1]/*) - IfThenElse(*/self::m:mlabeledtr, 1, 0)"
405407
match: "."
406408
replace:
407409
- T: "" # phrase(the 'table with' 3 rows)
@@ -411,9 +413,9 @@
411413
then: [T: "列"] # phrase(the table with 1 'row')
412414
else: [T: "列"] # phrase(the table with 3 'rows')
413415
- T: "" # phrase(the table with 3 rows 'and' 4 columns)
414-
- x: "count(*[1]/*)"
416+
- x: "$NumColumns"
415417
- test:
416-
if: "count(*[1]/*)=1"
418+
if: "$NumColumns"
417419
then: [T: "行"] # phrase(the table with 3 rows and 1 'column')
418420
else: [T: "行"] # phrase(the table with 3 rows and 4 'columns')
419421
- pause: long
@@ -429,14 +431,14 @@
429431
- T: "" # phrase(the first 'row' of a matrix)
430432
- x: "count(preceding-sibling::*)+1"
431433
- test:
432-
if: .[self::m:mlabeledtr]
434+
if: self::m:mlabeledtr
433435
then:
434436
- T: "帶有標籤" # phrase(the line 'with label' first equation)
435437
- x: "*[1]/*"
436438
- pause: short
437439
- pause: medium
438440
- test:
439-
if: .[self::m:mlabeledtr]
441+
if: self::m:mlabeledtr
440442
then: [{x: "*[position()>1]"}]
441443
else: {x: "*"}
442444

@@ -451,7 +453,7 @@
451453
if: "not($IsColumnSilent)"
452454
then:
453455
- T: "" # phrase(the first 'column' of the matrix)
454-
- x: "count(preceding-sibling::*)+1"
456+
- x: "count(preceding-sibling::*)+IfThenElse(parent::m:mlabeledtr, 0, 1)"
455457
- pause: medium
456458
- x: "*"
457459
- test:

tests/Languages/en/mtable.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,10 @@ fn matrix_2x3_labeled() {
258258
</math>
259259
";
260260
test("en", "ClearSpeak", expr,
261-
"the 2 by 3 matrix; row 1 with label (3.1); column 2; 3, column 3; 1, column 4; 4; \
261+
"the 2 by 3 matrix; row 1 with label (3.1); column 1; 3, column 2; 1, column 3; 4; \
262262
row 2; column 1; 0, column 2; 2, column 3; 6");
263263
test("en", "SimpleSpeak", expr,
264-
"the 2 by 3 matrix; row 1 with label (3.1); column 2; 3, column 3; 1, column 4; 4; \
264+
"the 2 by 3 matrix; row 1 with label (3.1); column 1; 3, column 2; 1, column 3; 4; \
265265
row 2; column 1; 0, column 2; 2, column 3; 6");
266266
}
267267

@@ -1082,3 +1082,19 @@ fn diagonal_matrix() {
10821082
// test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Verbose")],
10831083
// expr, "the 3 by 3 diagonal matrix; row 1, column 1, 2; row 2, column 2, 1; row 3, column 3, x squared");
10841084
}
1085+
1086+
#[test]
1087+
fn single_line_with_label() {
1088+
let expr = r#"<math>
1089+
<mtable class="gather" displaystyle="true" intent=":system-of-equations">
1090+
<mtr>
1091+
<mtd intent=":equation-label"> <mtext>(2)</mtext> </mtd>
1092+
<mtd> <mi>𝑏</mi> <mo>=</mo> <mn>2</mn> </mtd>
1093+
</mtr>
1094+
</mtable>
1095+
</math>"#;
1096+
test_prefs("en", "ClearSpeak", vec![("Verbosity", "Terse")],
1097+
expr, "1 line, with label 2; b equals 2");
1098+
test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Terse")],
1099+
expr, "1 equation, with label 2; b equals 2");
1100+
}

0 commit comments

Comments
 (0)