Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • M MathJax
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 304
    • Issues 304
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 15
    • Merge requests 15
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • MathJax
  • MathJax
  • Merge requests
  • !1551
Something went wrong while fetching comments. Please try again.

Allow <wbr> in TeX code (just like <br>). #1087

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Davide P. Cervone requested to merge github/fork/dpvc/issue1087 into develop 9 years ago
  • Overview 2
  • Commits 2
  • Pipelines 0
  • Changes 2

Add <wbr> as an ignored tag, and change to a list of ones to ignore. Cache the math.nextSibling node. Remove msieNewlineBug and fold that into the ignoreTags hash. Resolves issue #1087 (closed).

Compare
  • develop (base)

and
  • latest version
    7b98391a
    2 commits, 2 years ago

2 files
+ 41
- 31

    Preferences

    File browser
    Compare changes
unpacked/‎extensions‎
asciimat‎h2jax.js‎ +20 -15
tex2j‎ax.js‎ +21 -16
unpacked/extensions/asciimath2jax.js
+ 20
- 15
  • View file @ 7b98391a

  • Edit in single-file editor

  • Open in Web IDE


@@ -48,12 +48,21 @@ MathJax.Extension.asciimath2jax = {
// are ignored. Note that this is a regular expression,
// so be sure to quote any regexp special characters
preview: "AsciiMath" // set to "none" to not insert MathJax_Preview spans
preview: "AsciiMath" // set to "none" to not insert MathJax_Preview spans
// or set to an array specifying an HTML snippet
// to use the same preview for every equation.
},
//
// Tags to ignore when searching for AsciiMath in the page
//
ignoreTags: {
br: (MathJax.Hub.Browser.isMSIE && document.documentMode < 9 ? "\n" : " "),
wbr: "",
"#comment": ""
},
PreProcess: function (element) {
if (!this.configured) {
this.config = MathJax.Hub.CombineConfig("asciimath2jax",this.config);
@@ -132,8 +141,7 @@ MathJax.Extension.asciimath2jax = {
if (this.search.matched) {element = this.encloseMath(element)}
if (element) {
do {prev = element; element = element.nextSibling}
while (element && (element.nodeName.toLowerCase() === 'br' ||
element.nodeName.toLowerCase() === '#comment'));
while (element && this.ignoreTags[element.nodeName.toLowerCase()] != null);
if (!element || element.nodeName !== '#text') {return prev}
}
}
@@ -172,25 +180,24 @@ MathJax.Extension.asciimath2jax = {
},
encloseMath: function (element) {
var search = this.search, close = search.close, CLOSE, math;
var search = this.search, close = search.close, CLOSE, math, next;
if (search.cpos === close.length) {close = close.nextSibling}
else {close = close.splitText(search.cpos)}
if (!close) {CLOSE = close = MathJax.HTML.addText(search.close.parentNode,"")}
search.close = close;
math = (search.opos ? search.open.splitText(search.opos) : search.open);
while (math.nextSibling && math.nextSibling !== close) {
if (math.nextSibling.nodeValue !== null) {
if (math.nextSibling.nodeName === "#comment") {
math.nodeValue += math.nextSibling.nodeValue.replace(/^\[CDATA\[((.|\n|\r)*)\]\]$/,"$1");
while ((next = math.nextSibling) && next !== close) {
if (next.nodeValue !== null) {
if (next.nodeName === "#comment") {
math.nodeValue += next.nodeValue.replace(/^\[CDATA\[((.|\n|\r)*)\]\]$/,"$1");
} else {
math.nodeValue += math.nextSibling.nodeValue;
}
} else if (this.msieNewlineBug) {
math.nodeValue += (math.nextSibling.nodeName.toLowerCase() === "br" ? "\n" : " ");
} else {
math.nodeValue += " ";
var ignore = this.ignoreTags[next.nodeName.toLowerCase()];
math.nodeValue += (ignore == null ? " " : ignore);
}
math.parentNode.removeChild(math.nextSibling);
math.parentNode.removeChild(next);
}
var AM = math.nodeValue.substr(search.olen,math.nodeValue.length-search.olen-search.clen);
math.parentNode.removeChild(math);
@@ -224,9 +231,7 @@ MathJax.Extension.asciimath2jax = {
return script;
},
filterPreview: function (asciimath) {return asciimath},
msieNewlineBug: (MathJax.Hub.Browser.isMSIE && (document.documentMode||0) < 9)
filterPreview: function (asciimath) {return asciimath}
};
unpacked/extensions/tex2jax.js
+ 21
- 16
  • View file @ 7b98391a

  • Edit in single-file editor

  • Open in Web IDE


@@ -72,6 +72,15 @@ MathJax.Extension.tex2jax = {
},
//
// Tags to ignore when searching for TeX in the page
//
ignoreTags: {
br: (MathJax.Hub.Browser.isMSIE && document.documentMode < 9 ? "\n" : " "),
wbr: "",
"#comment": ""
},
PreProcess: function (element) {
if (!this.configured) {
this.config = MathJax.Hub.CombineConfig("tex2jax",this.config);
@@ -164,8 +173,7 @@ MathJax.Extension.tex2jax = {
if (this.search.matched) {element = this.encloseMath(element)}
if (element) {
do {prev = element; element = element.nextSibling}
while (element && (element.nodeName.toLowerCase() === 'br' ||
element.nodeName.toLowerCase() === '#comment'));
while (element && this.ignoreTags[element.nodeName.toLowerCase()] != null);
if (!element || element.nodeName !== '#text')
{return (this.search.close ? this.prevEndMatch() : prev)}
}
@@ -242,25 +250,24 @@ MathJax.Extension.tex2jax = {
},
encloseMath: function (element) {
var search = this.search, close = search.close, CLOSE, math;
var search = this.search, close = search.close, CLOSE, math, next;
if (search.cpos === close.length) {close = close.nextSibling}
else {close = close.splitText(search.cpos)}
if (!close) {CLOSE = close = MathJax.HTML.addText(search.close.parentNode,"")}
search.close = close;
math = (search.opos ? search.open.splitText(search.opos) : search.open);
while (math.nextSibling && math.nextSibling !== close) {
if (math.nextSibling.nodeValue !== null) {
if (math.nextSibling.nodeName === "#comment") {
math.nodeValue += math.nextSibling.nodeValue.replace(/^\[CDATA\[((.|\n|\r)*)\]\]$/,"$1");
while ((next = math.nextSibling) && next !== close) {
if (next.nodeValue !== null) {
if (next.nodeName === "#comment") {
math.nodeValue += next.nodeValue.replace(/^\[CDATA\[((.|\n|\r)*)\]\]$/,"$1");
} else {
math.nodeValue += math.nextSibling.nodeValue;
math.nodeValue += next.nodeValue;
}
} else if (this.msieNewlineBug) {
math.nodeValue += (math.nextSibling.nodeName.toLowerCase() === "br" ? "\n" : " ");
} else {
math.nodeValue += " ";
var ignore = this.ignoreTags[next.nodeName.toLowerCase()];
math.nodeValue += (ignore == null ? " " : ignore);
}
math.parentNode.removeChild(math.nextSibling);
math.parentNode.removeChild(next);
}
var TeX = math.nodeValue.substr(search.olen,math.nodeValue.length-search.olen-search.clen);
math.parentNode.removeChild(math);
@@ -294,10 +301,8 @@ MathJax.Extension.tex2jax = {
return script;
},
filterPreview: function (tex) {return tex},
msieNewlineBug: (MathJax.Hub.Browser.isMSIE && document.documentMode < 9)
filterPreview: function (tex) {return tex}
};
// We register the preprocessors with the following priorities:
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
MathJax v2.7.0
MathJax v2.7.0
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
3
3 participants
Administrator
Volker Sorge
Davide P. Cervone
Reference: mathjax/MathJax!1551
Source branch: github/fork/dpvc/issue1087

Menu

Explore Projects Groups Snippets