Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
const renderMath: RenderMath = (math, doc) => {
const { start, end, bbox, math: latex } = math;
return
}
//
// The renderActions needed to remove the data-semantic-attributes.
// STATE.ENRICHED is the priority of the enrichment, so this will rung just after enrichment.
// The first function is the one for when the document's render() method is called.
// The second is for when a MathItem's render(), rerender() or convert() method is called.
//
export const speechAction = {
simplfy: [
STATE.TYPESET + 1,
(doc) => {
console.log('m1')
for (const math of doc.math) {
//removeSemanticData(math);
}
},
renderMath
]
};
constructor(options: MathToSVGConfig) {
this.options = options;
//
// Create DOM adaptor and register it for HTML documents
//
const adaptor = liteAdaptor();
const htmlHander = RegisterHTMLHandler(adaptor);
//EnrichHandler(htmlHander, new MathML());
//
// Create input and output jax and a document using them on the content from the HTML file
//
this.tex = new TeX({ packages: options.packages });
this.svg = new SVG({
fontCache: (options.fontCache ? 'local' : 'none'),
internalSpeechTitles: true
});
this.html = mathjax.document('', {
InputJax: this.tex,
OutputJax: this.svg
//enrichSpeech: options.enrichSpeech
require('mathjax-full/js/util/asyncLoad/node.js');
require('mathjax-full/js/a11y/semantic-enrich.js');
const STATE = require('mathjax-full/js/core/MathItem.js').STATE;
//
// Remove the data-semantic-* attributes other than data-semantic-speech
//
function removeSemanticData(math) {
math.root.walkTree(node => {
const attributes = node.attributes.getAllAttributes();
delete attributes.xmlns; // some internal nodes get this attribute for some reason
for (const name of Object.keys(attributes)) {
if (name.substr(0, 14) === 'data-semantic-' && name !== 'data-semantic-speech') {
delete attributes[name];
}
}
});
}
if (name.substr(0, 14) === 'data-semantic-' && name !== 'data-semantic-speech') {
delete attributes[name];
}
}
});
}
//
// The renderActions needed to remove the data-semantic-attributes.
// STATE.ENRICHED is the priority of the enrichment, so this will rung just after enrichment.
// The first function is the one for when the document's render() method is called.
// The second is for when a MathItem's render(), rerender() or convert() method is called.
//
exports.speechAction = {
simplfy: [
STATE.ENRICHED + 1,
(doc) => {
for (const math of doc.math) {
removeSemanticData(math);
}
},
(math, doc) => {
removeSemanticData(math);
}
]
};
constructor(options: MathToSVGConfig) {
this.options = options;
//
// Create DOM adaptor and register it for HTML documents
//
const adaptor = liteAdaptor();
const htmlHander = RegisterHTMLHandler(adaptor);
//EnrichHandler(htmlHander, new MathML());
//
// Create input and output jax and a document using them on the content from the HTML file
//
this.tex = new TeX({ packages: options.packages });
this.svg = new SVG({
fontCache: (options.fontCache ? 'local' : 'none'),
internalSpeechTitles: true
});
this.html = mathjax.document('', {
InputJax: this.tex,
OutputJax: this.svg
//enrichSpeech: options.enrichSpeech
});
constructor(options: MathToSVGConfig) {
this.options = options;
//
// Create DOM adaptor and register it for HTML documents
//
const adaptor = liteAdaptor();
const htmlHander = RegisterHTMLHandler(adaptor);
//EnrichHandler(htmlHander, new MathML());
//
// Create input and output jax and a document using them on the content from the HTML file
//
this.tex = new TeX({ packages: options.packages });
this.svg = new SVG({
fontCache: (options.fontCache ? 'local' : 'none'),
internalSpeechTitles: true
});
this.html = mathjax.document('', {
InputJax: this.tex,
OutputJax: this.svg
//enrichSpeech: options.enrichSpeech
});
//this.html.addRenderAction('mip', ...speechAction.simplfy);
}
splitMath = _.memoize((math: string) => {
let parser = new TexParser(
math,
{ display: true, isInner: false },
this.parseOptions
);
parser.i = 0; // reset parser
const response = [];
while (parser.i < parser.string.length) {
response.push(parser.GetArgument(math, true))
}
/*
* try to compose bbox
const mathItems = _.map(response, (frag, index, collection) => {
const bip = new HTMLMathItem(frag, this.tex, true);
bip.compile(this.html.document)
bip.bbox = this.svg.getBBox(bip, this.html);
// Create DOM adaptor and register it for HTML documents
//
const adaptor = liteAdaptor();
const htmlHander = RegisterHTMLHandler(adaptor);
//EnrichHandler(htmlHander, new MathML());
//
// Create input and output jax and a document using them on the content from the HTML file
//
this.tex = new TeX({ packages: options.packages });
this.svg = new SVG({
fontCache: (options.fontCache ? 'local' : 'none'),
internalSpeechTitles: true
});
this.html = mathjax.document('', {
InputJax: this.tex,
OutputJax: this.svg
//enrichSpeech: options.enrichSpeech
});
//this.html.addRenderAction('mip', ...speechAction.simplfy);
}
constructor(options: MathToSVGConfig) {
this.options = options;
//
// Create DOM adaptor and register it for HTML documents
//
const adaptor = liteAdaptor();
const htmlHander = RegisterHTMLHandler(adaptor);
//EnrichHandler(htmlHander, new MathML());
//
// Create input and output jax and a document using them on the content from the HTML file
//
this.tex = new TeX({ packages: options.packages });
this.svg = new SVG({
fontCache: (options.fontCache ? 'local' : 'none'),
internalSpeechTitles: true
});
this.html = mathjax.document('', {
InputJax: this.tex,
OutputJax: this.svg
//enrichSpeech: options.enrichSpeech
});
//this.html.addRenderAction('mip', ...speechAction.simplfy);
}