From 3c196ba389a43bb988154aae8d06ee01bcb7c7ed Mon Sep 17 00:00:00 2001 From: Stegmujo Date: Tue, 25 Jul 2023 12:51:52 +0000 Subject: [PATCH] Render MathML for tripledash and ..arrows cmds from texfified mhchem * already these are as mhchem macros in mappings, tbd adapt Bug: T340024 Change-Id: Ic604720c71de720b6959159cfd78d6b55fdf399d --- src/TexVC/MMLmappings/BaseMappings.php | 2 +- src/TexVC/MMLmappings/BaseMethods.php | 3 +++ src/TexVC/MMLmappings/BaseParsing.php | 13 ++++++++++++- src/TexVC/texutil.json | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/TexVC/MMLmappings/BaseMappings.php b/src/TexVC/MMLmappings/BaseMappings.php index 2d680494f..27949f9e5 100644 --- a/src/TexVC/MMLmappings/BaseMappings.php +++ b/src/TexVC/MMLmappings/BaseMappings.php @@ -755,7 +755,7 @@ class BaseMappings { ], "tripledash" => [ 'macro', - '\\vphantom{-}\\raise2mu{\\kern2mu\\tiny\\text{-}\\kern1mu\\text{-}\\kern1mu\\text{-}\\kern2mu}' + '\\vphantom{-}\\raise{2mu}\\\kern{2mu}\\tiny\\text{-}\\kern{1mu}\\text{-}\\kern{1mu}\\text{-}\\kern{2mu}}' ], "xleftrightarrow" => [ 'xArrow', 0x2194, 6, 6 ], "xrightleftharpoons" => [ 'xArrow', 0x21CC, 5, 7 ], diff --git a/src/TexVC/MMLmappings/BaseMethods.php b/src/TexVC/MMLmappings/BaseMethods.php index d67acbef3..cd9ee5b4c 100644 --- a/src/TexVC/MMLmappings/BaseMethods.php +++ b/src/TexVC/MMLmappings/BaseMethods.php @@ -46,6 +46,9 @@ class BaseMethods { $resFct = BaseMappings::getSpecialByKey( $input ); if ( $resFct == null ) { $resFct = BaseMappings::getCancelByKey( $input ); + if ( $resFct == null ) { + $resFct = BaseMappings::getMhChemByKey( $input ); + } } } } diff --git a/src/TexVC/MMLmappings/BaseParsing.php b/src/TexVC/MMLmappings/BaseParsing.php index 161442147..347584f21 100644 --- a/src/TexVC/MMLmappings/BaseParsing.php +++ b/src/TexVC/MMLmappings/BaseParsing.php @@ -42,6 +42,7 @@ use MediaWiki\Extension\Math\TexVC\Nodes\Fun2sq; use MediaWiki\Extension\Math\TexVC\Nodes\Literal; use MediaWiki\Extension\Math\TexVC\Nodes\TexArray; use MediaWiki\Extension\Math\TexVC\Nodes\TexNode; +use MediaWiki\Extension\Math\TexVC\TexVC; /** * Parsing functions for specific recognized mappings. @@ -358,7 +359,8 @@ class BaseParsing { // Prevent parsing in unmapped cases return null; } - if ( $name == "mskip" || $name == "mkern" ) { + // Added kern j4t + if ( $name == "mskip" || $name == "mkern" || "kern" ) { $args = [ "width" => $em ]; } else { return null; @@ -483,6 +485,15 @@ class BaseParsing { $mo = new MMLmo(); return $mstyle->encapsulateRaw( $mspace->getEmpty() ) . $mo->encapsulateRaw( "⟺" ) . $mstyle->encapsulateRaw( $mspace->getEmpty() ); + case "tripledash": + print( "abc" ); + $texvc = new TexVC(); + $warnings = []; + $macro = "\\vphantom{-}\\raise{2mu}"; + $checkRes = $texvc->check( $macro, [ "usemhchem" => true, "usemhchemtexified" => true ], + $warnings, true ); + print( "res" ); + } // Removed all token based parsing, since macro resolution for the supported macros can be hardcoded in php diff --git a/src/TexVC/texutil.json b/src/TexVC/texutil.json index 776ba4327..dfbfd68c9 100644 --- a/src/TexVC/texutil.json +++ b/src/TexVC/texutil.json @@ -1215,6 +1215,10 @@ "\\ker": { "latex_function_names": true }, + "\\kern": { + "fun_ar1": true, + "mhchemtexified_required": true + }, "\\koppa": { "nullary_macro_in_mbox": true, "teubner_required": true