Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ids from assistive MathML to avoid duplicates #525

Merged
merged 1 commit into from
Jul 16, 2020
Merged
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
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