Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion testsuite/tests/input/tex/Base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

/********************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/input/tex/Noerrors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ describe('NoError', () => {
toXmlMatch(
tex2mml('\\mmlToken{mi}[m1=true]{}'),
`<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\mmlToken{mi}[m1=true]{}" display="block">
<merror data-mjx-error="Invalid MathML attribute: m1=true" title="Invalid MathML attribute: m1=true">
<merror data-mjx-error="Invalid MathML attribute: m1" title="Invalid MathML attribute: m1">
<mtext>\\mmlToken{mi}[m1=true]{}</mtext>
</merror>
</math>`
Expand Down
7 changes: 5 additions & 2 deletions ts/adaptors/HTMLAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(/^.*:/, '');
Expand Down Expand Up @@ -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];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions ts/input/tex/base/BaseMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]]) {
Expand Down
2 changes: 1 addition & 1 deletion ts/util/Styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down