@@ -27,6 +27,7 @@ import TexParser from '../TexParser.js';
2727import { TexConstant } from '../TexConstants.js' ;
2828import { CommandMap } from '../SymbolMap.js' ;
2929import { ParseMethod } from '../Types.js' ;
30+ import ParseUtil from '../ParseUtil.js' ;
3031
3132
3233/**
@@ -41,27 +42,6 @@ const ALLOWED: {[key: string]: number} = {
4142} ;
4243
4344
44- /**
45- * Rewrites tex parameter string into allowable attributes list.
46- * @param {any } def
47- * @param {string } attrib
48- */
49- function setAttributes ( def : any , attrib : string ) {
50- if ( attrib !== '' ) {
51- const attr = attrib . replace ( / / g, '' ) . split ( / , / ) ;
52- for ( let i = 0 , m = attr . length ; i < m ; i ++ ) {
53- const keyvalue = attr [ i ] . split ( / [: = ] / ) ;
54- if ( ALLOWED [ keyvalue [ 0 ] ] ) {
55- let value = keyvalue [ 1 ] ;
56- def [ keyvalue [ 0 ] ] = ( value === 'true' ) ? true :
57- ( value === 'false' ) ? false : value ;
58- }
59- }
60- }
61- return def ;
62- } ;
63-
64-
6545// Namespace
6646export let CancelMethods : Record < string , ParseMethod > = { } ;
6747
@@ -75,7 +55,8 @@ export let CancelMethods: Record<string, ParseMethod> = {};
7555CancelMethods . Cancel = function ( parser : TexParser , name : string , notation : string ) {
7656 const attr = parser . GetBrackets ( name , '' ) ;
7757 const math = parser . ParseArg ( name ) ;
78- const def = setAttributes ( { notation : notation } , attr ) ;
58+ const def = ParseUtil . splitPackageOptions ( attr , ALLOWED ) ;
59+ def [ 'notation' ] = notation ;
7960 parser . Push ( parser . create ( 'node' , 'menclose' , [ math ] , def ) ) ;
8061} ;
8162
@@ -87,13 +68,13 @@ CancelMethods.Cancel = function(parser: TexParser, name: string, notation: strin
8768 * @param {string } notation The type of cancel notation to use.
8869 */
8970
90- CancelMethods . CancelTo = function ( parser : TexParser , name : string , notation : string ) {
91- let value = parser . ParseArg ( name ) ;
71+ CancelMethods . CancelTo = function ( parser : TexParser , name : string ) {
9272 const attr = parser . GetBrackets ( name , '' ) ;
73+ let value = parser . ParseArg ( name ) ;
9374 const math = parser . ParseArg ( name ) ;
94- const def = setAttributes (
95- { notation : TexConstant . Notation . UPDIAGONALSTRIKE + ' ' +
96- TexConstant . Notation . UPDIAGONALARROW } , attr ) ;
75+ const def = ParseUtil . splitPackageOptions ( attr , ALLOWED ) ;
76+ def [ ' notation' ] = TexConstant . Notation . UPDIAGONALSTRIKE + ' ' +
77+ TexConstant . Notation . UPDIAGONALARROW ;
9778 value = parser . create ( 'node' , 'mpadded' , [ value ] ,
9879 { depth : '-.1em' , height : ' + .1em' , voffset : '.1em' } ) ;
9980 parser . Push ( parser . create ( 'node' , 'msup' ,
0 commit comments