From 640b0d5f16d9a0ab83626464f472a9774b166c9f Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 18 Mar 2015 12:13:32 -0400 Subject: [PATCH] Add support for element --- unpacked/jax/output/CommonHTML/autoload/ms.js | 73 +++++++++++++++++++ unpacked/jax/output/CommonHTML/jax.js | 7 +- 2 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 unpacked/jax/output/CommonHTML/autoload/ms.js diff --git a/unpacked/jax/output/CommonHTML/autoload/ms.js b/unpacked/jax/output/CommonHTML/autoload/ms.js new file mode 100644 index 000000000..72cb20452 --- /dev/null +++ b/unpacked/jax/output/CommonHTML/autoload/ms.js @@ -0,0 +1,73 @@ +/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ + +/************************************************************* + * + * MathJax/jax/output/CommonHTML/autoload/ms.js + * + * Implements the CommonHTML output for elements. + * + * --------------------------------------------------------------------- + * + * Copyright (c) 2015 The MathJax Consortium + * + * 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.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { + var VERSION = "2.5.0"; + var MML = MathJax.ElementJax.mml, + CHTML = MathJax.OutputJax.CommonHTML; + + MML.ms.Augment({ + toCommonHTML: function (node) { + // + // Create the node and handle its styles and scaling + // Get the variant and an empty bounding box + // + node = this.CHTMLcreateNode(node); + this.CHTMLhandleStyle(node); + this.CHTMLhandleScale(node); + this.CHTMLgetVariant(); + CHTML.BBOX.empty(this.CHTML); + // + // Get the quotes to use + // + var values = this.getValues("lquote","rquote"); + if (!this.hasValue("lquote")) values.lquote = "\u201C"; + if (!this.hasValue("rquote")) values.rquote = "\u201D"; + // + // Add the left quote, the child nodes, and the right quote + // FIXME: should the quotation marks be in MML.VARIANT.NORMAL? + // + this.CHTMLhandleText(node,values.lquote,this.CHTMLvariant); + for (var i = 0, m = this.data.length; i < m; i++) this.CHTMLaddChild(node,i,{}); + this.CHTMLhandleText(node,values.rquote,this.CHTMLvariant); + // + // Finish the bbox, add any needed space and color + // + this.CHTML.clean(); + this.CHTMLhandleSpace(node); + this.CHTMLhandleBBox(node); + this.CHTMLhandleColor(node); + // + // Return the completed node + // + return node; + } + }); + + MathJax.Hub.Startup.signal.Post("CommonHTML ms Ready"); + MathJax.Ajax.loadComplete(CHTML.autoloadDir+"/ms.js"); +}); + diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index 2cfad14f1..0dec66234 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -1249,6 +1249,7 @@ }, CHTMLhandleText: function (node,text,variant) { + if (node.firstChild && !this.CHTML) this.CHTML = CHTML.BBOX.empty(); this.CHTML = CHTML.handleText(node,text,variant,this.CHTML); }, @@ -1344,11 +1345,11 @@ // // Autoload files based on node type or file name // - HTMLautoload: function () { + CHTMLautoload: function () { var file = CHTML.autoloadDir+"/"+this.type+".js"; HUB.RestartAfter(AJAX.Require(file)); }, - HTMLautoloadFile: function (name) { + CHTMLautoloadFile: function (name) { var file = CHTML.autoloadDir+"/"+name+".js"; HUB.RestartAfter(AJAX.Require(file)); }, @@ -2294,7 +2295,7 @@ /********************************************************/ -// MML.ms.Augment({toCommonHTML: MML.mbase.CHTMLautoload}); + MML.ms.Augment({toCommonHTML: MML.mbase.CHTMLautoload}); // MML.mglyph.Augment({toCommonHTML: MML.mbase.CHTMLautoload}); // MML.menclose.Augment({toCommonHTML: MML.mbase.CHTMLautoload}); // MML.maction.Augment({toCommonHTML: MML.mbase.CHTMLautoload});