Add a configuration flag that causes the underlying MathML structure to be retained in the SVG output, with element classes used to mark the corresponding elements (this allows some CSS control of the results, but also produces more complicated SVG trees)

This commit is contained in:
Davide P. Cervone 2011-11-04 21:47:15 -04:00
parent 06c700c804
commit d76580a422
4 changed files with 9 additions and 2 deletions

View File

@ -12,5 +12,5 @@
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
*/ */
MathJax.OutputJax.SVG=MathJax.OutputJax({id:"SVG",version:"1.1",directory:MathJax.OutputJax.directory+"/SVG",extensionDir:MathJax.OutputJax.extensionDir+"/SVG",autoloadDir:MathJax.OutputJax.directory+"/SVG/autoload",fontDir:MathJax.OutputJax.directory+"/SVG/fonts",config:{scale:100,minScaleAdjust:50,font:"TeX",blacker:10,mtextFontInherit:false,MISSINGFONT:"STIXGeneral,'Arial Unicode MS'",EqnChunk:50,EqnChunkFactor:1.5,EqChunkDelay:100,linebreaks:{automatic:false,width:"container"},styles:{".MathJax_SVG_Display":{"text-align":"center",margin:"1em 0em"},"#MathJax_SVG_Tooltip":{"background-color":"InfoBackground",color:"InfoText",border:"1px solid black","box-shadow":"2px 2px 5px #AAAAAA","-webkit-box-shadow":"2px 2px 5px #AAAAAA","-moz-box-shadow":"2px 2px 5px #AAAAAA","-khtml-box-shadow":"2px 2px 5px #AAAAAA",padding:"3px 4px"}}}});if(!MathJax.Hub.config.delayJaxRegistration){MathJax.OutputJax.SVG.Register("jax/mml")}MathJax.OutputJax.SVG.loadComplete("config.js"); MathJax.OutputJax.SVG=MathJax.OutputJax({id:"SVG",version:"1.1",directory:MathJax.OutputJax.directory+"/SVG",extensionDir:MathJax.OutputJax.extensionDir+"/SVG",autoloadDir:MathJax.OutputJax.directory+"/SVG/autoload",fontDir:MathJax.OutputJax.directory+"/SVG/fonts",config:{scale:100,minScaleAdjust:50,font:"TeX",blacker:10,mtextFontInherit:false,MISSINGFONT:"STIXGeneral,'Arial Unicode MS'",addMMLclasses:false,EqnChunk:50,EqnChunkFactor:1.5,EqChunkDelay:100,linebreaks:{automatic:false,width:"container"},styles:{".MathJax_SVG_Display":{"text-align":"center",margin:"1em 0em"},"#MathJax_SVG_Tooltip":{"background-color":"InfoBackground",color:"InfoText",border:"1px solid black","box-shadow":"2px 2px 5px #AAAAAA","-webkit-box-shadow":"2px 2px 5px #AAAAAA","-moz-box-shadow":"2px 2px 5px #AAAAAA","-khtml-box-shadow":"2px 2px 5px #AAAAAA",padding:"3px 4px"}}}});if(!MathJax.Hub.config.delayJaxRegistration){MathJax.OutputJax.SVG.Register("jax/mml")}MathJax.OutputJax.SVG.loadComplete("config.js");

File diff suppressed because one or more lines are too long

View File

@ -37,6 +37,8 @@ MathJax.OutputJax.SVG = MathJax.OutputJax({
mtextFontInherit: false, // to make <mtext> be in page font rather than MathJax font mtextFontInherit: false, // to make <mtext> be in page font rather than MathJax font
MISSINGFONT: "STIXGeneral,'Arial Unicode MS'", // fonts to use for missing characters MISSINGFONT: "STIXGeneral,'Arial Unicode MS'", // fonts to use for missing characters
addMMLclasses: false, // keep MathML structure and use CSS classes to mark elements
EqnChunk: 50, // number of equations to process before showing them EqnChunk: 50, // number of equations to process before showing them
EqnChunkFactor: 1.5, // chunk size is multiplied by this after each chunk EqnChunkFactor: 1.5, // chunk size is multiplied by this after each chunk
EqChunkDelay: 100, // milliseconds to delay between chunks (to let browser EqChunkDelay: 100, // milliseconds to delay between chunks (to let browser

View File

@ -938,6 +938,7 @@
if (svg.X != null) {this.SVGdata.X = svg.X} if (svg.X != null) {this.SVGdata.X = svg.X}
if (this["class"]) {svg.removeable = false; SVG.Element(svg.element,{"class":this["class"]})} if (this["class"]) {svg.removeable = false; SVG.Element(svg.element,{"class":this["class"]})}
// FIXME: if an element is split by linebreaking, the ID will be the same on both parts // FIXME: if an element is split by linebreaking, the ID will be the same on both parts
// FIXME: if an element has an id, its zoomed copy will have the same ID
if (this.id) {svg.removeable = false; SVG.Element(svg.element,{"id":this.id})} if (this.id) {svg.removeable = false; SVG.Element(svg.element,{"id":this.id})}
if (this.href) { if (this.href) {
var a = SVG.Element("a"); var a = SVG.Element("a");
@ -949,6 +950,10 @@
} else {a.appendChild(svg.element)} } else {a.appendChild(svg.element)}
svg.element = a; svg.removeable = false; svg.element = a; svg.removeable = false;
} }
if (SVG.config.addMMLclasses) {
svg.removeable = false;
svg.element.setAttribute("className","mjx-svg-"+this.type);
}
}, },
SVGgetStyles: function () { SVGgetStyles: function () {