Skip to content

Commit

Permalink
Merge pull request #525 from mathjax/assistive-mml-ids
Browse files Browse the repository at this point in the history
Remove ids from assistive MathML to avoid duplicates
  • Loading branch information
dpvc authored Jul 16, 2020
2 parents a8feac3 + 09737ff commit ce4ab81
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions ts/a11y/assistive-mml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ import {SerializedMmlVisitor} from '../core/MmlTree/SerializedMmlVisitor.js';
import {OptionList, expandable} from '../util/Options.js';
import {StyleList} from '../util/StyleList.js';

/*==========================================================================*/

export class LimitedMmlVisitor extends SerializedMmlVisitor {

/**
* @override
*/
protected getAttributes(node: MmlNode): string {
/**
* Remove id from attribute output
*/
return super.getAttributes(node).replace(/ ?id=".*?"/, '');
}

}

/**
* Generic constructor for Mixins
*/
Expand Down Expand Up @@ -198,7 +214,7 @@ B extends MathDocumentConstructor<AbstractMathDocument<N, T, D>>>(
/**
* Visitor used for serializing internal MathML nodes
*/
protected visitor: SerializedMmlVisitor;
protected visitor: LimitedMmlVisitor;

/**
* Augment the MathItem class used for this MathDocument, and create the serialization visitor.
Expand All @@ -213,7 +229,7 @@ B extends MathDocumentConstructor<AbstractMathDocument<N, T, D>>>(
if (!ProcessBits.has('assistive-mml')) {
ProcessBits.allocate('assistive-mml');
}
this.visitor = new SerializedMmlVisitor(this.mmlFactory);
this.visitor = new LimitedMmlVisitor(this.mmlFactory);
this.options.MathItem =
AssistiveMmlMathItemMixin<N, T, D, Constructor<AbstractMathItem<N, T, D>>>(
this.options.MathItem
Expand Down

0 comments on commit ce4ab81

Please sign in to comment.