@@ -182,6 +182,9 @@ var temml = (function () {
182182 return + n . toFixed ( 4 ) ;
183183 } ;
184184
185+ // Identify short letters. Used for accents and \cancelto.
186+ const smalls = "acegıȷmnopqrsuvwxyzαγεηικμνοπρςστυχωϕ𝐚𝐜𝐞𝐠𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐮𝐯𝐰𝐱𝐲𝐳" ;
187+
185188 /**
186189 * This is a module for storing settings passed into Temml. It correctly handles
187190 * default settings.
@@ -797,6 +800,8 @@ var temml = (function () {
797800 xrightarrow : "\u2192" ,
798801 underbrace : "\u23df" ,
799802 overbrace : "\u23de" ,
803+ overbracket : "\u23b4" ,
804+ underbracket : "\u23b5" ,
800805 overgroup : "\u23e0" ,
801806 overparen : "⏜" ,
802807 undergroup : "\u23e1" ,
@@ -2452,9 +2457,6 @@ var temml = (function () {
24522457 return math ;
24532458 }
24542459
2455- // Identify letters to which we'll attach a combining accent character
2456- const smalls = "acegıȷmnopqrsuvwxyzαγεηικμνοπρςστυχωϕ𝐚𝐜𝐞𝐠𝐦𝐧𝐨𝐩𝐪𝐫𝐬𝐮𝐯𝐰𝐱𝐲𝐳" ;
2457-
24582460 // From the KaTeX font metrics, identify letters whose accents need a italic correction.
24592461 const smallNudge = "DHKLUcegorsuvxyzΠΥΨαδηιμνοτυχϵ" ;
24602462 const mediumNudge = "BCEGIMNOPQRSTXZlpqtwΓΘΞΣΦΩβεζθξρςφψϑϕϱ" ;
@@ -4521,6 +4523,7 @@ var temml = (function () {
45214523 const tbl = [ ] ;
45224524 const numRows = group . body . length ;
45234525 const hlines = group . hLinesBeforeRow ;
4526+ const tagIsPresent = ( group . tags && group . tags . some ( ( tag ) => tag ) ) ;
45244527
45254528 for ( let i = 0 ; i < numRows ; i ++ ) {
45264529 const rw = group . body [ i ] ;
@@ -4550,7 +4553,7 @@ var temml = (function () {
45504553 for ( let k = 0 ; k < numColumns - rw . length ; k ++ ) {
45514554 row . push ( new MathNode ( "mtd" , [ ] , [ ] , style ) ) ;
45524555 }
4553- if ( group . autoTag ) {
4556+ if ( tagIsPresent ) {
45544557 const tag = group . tags [ i ] ;
45554558 let tagElement ;
45564559 if ( tag === true ) { // automatic numbering
@@ -4662,7 +4665,7 @@ var temml = (function () {
46624665 if ( j === numCols - 1 && hand === 1 ) { return "0" }
46634666 if ( group . envClasses [ 0 ] !== "align" ) { return sidePadding }
46644667 if ( hand === 1 ) { return "0" }
4665- if ( group . autoTag ) {
4668+ if ( tagIsPresent ) {
46664669 return ( j % 2 ) ? "1" : "0"
46674670 } else {
46684671 return ( j % 2 ) ? "0" : "1"
@@ -4698,7 +4701,7 @@ var temml = (function () {
46984701 // TODO: Remove -webkit- when Chromium no longer needs it.
46994702 row . children [ j ] . classes = [ "tml-" + ( j % 2 ? "left" : "right" ) ] ;
47004703 }
4701- if ( group . autoTag ) {
4704+ if ( tagIsPresent ) {
47024705 const k = group . leqno ? 0 : row . children . length - 1 ;
47034706 row . children [ k ] . classes = [ ] ; // Default is center.
47044707 }
@@ -4755,7 +4758,7 @@ var temml = (function () {
47554758 row . children [ 0 ] . style . borderLeft = sep ;
47564759 }
47574760 }
4758- let iCol = group . autoTag ? 0 : - 1 ;
4761+ let iCol = tagIsPresent ? 0 : - 1 ;
47594762 for ( let i = iStart ; i < iEnd ; i ++ ) {
47604763 if ( cols [ i ] . type === "align" ) {
47614764 const colAlign = alignMap [ cols [ i ] . align ] ;
@@ -5281,6 +5284,78 @@ var temml = (function () {
52815284 }
52825285 } ) ;
52835286
5287+ defineFunction ( {
5288+ type : "cancelto" ,
5289+ names : [ "\\cancelto" ] ,
5290+ props : {
5291+ numArgs : 2
5292+ } ,
5293+ handler ( { parser } , args ) {
5294+ const to = args [ 0 ] ;
5295+ const body = args [ 1 ] ;
5296+ return {
5297+ type : "cancelto" ,
5298+ mode : parser . mode ,
5299+ body,
5300+ to,
5301+ isCharacterBox : isCharacterBox ( body )
5302+ } ;
5303+ } ,
5304+ mathmlBuilder ( group , style ) {
5305+ const fromNode = new MathNode (
5306+ "mrow" ,
5307+ [ buildGroup$1 ( group . body , style ) ] ,
5308+ [ "ff-narrow" ] // A zero-width mrow.
5309+ ) ;
5310+ // Write the arrow in a node written after the content.
5311+ // That way, the arrow will be an overlay on the content.
5312+ const phantom = new MathNode ( "mphantom" , [ buildGroup$1 ( group . body , style ) ] ) ;
5313+ const arrow = new MathNode ( "mrow" , [ phantom ] , [ "tml-cancelto" ] ) ;
5314+ if ( group . isCharacterBox && smalls . indexOf ( group . body . body [ 0 ] . text ) > - 1 ) {
5315+ arrow . style . left = "0.1em" ;
5316+ arrow . style . width = "90%" ;
5317+ }
5318+ const node = new MathNode ( "mrow" , [ fromNode , arrow ] , [ "menclose" ] ) ;
5319+ if ( ! group . isCharacterBox || / [ f ∫ ∑ ] / . test ( group . body . body [ 0 ] . text ) ) {
5320+ // Add 0.2em space to right of content to make room for the arrowhead.
5321+ phantom . style . paddingRight = "0.2em" ;
5322+ } else {
5323+ phantom . style . padding = "0.5ex 0.1em 0 0" ;
5324+ const strut = new MathNode ( 'mspace' , [ ] ) ;
5325+ strut . setAttribute ( 'height' , "0.85em" ) ;
5326+ fromNode . children . push ( strut ) ;
5327+ }
5328+
5329+ // Create the "to" value above and to the right of the arrow.
5330+ // First, we want a dummy node with the same height as the `from` content.
5331+ // We'll place the `to` node above the dummy to get the correct vertical alignment.
5332+ let dummyNode ;
5333+ if ( group . isCharacterBox ) {
5334+ dummyNode = new MathNode ( 'mspace' , [ ] ) ;
5335+ dummyNode . setAttribute ( 'height' , "1em" ) ;
5336+ } else {
5337+ // Create a phantom node with the same content as the body.
5338+ const inner = buildGroup$1 ( group . body , style ) ;
5339+ // The phantom node will be zero-width, so it won't affect horizontal spacing.
5340+ const zeroWidthNode = new MathNode ( "mpadded" , [ inner ] ) ;
5341+ zeroWidthNode . setAttribute ( "width" , "0.1px" ) ; // Don't use 0. WebKit would omit it.
5342+ dummyNode = new MathNode ( "mphantom" , [ zeroWidthNode ] ) ; // Hide it.
5343+ }
5344+ const toNode = buildGroup$1 ( group . to , style ) ;
5345+ const zeroWidthToNode = new MathNode ( "mpadded" , [ toNode ] ) ;
5346+ if ( ! group . isCharacterBox || / [ f ∫ ∑ ] / . test ( group . body . body [ 0 ] . text ) ) {
5347+ const w = new MathNode ( "mspace" , [ ] ) ;
5348+ w . setAttribute ( 'width' , "0.2em" ) ;
5349+ zeroWidthToNode . children . unshift ( w ) ;
5350+ }
5351+ zeroWidthToNode . setAttribute ( "width" , "0.1px" ) ; // Don't use 0. WebKit would hide it.
5352+ const mover = new MathNode ( "mover" , [ dummyNode , zeroWidthToNode ] ) ;
5353+ // Fix Firefox positioning.
5354+ const nudgeLeft = new MathNode ( 'mrow' , [ ] , [ "ff-nudge-left" ] ) ;
5355+ return newDocumentFragment ( [ makeRow ( [ node , mover ] ) , nudgeLeft ] )
5356+ }
5357+ } ) ;
5358+
52845359 // \@char is an internal function that takes a grouped decimal argument like
52855360 // {123} and converts into symbol with code 123. It is used by the *macro*
52865361 // \char defined in macros.js.
@@ -6207,8 +6282,10 @@ var temml = (function () {
62076282 }
62086283 } ) ;
62096284
6285+ const boxTags = [ "\\boxed" , "\\fcolorbox" , "\\colorbox" ] ;
6286+
62106287 const mathmlBuilder$7 = ( group , style ) => {
6211- const tag = group . label === "\\boxed" ? "mrow" : "menclose" ;
6288+ const tag = boxTags . includes ( group . label ) ? "mrow" : "menclose" ;
62126289 const node = new MathNode ( tag , [ buildGroup$1 ( group . body , style ) ] ) ;
62136290 switch ( group . label ) {
62146291 case "\\overline" :
@@ -6235,6 +6312,7 @@ var temml = (function () {
62356312 node . setAttribute ( "notation" , "updiagonalstrike downdiagonalstrike" ) ;
62366313 node . classes . push ( "tml-xcancel" ) ;
62376314 break
6315+ // cancelto is handled in cancelto.js
62386316 case "\\longdiv" :
62396317 node . setAttribute ( "notation" , "longdiv" ) ;
62406318 node . classes . push ( "longdiv-top" ) ;
@@ -6267,13 +6345,8 @@ var temml = (function () {
62676345 break
62686346 case "\\fcolorbox" :
62696347 case "\\colorbox" : {
6270- // <menclose> doesn't have a good notation option for \colorbox.
6271- // So use <mpadded> instead. Set some attributes that come
6272- // included with <menclose>.
6273- //const fboxsep = 3; // 3 pt from LaTeX source2e
6274- //node.setAttribute("height", `+${2 * fboxsep}pt`)
6275- //node.setAttribute("voffset", `${fboxsep}pt`)
6276- node . style . padding = "3pt" ;
6348+ // Don't use <menclose>. WebKit would show a radical.
6349+ node . style . padding = "0.3em" ; // 3 pt from LaTeX source2e for a 10pt font
62776350 if ( group . label === "\\fcolorbox" ) {
62786351 node . style . border = "0.0667em solid " + String ( group . borderColor ) ;
62796352 }
@@ -7042,16 +7115,16 @@ var temml = (function () {
70427115 ] ) ;
70437116 } ;
70447117
7045- // Horizontal stretchy braces
7118+ // Horizontal stretchy brackets
70467119 defineFunction ( {
7047- type : "horizBrace " ,
7048- names : [ "\\overbrace" , "\\underbrace" ] ,
7120+ type : "horizBracket " ,
7121+ names : [ "\\overbrace" , "\\underbrace" , "\\overbracket" , "\\underbracket" ] ,
70497122 props : {
70507123 numArgs : 1
70517124 } ,
70527125 handler ( { parser, funcName } , args ) {
70537126 return {
7054- type : "horizBrace " ,
7127+ type : "horizBracket " ,
70557128 mode : parser . mode ,
70567129 label : funcName ,
70577130 isOver : / ^ \\ o v e r / . test ( funcName ) ,
@@ -8207,7 +8280,8 @@ var temml = (function () {
82078280 "\u2a1a"
82088281 ] ,
82098282 props : {
8210- numArgs : 0
8283+ numArgs : 0 ,
8284+ allowedInArgument : true
82118285 } ,
82128286 handler ( { parser, funcName } ) {
82138287 let fName = funcName ;
@@ -8947,18 +9021,18 @@ var temml = (function () {
89479021 defineFunctionBuilders ( {
89489022 type : "supsub" ,
89499023 mathmlBuilder ( group , style ) {
8950- // Is the inner group a relevant horizontal brace?
8951- let isBrace = false ;
9024+ // Is the inner group a relevant horizontal brace or bracket ?
9025+ let isBracket = false ;
89529026 let isOver ;
89539027 let isSup ;
89549028 let appendApplyFunction = false ;
89559029 let appendSpace = false ;
89569030 let needsLeadingSpace = false ;
89579031
8958- if ( group . base && group . base . type === "horizBrace " ) {
9032+ if ( group . base && group . base . type === "horizBracket " ) {
89599033 isSup = ! ! group . sup ;
89609034 if ( isSup === group . base . isOver ) {
8961- isBrace = true ;
9035+ isBracket = true ;
89629036 isOver = group . base . isOver ;
89639037 }
89649038 }
@@ -9006,7 +9080,7 @@ var temml = (function () {
90069080 }
90079081
90089082 let nodeType ;
9009- if ( isBrace ) {
9083+ if ( isBracket ) {
90109084 nodeType = isOver ? "mover" : "munder" ;
90119085 } else if ( ! group . sub ) {
90129086 const base = group . base ;
@@ -12076,7 +12150,7 @@ var temml = (function () {
1207612150 * https://mit-license.org/
1207712151 */
1207812152
12079- const version = "0.12.01 " ;
12153+ const version = "0.12.02 " ;
1208012154
1208112155 function postProcess ( block ) {
1208212156 const labelMap = { } ;
0 commit comments