Skip to content

Commit

Permalink
Remove menclose in cancel rendering
Browse files Browse the repository at this point in the history
Chrome and similar browsers do not support the
menclose tag. This change introduces a css polyfill
suggested in

w3c/mathml-core#245 (comment)

but keeps the mencose rendering since FF does not
support the polyfill

https://bugzilla.mozilla.org/show_bug.cgi?id=1929800

Bug: T376829
Change-Id: I860e2f2f9bf9eef8eeba35b0999ec50175fdfc4b
  • Loading branch information
physikerwelt committed Nov 8, 2024
1 parent 4ce41fa commit cc0a214
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
28 changes: 28 additions & 0 deletions modules/ext.math.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,31 @@ mtd.mwe-math-matrix-left {
mtd.mwe-math-matrix-right {
border-right: 0.06em solid;
}

/* see https://github.com/w3c/mathml-core/issues/245#issuecomment-2410676518 */
menclose.menclose {
position: relative;
padding: 0.5ex 0;
}

mrow.menclose-updiagonalstrike {
display: inline-block;
position: absolute;
left: 0.5px;
bottom: 0;
width: 100%;
height: 100%;
background-color: currentcolor;
clip-path: polygon( 0.05em 100%, 0 calc( 100% - 0.05em ), calc( 100% - 0.05em ) 0, 100% 0.05em );
}

mrow.menclose-downdiagonalstrike {
display: inline-block;
position: absolute;
left: 0.5px;
bottom: 0;
width: 100%;
height: 100%;
background-color: currentcolor;
clip-path: polygon( 0 0, 0.05em 0, 100% 100%, calc( 100% - 0.05em ) 100% );
}
12 changes: 8 additions & 4 deletions src/WikiTexVC/MMLmappings/BaseParsing.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,14 @@ public static function boldsymbol( $node, $passedArgs, $operatorContent, $name,
return $mrow->encapsulateRaw( $node->getArg()->renderMML( $passedArgs ) );
}

public static function cancel( $node, $passedArgs, $operatorContent, $name, $notation = null, $smth2 = null ) {
$mrow = new MMLmrow();
$menclose = new MMLmenclose( "", [ "notation" => $notation ] );
return $mrow->encapsulateRaw( $menclose->encapsulateRaw( $node->getArg()->renderMML() ) );
public static function cancel( Fun1 $node, $passedArgs, $operatorContent, $name, $notation = '' ): string {
$outer = new MMLmenclose( '', [ 'notation' => $notation, 'class' => 'menclose' ] );
$bars = '';
foreach ( explode( ' ', $notation ) as $element ) {
$bars .= ( new MMLmrow( '', [ 'class' => 'menclose-' . $element ] ) )->getEmpty();
}

return $outer->encapsulateRaw( $node->getArg()->renderMML() . $bars );
}

public static function cancelTo( $node, $passedArgs, $operatorContent, $name, $notation = null ) {
Expand Down
4 changes: 3 additions & 1 deletion tests/phpunit/unit/WikiTexVC/MMLmappings/BaseParsingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ public function testCancel() {
( new Literal( 'a' ) )
);
$result = BaseParsing::cancel( $node, [], null, 'cancel', 'something' );
$this->assertStringContainsString( '<menclose notation="something"><mi>a</mi></menclose>',
$this->assertStringContainsString( '<mi>a</mi><mrow class="menclose-something"/>',
$result );
$this->assertStringContainsString( '<menclose notation="something" class="menclose">',
$result );
}

Expand Down

0 comments on commit cc0a214

Please sign in to comment.