Skip to content

Commit

Permalink
Adjust code in mj postprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
linev committed Jan 16, 2025
1 parent 2e2d5dc commit 4a9c865
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions modules/base/ObjectPainter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1044,9 +1044,9 @@ class ObjectPainter extends BasePainter {
}

all_args.forEach(arg => {
if (arg.mj_node && arg.applyAttributesToMathJax) {
if (arg.mj_node && arg.mj_func) {
const svg = arg.mj_node.select('svg'); // MathJax svg
arg.applyAttributesToMathJax(this, arg.mj_node, svg, arg, font_size, f);
arg.mj_func(this, arg.mj_node, svg, arg, font_size, f);
delete arg.mj_node; // remove reference
only_text = false;
} else if (arg.txt_g)
Expand Down
6 changes: 2 additions & 4 deletions modules/base/latex.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ function applyAttributesToMathJax(painter, mj_node, svg, arg, font_size, svg_fac

if (isNodeJs()) {
// workaround for NaN in viewBox produced by MathJax
let vb = svg.attr('viewBox');
const vb = svg.attr('viewBox');
if (isStr(vb) && vb.indexOf('NaN') > 0)
svg.attr('viewBox', vb.replaceAll('NaN', '600'));
// console.log('Problematic viewBox', vb, svg.select('text').node()?.innerHTML);
Expand Down Expand Up @@ -1490,8 +1490,6 @@ function applyAttributesToMathJax(painter, mj_node, svg, arg, font_size, svg_fac
if (arg.rotate)
trans += `${trans?' ':''}rotate(${arg.rotate})`;



mj_node.attr('transform', trans || null).attr('visibility', null);
}

Expand All @@ -1511,7 +1509,7 @@ async function produceMathjax(painter, mj_node, arg) {

repairMathJaxSvgSize(painter, mj_node, svg, arg);

arg.applyAttributesToMathJax = applyAttributesToMathJax;
arg.mj_func = applyAttributesToMathJax;
return true;
});
}
Expand Down

0 comments on commit 4a9c865

Please sign in to comment.