diff --git a/testsuite/tests/input/tex/Base.test.ts b/testsuite/tests/input/tex/Base.test.ts index 7b70ffabe..90b91edd7 100644 --- a/testsuite/tests/input/tex/Base.test.ts +++ b/testsuite/tests/input/tex/Base.test.ts @@ -2503,7 +2503,7 @@ describe('MmlToken', () => { it('Token Invalid Attribute', () => { expectTexError('\\mmlToken{mi}[m1=true]{}') - .toBe('Invalid MathML attribute: m1=true'); + .toBe('Invalid MathML attribute: m1'); }); /********************************************************************************/ diff --git a/testsuite/tests/input/tex/Noerrors.test.ts b/testsuite/tests/input/tex/Noerrors.test.ts index dfc87d3d3..ddadeef37 100644 --- a/testsuite/tests/input/tex/Noerrors.test.ts +++ b/testsuite/tests/input/tex/Noerrors.test.ts @@ -288,7 +288,7 @@ describe('NoError', () => { toXmlMatch( tex2mml('\\mmlToken{mi}[m1=true]{}'), ` - + \\mmlToken{mi}[m1=true]{} ` diff --git a/ts/adaptors/HTMLAdaptor.ts b/ts/adaptors/HTMLAdaptor.ts index c1a9d68dc..b5d4799df 100644 --- a/ts/adaptors/HTMLAdaptor.ts +++ b/ts/adaptors/HTMLAdaptor.ts @@ -463,6 +463,9 @@ export class HTMLAdaptor< */ public setAttribute(node: N, name: string, value: string, ns: string = null) { if (!ns) { + if (name === 'style') { + value = value.replace(/\n/g, ' '); + } return node.setAttribute(name, value); } name = ns.replace(/.*\//, '') + ':' + name.replace(/^.*:/, ''); @@ -538,14 +541,14 @@ export class HTMLAdaptor< * @override */ public setStyle(node: N, name: string, value: string) { - (node.style as OptionList)[name] = value; + node.style[name] = String(value).replace(/\n/g, ' '); } /** * @override */ public getStyle(node: N, name: string) { - return (node.style as OptionList)[name]; + return node.style[name]; } /** diff --git a/ts/input/tex/base/BaseMethods.ts b/ts/input/tex/base/BaseMethods.ts index 206452de8..88e1c73e3 100644 --- a/ts/input/tex/base/BaseMethods.ts +++ b/ts/input/tex/base/BaseMethods.ts @@ -1089,14 +1089,14 @@ const BaseMethods: { [key: string]: ParseMethod } = { } while (attr !== '') { const match = attr.match( - /^([a-z]+)\s*=\s*('[^']*'|"[^"]*"|[^ ,]*)\s*,?\s*/i + /^([a-z]+)\s*=\s*('[^'\n]*'|"[^"\n]*"|[^ ,\n]*)[\s\n]*,?[\s\n]*/i ); if (!match) { // @test Token Invalid Attribute throw new TexError( 'InvalidMathMLAttr', 'Invalid MathML attribute: %1', - attr + attr.split(/[\s\n=]/)[0] ); } if (!node.attributes.hasDefault(match[1]) && !MmlTokenAllow[match[1]]) { diff --git a/ts/util/Styles.ts b/ts/util/Styles.ts index 63042926b..13905e355 100644 --- a/ts/util/Styles.ts +++ b/ts/util/Styles.ts @@ -56,7 +56,7 @@ export const WSC = ['width', 'style', 'color']; * @returns {string[]} Array of parts of the style (separated by spaces) */ function splitSpaces(text: string): string[] { - const parts = text.split(/((?:'[^']*'|"[^"]*"|,[\s\n]|[^\s\n])*)/g); + const parts = text.split(/((?:'[^'\n]*'|"[^"\n]*"|,[\s\n]|[^\s\n])*)/g); const split = [] as string[]; while (parts.length > 1) { parts.shift();