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

Don't process escaped characters in a11y and menu extensions. mathjax/MathJax#2327. #438

Merged
merged 1 commit into from
Mar 30, 2020
Merged
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 ts/a11y/assistive-mml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function AssistiveMmlMathItemMixin<N, T, D, B extends Constructor<Abstrac
* @param {MathDocument} document The MathDocument for the MathItem
*/
public assistiveMml(document: AssistiveMmlMathDocument<N, T, D>) {
if (this.state() >= STATE.ASSISTIVEMML) return;
if (this.state() >= STATE.ASSISTIVEMML || this.isEscaped) return;
this.state(STATE.ASSISTIVEMML);
const adaptor = document.adaptor;
//
Expand Down
2 changes: 1 addition & 1 deletion ts/a11y/complexity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function ComplexityMathItemMixin<N, T, D, B extends Constructor<EnrichedM
* @param {ComplexityMathDocument} docuemnt The MathDocument for the MathItem
*/
public complexity(document: ComplexityMathDocument<N, T, D>) {
if (this.state() < STATE.COMPLEXITY) {
if (this.state() < STATE.COMPLEXITY && !this.isEscaped) {
this.enrich(document);
computeComplexity(this.root);
this.state(STATE.COMPLEXITY);
Expand Down
2 changes: 1 addition & 1 deletion ts/a11y/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function ExplorerMathItemMixin<B extends Constructor<HTMLMATHITEM>>(
* @param {HTMLDocument} document The MathDocument for the MathItem
*/
public explorable(document: ExplorerMathDocument) {
if (this.state() >= STATE.EXPLORER) return;
if (this.state() >= STATE.EXPLORER || this.isEscaped) return;
const node = this.typesetRoot;
const mml = toMathML(this.root);
if (this.savedId) {
Expand Down
2 changes: 1 addition & 1 deletion ts/a11y/semantic-enrich.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function EnrichedMathItemMixin<N, T, D, B extends Constructor<AbstractMat
* @param {MathDocument} document The MathDocument for the MathItem
*/
public enrich(document: MathDocument<N, T, D>) {
if (this.state() >= STATE.ENRICHED) return;
if (this.state() >= STATE.ENRICHED || this.isEscaped) return;
if (typeof sre === 'undefined' || !sre.Engine.isReady()) {
mathjax.retryAfter(sreReady);
}
Expand Down
13 changes: 11 additions & 2 deletions ts/core/MathItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ export interface MathItem<N, T, D> {
*/
display: boolean;

/**
* Whether this item is an escaped character or not
*/
isEscaped: boolean;

/**
* The start and ending locations in the document of
* this expression
Expand Down Expand Up @@ -271,6 +276,10 @@ export abstract class AbstractMathItem<N, T, D> implements MathItem<N, T, D> {
public inputData: OptionList = {};
public outputData: OptionList = {};

public get isEscaped() {
return this.display === null;
}

/**
* @param {string} math The math expression for this item
* @param {Inputjax} jax The input jax to use for this item
Expand Down Expand Up @@ -315,7 +324,7 @@ export abstract class AbstractMathItem<N, T, D> implements MathItem<N, T, D> {
/**
* @override
*/
convert(document: MathDocument<N, T, D>, end: number = STATE.LAST) {
public convert(document: MathDocument<N, T, D>, end: number = STATE.LAST) {
document.renderActions.renderConvert(this, document, end);
}

Expand All @@ -334,7 +343,7 @@ export abstract class AbstractMathItem<N, T, D> implements MathItem<N, T, D> {
*/
public typeset(document: MathDocument<N, T, D>) {
if (this.state() < STATE.TYPESET) {
this.typesetRoot = document.outputJax[this.display === null ? 'escaped' : 'typeset'](this, document);
this.typesetRoot = document.outputJax[this.isEscaped ? 'escaped' : 'typeset'](this, document);
this.state(STATE.TYPESET);
}
}
Expand Down
2 changes: 1 addition & 1 deletion ts/ui/menu/MenuHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export function MenuMathItemMixin<B extends A11yMathItemConstructor>(
* @param {MenuMathDocument} document The document where the menu is being added
*/
public addMenu(document: MenuMathDocument) {
if (this.state() < STATE.CONTEXT_MENU) {
if (this.state() < STATE.CONTEXT_MENU && !this.isEscaped) {
document.menu.addMenu(this);
this.state(STATE.CONTEXT_MENU);
}
Expand Down