Skip to content

Commit daeabe1

Browse files
committed
More fixes for Polish braille (focused on scripts and fractions).
Now down to 64 failures. There appear to be some mistakes in the tests for fractions that I still need to fix.
1 parent 93f7366 commit daeabe1

4 files changed

Lines changed: 264 additions & 84 deletions

File tree

‎Rules/Braille/Polish/Polish_Rules.yaml‎

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,11 @@
174174
replace:
175175
- t: "<⠆" # signal start of fraction (needed for state machine to replace spaces)
176176
- test:
177-
# FIX: it seems like this should be more general, but examples break when it is more general
178-
if: "not(IsNode(*[1], 'leaf')) and preceding-sibling::*[1][self::m:mo and (.='-' or .='+')]"
179-
then: [t: "+"] # "+" says to keep the indicator -- need to make sure the "numerator" appears to be in the fraction
177+
# Keep fraction start (p26 rule 4b): numerator begins with minus, or a unary minus precedes the fraction.
178+
# Do NOT keep merely because a binary +/- precedes the fraction (p28_3 omits start after binary minus).
179+
if: "(*[1][self::m:mo and .='-'] or *[1][self::m:mrow][*[1][self::m:mo and .='-']]) or
180+
(preceding-sibling::*[1][self::m:mo and .='-'] and not(preceding-sibling::*[2]))"
181+
then: [t: "+"] # "+" says to keep the indicator
180182
- x: "*[1]"
181183
- t: "W/"
182184
- test:
@@ -476,6 +478,15 @@
476478
- x: "*[1]"
477479
- T: "⠆⠆"
478480

481+
-
482+
# empty-base msup of primes (from MathML like <msup><mrow/><mo>″</mo></msup>);
483+
# skip the empty base so we don't emit W/⠈ before the primes
484+
name: prime-exception
485+
tag: msup
486+
match: "*[2][translate(., \"′″‴⁗\",'')=''] and translate(*[1], '\u00A0','')=''"
487+
replace:
488+
- x: "*[2]"
489+
479490
-
480491
name: diacriticals
481492
tag: [mover, msup]
@@ -515,23 +526,34 @@
515526
- x: "*[2]"
516527

517528
-
518-
name: prime-exception # 4.3.1
529+
# 4.3.1 / p35: primes with subscript — either primes first, or reverse order
530+
# (primes after the subscript) which requires keeping the simple close ⠱.
531+
# NBSP may remain in *[3]'s string-value from canonicalize of an empty-base nested msup.
532+
name: prime-exception
519533
tag: msubsup
520-
match: "*[3][translate(., \"′″‴⁗\",'')='']"
534+
match: "translate(*[3], \"′″‴⁗\u00A0\",'')=''"
521535
replace:
522536
- x: "*[1]"
523537
- test:
524-
if: "*[2][self::m:mn and translate(., '0123456789', '') = '']"
525-
then:
526-
- t: "<⠡"
527-
- x: "BrailleChars(translate(*[2], '0123456789', '\ue000\ue001\ue002\ue003\ue004\ue005\ue006\ue007\ue008\ue009'), 'Polish')"
528-
- t: ">⠱+"
529-
- x: "*[3]"
530-
else:
531-
- x: "*[3]"
532-
- t: "<⠡"
533-
- x: "*[2]"
534-
- t: ">⠱"
538+
- if: "*[2][self::m:mn and translate(., '0123456789', '') = '']"
539+
then:
540+
- t: "<⠡"
541+
- x: "BrailleChars(translate(*[2], '0123456789', '\ue000\ue001\ue002\ue003\ue004\ue005\ue006\ue007\ue008\ue009'), 'Polish')"
542+
- t: ">⠱+"
543+
- x: "*[3]"
544+
# reverse order for compound subscripts (e.g. x_{n+1}″)
545+
- else_if: "*[2][self::m:mrow or not(IsNode(., 'leaf'))]"
546+
then:
547+
- t: "<⠡"
548+
- x: "*[2]"
549+
- t: ">⠱+"
550+
- x: "*[3]"
551+
else:
552+
# primes first (e.g. a″_n)
553+
- x: "*[3]"
554+
- t: "<⠡"
555+
- x: "*[2]"
556+
- t: ">⠱"
535557

536558
-
537559
name: log-with-base
@@ -615,10 +637,10 @@
615637

616638
-
617639
# scripts
618-
# for some reason, the spec reverses the order of sub and sup for cap letters that are not chemistry
640+
# for some reason, the spec reverses the order of sub and sup for cap letters C (combinatorics) and V (???) that are not chemistry
619641
name: cap-letter-scripts
620642
tag: msubsup
621-
match: "not(@data-chem-element) and BaseNode(*[1])[translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', '') = '']"
643+
match: "not(@data-chem-element) and BaseNode(*[1])[.='C' or .='V']"
622644
# the examples all use superscripts, not exponents for cap letters these (for example p39 and p55)
623645
# also, for some reason, the cap letters use superscripts first
624646
replace:
@@ -652,8 +674,13 @@
652674
# the examples all use superscripts, not exponents for cap letters these (for example p39 and p55)
653675
# also, for some reason, the cap letters use superscripts first
654676
variables:
655-
- IsCapLetter: "BaseNode(*[1])[translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', '') = '']"
656-
- BaseNeedsSuperscript: "self::m:msubsup and (BaseNode(*[1])[self::m:mo or .='lim' or $IsCapLetter] or parent::m:mrow[parent::m:msup])"
677+
# ⠌ (superscript) vs ⠬ (exponent):
678+
# - mo/'lim' bases always use superscript
679+
# - msubsup nested under an outer msup uses ⠌ for its superscript half (p34_1, p34_4)
680+
# - plain nested msup (e.g. a^{2^{2k-1}-1}) must stay ⠬ (p33_3) -- do NOT apply the
681+
# parent::m:mrow[parent::m:msup] clause to self::m:msup
682+
- BaseNeedsSuperscript: "(self::m:msup and BaseNode(*[1])[self::m:mo or .='lim']) or
683+
(self::m:msubsup and (BaseNode(*[1])[self::m:mo or .='lim'] or parent::m:mrow[parent::m:msup]))"
657684
replace:
658685
- x: "*[1]"
659686
- test:

0 commit comments

Comments
 (0)