Merge branch 'AsciiMath' into v2.0-candidate
This commit is contained in:
commit
5422dda7a1
|
@ -299,6 +299,71 @@ MathJax.Hub.Config({
|
|||
|
||||
},
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// These parameters control the asciimath2jax preprocessor (when you have included
|
||||
// "asciimath2jax.js" in the extensions list above).
|
||||
//
|
||||
asciimath2jax: {
|
||||
|
||||
//
|
||||
// The delimiters that surround asciimath expressions. The first in each
|
||||
// pair is the initial delimiter and the second is the terminal delimiter.
|
||||
//
|
||||
delimiters: [
|
||||
['`','`']
|
||||
],
|
||||
|
||||
//
|
||||
// This array lists the names of the tags whose contents should not be
|
||||
// processed by asciimath2jax (other than to look for ignore/process classes
|
||||
// as listed below). You can add to (or remove from) this list to prevent
|
||||
// MathJax from processing mathematics in specific contexts.
|
||||
//
|
||||
skipTags: ["script","noscript","style","textarea","pre","code"],
|
||||
|
||||
//
|
||||
// This is the class name used to mark elements whose contents should
|
||||
// not be processed by asciimath2jax (other than to look for the
|
||||
// processClass pattern below). Note that this is a regular
|
||||
// expression, and so you need to be sure to quote any regexp special
|
||||
// characters. The pattern is automatically preceeded by '(^| )(' and
|
||||
// followed by ')( |$)', so your pattern will have to match full words
|
||||
// in the class name. Assigning an element this class name will
|
||||
// prevent `asciimath2jax` from processing its contents.
|
||||
//
|
||||
ignoreClass: "asciimath2jax_ignore",
|
||||
|
||||
//
|
||||
// This is the class name used to mark elements whose contents SHOULD
|
||||
// be processed by asciimath2jax. This is used to turn on processing
|
||||
// within tags that have been marked as ignored or skipped above.
|
||||
// Note that this is a regular expression, and so you need to be sure
|
||||
// to quote any regexp special characters. The pattern is
|
||||
// automatically preceeded by '(^| )(' and followed by ')( |$)', so
|
||||
// your pattern will have to match full words in the class name. Use
|
||||
// this to restart processing within an element that has been marked
|
||||
// as ignored above.
|
||||
//
|
||||
processClass: "asciimath2jax_process",
|
||||
|
||||
// Controls whether asciimath2jax inserts MathJax_Preview spans to make a
|
||||
// preview available, and what preview to use, when it locates in-line
|
||||
// and display mathetics on the page. The default is "AsciiMath", which
|
||||
// means use the AsciiMath code as the preview (until it is processed by
|
||||
// MathJax). Set to "none" to prevent the previews from being
|
||||
// inserted (the math will simply disappear until it is typeset). Set
|
||||
// to an array containing the description of an HTML snippet in order
|
||||
// to use the same preview for all equations on the page (e.g., you
|
||||
// could have it say "[math]" or load an image).
|
||||
//
|
||||
// E.g., preview: ["[math]"],
|
||||
// or preview: [["img",{src: "http://myserver.com/images/mypic.jpg"}]]
|
||||
//
|
||||
preview: "AsciiMath"
|
||||
|
||||
},
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// These parameters control the mml2jax preprocessor (when you have included
|
||||
|
@ -405,6 +470,27 @@ MathJax.Hub.Config({
|
|||
|
||||
},
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// These parameters control the AsciiMath inupt jax.
|
||||
//
|
||||
AasciiMath: {
|
||||
//
|
||||
// Determines whether limits are placed above and below operators,
|
||||
// or next to them. (AsciiMath doesn't have separate in-line and
|
||||
// display modes like TeX and MathML do, so this is the only control
|
||||
// you have over its output)
|
||||
//
|
||||
displaystyle: true,
|
||||
|
||||
//
|
||||
// The character to use for decimal places when scanning for a number.
|
||||
// If you change it to ,, beware of things like "(1,2)" which would need
|
||||
// to be changed to "(1, 2)" to be parsed correctly.
|
||||
//
|
||||
decimal: "."
|
||||
},
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// These parameters control the MathML inupt jax.
|
||||
|
|
16
extensions/asciimath2jax.js
Normal file
16
extensions/asciimath2jax.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* /MathJax/extensions/asciimath2jax.js
|
||||
*
|
||||
* Copyright (c) 2010 Design Science, Inc.
|
||||
*
|
||||
* Part of the MathJax library.
|
||||
* See http://www.mathjax.org for details.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
MathJax.Extension.asciimath2jax={version:"1.0",config:{delimiters:[["`","`"]],skipTags:["script","noscript","style","textarea","pre","code"],ignoreClass:"asciimath2jax_ignore",processClass:"asciimath2jax_process",preview:"AsciiMath"},PreProcess:function(a){if(!this.configured){this.config=MathJax.Hub.CombineConfig("asciimath2jax",this.config);if(this.config.Augment){MathJax.Hub.Insert(this,this.config.Augment)}this.configured=true}if(typeof(a)==="string"){a=document.getElementById(a)}if(!a){a=document.body}if(this.createPatterns()){this.scanElement(a,a.nextSibling)}},createPatterns:function(){var d=[],c,a,b=this.config;this.match={};if(b.delimiters.length===0){return false}for(c=0,a=b.delimiters.length;c<a;c++){d.push(this.patternQuote(b.delimiters[c][0]));this.match[b.delimiters[c][0]]={mode:"",end:b.delimiters[c][1],pattern:this.endPattern(b.delimiters[c][1])}}this.start=new RegExp(d.sort(this.sortLength).join("|"),"g");this.skipTags=new RegExp("^("+b.skipTags.join("|")+")$","i");this.ignoreClass=new RegExp("(^| )("+b.ignoreClass+")( |$)");this.processClass=new RegExp("(^| )("+b.processClass+")( |$)");return true},patternQuote:function(a){return a.replace(/([\^$(){}+*?\-|\[\]\:\\])/g,"\\$1")},endPattern:function(a){return new RegExp(this.patternQuote(a)+"|\\\\.","g")},sortLength:function(d,c){if(d.length!==c.length){return c.length-d.length}return(d==c?0:(d<c?-1:1))},scanElement:function(c,b,g){var a,e,d,f;while(c&&c!=b){if(c.nodeName.toLowerCase()==="#text"){if(!g){c=this.scanText(c)}}else{a=(typeof(c.className)==="undefined"?"":c.className);e=(typeof(c.tagName)==="undefined"?"":c.tagName);if(typeof(a)!=="string"){a=String(a)}f=this.processClass.exec(a);if(c.firstChild&&!a.match(/(^| )MathJax/)&&(f||!this.skipTags.exec(e))){d=(g||this.ignoreClass.exec(a))&&!f;this.scanElement(c.firstChild,b,d)}}if(c){c=c.nextSibling}}},scanText:function(b){if(b.nodeValue.replace(/\s+/,"")==""){return b}var a,c;this.search={start:true};this.pattern=this.start;while(b){this.pattern.lastIndex=0;while(b&&b.nodeName.toLowerCase()==="#text"&&(a=this.pattern.exec(b.nodeValue))){if(this.search.start){b=this.startMatch(a,b)}else{b=this.endMatch(a,b)}}if(this.search.matched){b=this.encloseMath(b)}if(b){do{c=b;b=b.nextSibling}while(b&&(b.nodeName.toLowerCase()==="br"||b.nodeName.toLowerCase()==="#comment"));if(!b||b.nodeName!=="#text"){return c}}}return b},startMatch:function(a,b){var c=this.match[a[0]];if(c!=null){this.search={end:c.end,mode:c.mode,open:b,olen:a[0].length,opos:this.pattern.lastIndex-a[0].length};this.switchPattern(c.pattern)}return b},endMatch:function(a,b){if(a[0]==this.search.end){this.search.close=b;this.search.cpos=this.pattern.lastIndex;this.search.clen=(this.search.isBeginEnd?0:a[0].length);this.search.matched=true;b=this.encloseMath(b);this.switchPattern(this.start)}return b},switchPattern:function(a){a.lastIndex=this.pattern.lastIndex;this.pattern=a;this.search.start=(a===this.start)},encloseMath:function(b){var a=this.search,f=a.close,e,c;if(a.cpos===f.length){f=f.nextSibling}else{f=f.splitText(a.cpos)}if(!f){e=f=MathJax.HTML.addText(a.close.parentNode,"")}a.close=f;c=(a.opos?a.open.splitText(a.opos):a.open);while(c.nextSibling&&c.nextSibling!==f){if(c.nextSibling.nodeValue!==null){if(c.nextSibling.nodeName==="#comment"){c.nodeValue+=c.nextSibling.nodeValue.replace(/^\[CDATA\[((.|\n|\r)*)\]\]$/,"$1")}else{c.nodeValue+=c.nextSibling.nodeValue}}else{if(this.msieNewlineBug){c.nodeValue+=(c.nextSibling.nodeName.toLowerCase()==="br"?"\n":" ")}else{c.nodeValue+=" "}}c.parentNode.removeChild(c.nextSibling)}var d=c.nodeValue.substr(a.olen,c.nodeValue.length-a.olen-a.clen);c.parentNode.removeChild(c);if(this.config.preview!=="none"){this.createPreview(a.mode,d)}c=this.createMathTag(a.mode,d);this.search={};this.pattern.lastIndex=0;if(e){e.parentNode.removeChild(e)}return c},insertNode:function(b){var a=this.search;a.close.parentNode.insertBefore(b,a.close)},createPreview:function(c,a){var b;if(this.config.preview==="AsciiMath"){b=[this.filterAM(a)]}else{if(this.config.preview instanceof Array){b=this.config.preview}}if(b){b=MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},b);this.insertNode(b)}},createMathTag:function(c,a){var b=document.createElement("script");b.type="math/asciimath"+c;MathJax.HTML.setScript(b,a);this.insertNode(b);return b},filterAM:function(a){return a},msieNewlineBug:(MathJax.Hub.Browser.isMSIE&&(document.documentMode||0)<9)};MathJax.Hub.Register.PreProcessor(["PreProcess",MathJax.Extension.asciimath2jax]);MathJax.Ajax.loadComplete("[MathJax]/extensions/asciimath2jax.js");
|
||||
|
16
jax/input/AsciiMath/config.js
Normal file
16
jax/input/AsciiMath/config.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* /MathJax/jax/input/AsciiMath/config.js
|
||||
*
|
||||
* Copyright (c) 2010 Design Science, Inc.
|
||||
*
|
||||
* Part of the MathJax library.
|
||||
* See http://www.mathjax.org for details.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
MathJax.InputJax.AsciiMath=MathJax.InputJax({id:"AsciiMath",version:"1.0",directory:MathJax.InputJax.directory+"/AsciiMath",extensionDir:MathJax.InputJax.extensionDir+"/AsciiMath",config:{displaystyle:true,decimal:"."}});MathJax.InputJax.AsciiMath.Register("math/asciimath");MathJax.InputJax.AsciiMath.loadComplete("config.js");
|
||||
|
16
jax/input/AsciiMath/jax.js
Normal file
16
jax/input/AsciiMath/jax.js
Normal file
File diff suppressed because one or more lines are too long
|
@ -299,6 +299,71 @@ MathJax.Hub.Config({
|
|||
|
||||
},
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// These parameters control the asciimath2jax preprocessor (when you have included
|
||||
// "asciimath2jax.js" in the extensions list above).
|
||||
//
|
||||
asciimath2jax: {
|
||||
|
||||
//
|
||||
// The delimiters that surround asciimath expressions. The first in each
|
||||
// pair is the initial delimiter and the second is the terminal delimiter.
|
||||
//
|
||||
delimiters: [
|
||||
['`','`']
|
||||
],
|
||||
|
||||
//
|
||||
// This array lists the names of the tags whose contents should not be
|
||||
// processed by asciimath2jax (other than to look for ignore/process classes
|
||||
// as listed below). You can add to (or remove from) this list to prevent
|
||||
// MathJax from processing mathematics in specific contexts.
|
||||
//
|
||||
skipTags: ["script","noscript","style","textarea","pre","code"],
|
||||
|
||||
//
|
||||
// This is the class name used to mark elements whose contents should
|
||||
// not be processed by asciimath2jax (other than to look for the
|
||||
// processClass pattern below). Note that this is a regular
|
||||
// expression, and so you need to be sure to quote any regexp special
|
||||
// characters. The pattern is automatically preceeded by '(^| )(' and
|
||||
// followed by ')( |$)', so your pattern will have to match full words
|
||||
// in the class name. Assigning an element this class name will
|
||||
// prevent `asciimath2jax` from processing its contents.
|
||||
//
|
||||
ignoreClass: "asciimath2jax_ignore",
|
||||
|
||||
//
|
||||
// This is the class name used to mark elements whose contents SHOULD
|
||||
// be processed by asciimath2jax. This is used to turn on processing
|
||||
// within tags that have been marked as ignored or skipped above.
|
||||
// Note that this is a regular expression, and so you need to be sure
|
||||
// to quote any regexp special characters. The pattern is
|
||||
// automatically preceeded by '(^| )(' and followed by ')( |$)', so
|
||||
// your pattern will have to match full words in the class name. Use
|
||||
// this to restart processing within an element that has been marked
|
||||
// as ignored above.
|
||||
//
|
||||
processClass: "asciimath2jax_process",
|
||||
|
||||
// Controls whether asciimath2jax inserts MathJax_Preview spans to make a
|
||||
// preview available, and what preview to use, when it locates in-line
|
||||
// and display mathetics on the page. The default is "AsciiMath", which
|
||||
// means use the AsciiMath code as the preview (until it is processed by
|
||||
// MathJax). Set to "none" to prevent the previews from being
|
||||
// inserted (the math will simply disappear until it is typeset). Set
|
||||
// to an array containing the description of an HTML snippet in order
|
||||
// to use the same preview for all equations on the page (e.g., you
|
||||
// could have it say "[math]" or load an image).
|
||||
//
|
||||
// E.g., preview: ["[math]"],
|
||||
// or preview: [["img",{src: "http://myserver.com/images/mypic.jpg"}]]
|
||||
//
|
||||
preview: "AsciiMath"
|
||||
|
||||
},
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// These parameters control the mml2jax preprocessor (when you have included
|
||||
|
@ -405,6 +470,27 @@ MathJax.Hub.Config({
|
|||
|
||||
},
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// These parameters control the AsciiMath inupt jax.
|
||||
//
|
||||
AasciiMath: {
|
||||
//
|
||||
// Determines whether limits are placed above and below operators,
|
||||
// or next to them. (AsciiMath doesn't have separate in-line and
|
||||
// display modes like TeX and MathML do, so this is the only control
|
||||
// you have over its output)
|
||||
//
|
||||
displaystyle: true,
|
||||
|
||||
//
|
||||
// The character to use for decimal places when scanning for a number.
|
||||
// If you change it to ,, beware of things like "(1,2)" which would need
|
||||
// to be changed to "(1, 2)" to be parsed correctly.
|
||||
//
|
||||
decimal: "."
|
||||
},
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// These parameters control the MathML inupt jax.
|
||||
|
|
228
unpacked/extensions/asciimath2jax.js
Normal file
228
unpacked/extensions/asciimath2jax.js
Normal file
|
@ -0,0 +1,228 @@
|
|||
/*************************************************************
|
||||
*
|
||||
* MathJax/extensions/asciimath2jax.js
|
||||
*
|
||||
* Implements the AsciiMath to Jax preprocessor that locates AsciiMath
|
||||
* code within the text of a document and replaces it with SCRIPT tags for
|
||||
* processing by MathJax.
|
||||
*
|
||||
* Modified by David Lippman, based on tex2jax.js.
|
||||
* Additional work by Davide P. Cervone.
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 2012 Design Science, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
MathJax.Extension.asciimath2jax = {
|
||||
version: "1.0",
|
||||
config: {
|
||||
delimiters: [['`','`']], // The star/stop delimiter pairs for asciimath code
|
||||
|
||||
skipTags: ["script","noscript","style","textarea","pre","code"],
|
||||
// The names of the tags whose contents will not be
|
||||
// scanned for math delimiters
|
||||
|
||||
ignoreClass: "asciimath2jax_ignore", // the class name of elements whose contents should
|
||||
// NOT be processed by asciimath2jax. Note that this
|
||||
// is a regular expression, so be sure to quote any
|
||||
// regexp special characters
|
||||
|
||||
processClass: "asciimath2jax_process", // the class name of elements whose contents SHOULD
|
||||
// be processed when they appear inside ones that
|
||||
// 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
|
||||
// or set to an array specifying an HTML snippet
|
||||
// to use the same preview for every equation.
|
||||
|
||||
},
|
||||
|
||||
PreProcess: function (element) {
|
||||
if (!this.configured) {
|
||||
this.config = MathJax.Hub.CombineConfig("asciimath2jax",this.config);
|
||||
if (this.config.Augment) {MathJax.Hub.Insert(this,this.config.Augment)}
|
||||
this.configured = true;
|
||||
}
|
||||
if (typeof(element) === "string") {element = document.getElementById(element)}
|
||||
if (!element) {element = document.body}
|
||||
if (this.createPatterns()) {this.scanElement(element,element.nextSibling)}
|
||||
},
|
||||
|
||||
createPatterns: function () {
|
||||
var starts = [], i, m, config = this.config; this.match = {};
|
||||
if (config.delimiters.length === 0) {return false}
|
||||
for (i = 0, m = config.delimiters.length; i < m; i++) {
|
||||
starts.push(this.patternQuote(config.delimiters[i][0]));
|
||||
this.match[config.delimiters[i][0]] = {
|
||||
mode: "",
|
||||
end: config.delimiters[i][1],
|
||||
pattern: this.endPattern(config.delimiters[i][1])
|
||||
};
|
||||
}
|
||||
this.start = new RegExp(starts.sort(this.sortLength).join("|"),"g");
|
||||
this.skipTags = new RegExp("^("+config.skipTags.join("|")+")$","i");
|
||||
this.ignoreClass = new RegExp("(^| )("+config.ignoreClass+")( |$)");
|
||||
this.processClass = new RegExp("(^| )("+config.processClass+")( |$)");
|
||||
return true;
|
||||
},
|
||||
|
||||
patternQuote: function (s) {return s.replace(/([\^$(){}+*?\-|\[\]\:\\])/g,'\\$1')},
|
||||
|
||||
endPattern: function (end) {
|
||||
return new RegExp(this.patternQuote(end)+"|\\\\.","g");
|
||||
},
|
||||
|
||||
sortLength: function (a,b) {
|
||||
if (a.length !== b.length) {return b.length - a.length}
|
||||
return (a == b ? 0 : (a < b ? -1 : 1));
|
||||
},
|
||||
|
||||
scanElement: function (element,stop,ignore) {
|
||||
var cname, tname, ignoreChild, process;
|
||||
while (element && element != stop) {
|
||||
if (element.nodeName.toLowerCase() === '#text') {
|
||||
if (!ignore) {element = this.scanText(element)}
|
||||
} else {
|
||||
cname = (typeof(element.className) === "undefined" ? "" : element.className);
|
||||
tname = (typeof(element.tagName) === "undefined" ? "" : element.tagName);
|
||||
if (typeof(cname) !== "string") {cname = String(cname)} // jsxgraph uses non-string class names!
|
||||
process = this.processClass.exec(cname);
|
||||
if (element.firstChild && !cname.match(/(^| )MathJax/) &&
|
||||
(process || !this.skipTags.exec(tname))) {
|
||||
ignoreChild = (ignore || this.ignoreClass.exec(cname)) && !process;
|
||||
this.scanElement(element.firstChild,stop,ignoreChild);
|
||||
}
|
||||
}
|
||||
if (element) {element = element.nextSibling}
|
||||
}
|
||||
},
|
||||
|
||||
scanText: function (element) {
|
||||
if (element.nodeValue.replace(/\s+/,'') == '') {return element}
|
||||
var match, prev;
|
||||
this.search = {start: true};
|
||||
this.pattern = this.start;
|
||||
while (element) {
|
||||
this.pattern.lastIndex = 0;
|
||||
while (element && element.nodeName.toLowerCase() === '#text' &&
|
||||
(match = this.pattern.exec(element.nodeValue))) {
|
||||
if (this.search.start) {element = this.startMatch(match,element)}
|
||||
else {element = this.endMatch(match,element)}
|
||||
}
|
||||
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'));
|
||||
if (!element || element.nodeName !== '#text') {return prev}
|
||||
}
|
||||
}
|
||||
return element;
|
||||
},
|
||||
|
||||
startMatch: function (match,element) {
|
||||
var delim = this.match[match[0]];
|
||||
if (delim != null) {
|
||||
this.search = {
|
||||
end: delim.end, mode: delim.mode,
|
||||
open: element, olen: match[0].length,
|
||||
opos: this.pattern.lastIndex - match[0].length
|
||||
};
|
||||
this.switchPattern(delim.pattern);
|
||||
}
|
||||
return element;
|
||||
},
|
||||
|
||||
endMatch: function (match,element) {
|
||||
if (match[0] == this.search.end) {
|
||||
this.search.close = element;
|
||||
this.search.cpos = this.pattern.lastIndex;
|
||||
this.search.clen = (this.search.isBeginEnd ? 0 : match[0].length);
|
||||
this.search.matched = true;
|
||||
element = this.encloseMath(element);
|
||||
this.switchPattern(this.start);
|
||||
}
|
||||
return element;
|
||||
},
|
||||
|
||||
switchPattern: function (pattern) {
|
||||
pattern.lastIndex = this.pattern.lastIndex;
|
||||
this.pattern = pattern;
|
||||
this.search.start = (pattern === this.start);
|
||||
},
|
||||
|
||||
encloseMath: function (element) {
|
||||
var search = this.search, close = search.close, CLOSE, math;
|
||||
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");
|
||||
} else {
|
||||
math.nodeValue += math.nextSibling.nodeValue;
|
||||
}
|
||||
} else if (this.msieNewlineBug) {
|
||||
math.nodeValue += (math.nextSibling.nodeName.toLowerCase() === "br" ? "\n" : " ");
|
||||
} else {
|
||||
math.nodeValue += " ";
|
||||
}
|
||||
math.parentNode.removeChild(math.nextSibling);
|
||||
}
|
||||
var AM = math.nodeValue.substr(search.olen,math.nodeValue.length-search.olen-search.clen);
|
||||
math.parentNode.removeChild(math);
|
||||
if (this.config.preview !== "none") {this.createPreview(search.mode,AM)}
|
||||
math = this.createMathTag(search.mode,AM);
|
||||
this.search = {}; this.pattern.lastIndex = 0;
|
||||
if (CLOSE) {CLOSE.parentNode.removeChild(CLOSE)}
|
||||
return math;
|
||||
},
|
||||
|
||||
insertNode: function (node) {
|
||||
var search = this.search;
|
||||
search.close.parentNode.insertBefore(node,search.close);
|
||||
},
|
||||
|
||||
createPreview: function (mode,asciimath) {
|
||||
var preview;
|
||||
if (this.config.preview === "AsciiMath") {preview = [this.filterAM(asciimath)]}
|
||||
else if (this.config.preview instanceof Array) {preview = this.config.preview}
|
||||
if (preview) {
|
||||
preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview);
|
||||
this.insertNode(preview);
|
||||
}
|
||||
},
|
||||
|
||||
createMathTag: function (mode,asciimath) {
|
||||
var script = document.createElement("script");
|
||||
script.type = "math/asciimath" + mode;
|
||||
MathJax.HTML.setScript(script,asciimath);
|
||||
this.insertNode(script);
|
||||
return script;
|
||||
},
|
||||
|
||||
filterAM: function (asciimath) {return asciimath},
|
||||
|
||||
msieNewlineBug: (MathJax.Hub.Browser.isMSIE && (document.documentMode||0) < 9)
|
||||
|
||||
};
|
||||
|
||||
MathJax.Hub.Register.PreProcessor(["PreProcess",MathJax.Extension.asciimath2jax]);
|
||||
MathJax.Ajax.loadComplete("[MathJax]/extensions/asciimath2jax.js");
|
41
unpacked/jax/input/AsciiMath/config.js
Normal file
41
unpacked/jax/input/AsciiMath/config.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*************************************************************
|
||||
*
|
||||
* MathJax/jax/input/AsciiMath/config.js
|
||||
*
|
||||
* Initializes the AsciiMath InputJax (the main definition is in
|
||||
* MathJax/jax/input/AsciiMath/jax.js, which is loaded when needed).
|
||||
*
|
||||
* Originally adapted for MathJax by David Lippman.
|
||||
* Additional work done by Davide P. Cervone.
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (c) 2012 Design Science, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
MathJax.InputJax.AsciiMath = MathJax.InputJax({
|
||||
id: "AsciiMath",
|
||||
version: "1.0",
|
||||
directory: MathJax.InputJax.directory + "/AsciiMath",
|
||||
extensionDir: MathJax.InputJax.extensionDir + "/AsciiMath",
|
||||
|
||||
config: {
|
||||
displaystyle: true, // put limits above and below operators
|
||||
decimal: "." // can change to "," but watch out for "(1,2)"
|
||||
}
|
||||
});
|
||||
MathJax.InputJax.AsciiMath.Register("math/asciimath");
|
||||
|
||||
MathJax.InputJax.AsciiMath.loadComplete("config.js");
|
1295
unpacked/jax/input/AsciiMath/jax.js
Normal file
1295
unpacked/jax/input/AsciiMath/jax.js
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user