Skip to content

Commit

Permalink
Make sure explicit attributes added by \mmlToken are not removed, eve…
Browse files Browse the repository at this point in the history
…n if they equal the defaults. (mathjax/MathJax#2806)
  • Loading branch information
dpvc committed Jan 18, 2022
1 parent 6b38558 commit ecb740e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ts/input/tex/FilterUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ namespace FilterUtil {
if (!attribs) {
return;
}
const keep = new Set((attribs.get('mjx-keep-attrs') || '').split(/ /));
delete (attribs.getAllAttributes())['mjx-keep-attrs'];
for (const key of attribs.getExplicitNames()) {
if (attribs.attributes[key] === mml.attributes.getInherited(key)) {
if (!keep.has(key) && attribs.attributes[key] === mml.attributes.getInherited(key)) {
delete attribs.attributes[key];
}
}
Expand Down
5 changes: 5 additions & 0 deletions ts/input/tex/base/BaseMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ BaseMethods.MmlToken = function(parser: TexParser, name: string) {
let attr = parser.GetBrackets(name, '').replace(/^\s+/, '');
const text = parser.GetArgument(name);
const def: EnvList = {};
const keep: string[] = [];
let node: MmlNode;
try {
node = parser.create('node', kind);
Expand Down Expand Up @@ -738,9 +739,13 @@ BaseMethods.MmlToken = function(parser: TexParser, name: string) {
value = false;
}
def[match[1]] = value;
keep.push(match[1]);
}
attr = attr.substr(match[0].length);
}
if (keep.length) {
def['mjx-keep-attrs'] = keep.join(' ');
}
const textNode = parser.create('text', text);
node.appendChild(textNode);
NodeUtil.setProperties(node, def);
Expand Down

0 comments on commit ecb740e

Please sign in to comment.