Replacing old XSLT transform for math with MathJax

git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@161 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
henrikjust 2014-08-14 12:09:55 +00:00
parent 3dff4f20b4
commit fbd7e66412
39 changed files with 128 additions and 1794 deletions

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.4 (2014-08-05)
* Version 1.4 (2014-08-13)
*
*/
@ -54,7 +54,7 @@ import writer2latex.util.Misc;
* <p>Where the available options are
* <ul>
* <li><code>-latex</code>, <code>-bibtex</code>, <code>-html5</code>, <code>-xhtml</code>,
<code>-xhtml+mathml</code>, <code>-xhtml+mathml+xsl</code>, <code>-epub</code>
<code>-xhtml+mathml</code>, <code>-epub</code>
* <li><code>-recurse</code>
* <li><code>-ultraclean</code>, <code>-clean</code>, <code>-pdfscreen</code>,
* <code>-pdfprint</code>, <code>-cleanxhtml</code>
@ -328,7 +328,6 @@ public final class Application {
System.out.println(" -xhtml");
System.out.println(" -xhtml11");
System.out.println(" -xhtml+mathml");
System.out.println(" -xhtml+mathml+xsl");
System.out.println(" -html5");
System.out.println(" -epub");
System.out.println(" -recurse");
@ -366,7 +365,6 @@ public final class Application {
else if ("-xhtml".equals(sArg)) { sTargetMIME = MIMETypes.XHTML; }
else if ("-xhtml11".equals(sArg)) { sTargetMIME = MIMETypes.XHTML11; }
else if ("-xhtml+mathml".equals(sArg)) { sTargetMIME = MIMETypes.XHTML_MATHML; }
else if ("-xhtml+mathml+xsl".equals(sArg)) { sTargetMIME = MIMETypes.XHTML_MATHML_XSL; }
else if ("-epub".equals(sArg)) { sTargetMIME = MIMETypes.EPUB; }
else if ("-recurse".equals(sArg)) { bRecurse = true; }
else if ("-ultraclean".equals(sArg)) { configFileNames.add("*ultraclean.xml"); }

View file

@ -89,9 +89,6 @@ public class ConverterFactory {
else if (MIMETypes.XHTML_MATHML.equals(sMIME)) {
converter = createInstance("writer2latex.xhtml.XhtmlMathMLConverter");
}
else if (MIMETypes.XHTML_MATHML_XSL.equals(sMIME)) {
converter = createInstance("writer2latex.xhtml.XhtmlMathMLXSLConverter");
}
else if (MIMETypes.HTML5.equals(sMIME)) {
converter = createInstance("writer2latex.xhtml.Html5Converter");
}

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2012 by Henrik Just
* Copyright: 2002-2014 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.4 (2012-04-01)
* Version 1.4 (2014-08-13)
*
*/
@ -51,7 +51,6 @@ public class MIMETypes {
/** This is a fake MIME type, for internal use only */
public static final String XHTML11="application/xhtml11";
public static final String XHTML_MATHML="application/xhtml+xml";
public static final String XHTML_MATHML_XSL="application/xml";
/** This is a fake MIME type, for internal use only */
public static final String HTML5="text/html5";
public static final String EPUB="application/epub+zip";

View file

@ -269,7 +269,7 @@ public final class MathConverter extends ConverterHelper {
* @param node the paragraph
* @return true if this is a display equation
*/
public boolean parseDisplayEquation(Node node) {
private boolean parseDisplayEquation(Node node) {
theEquation = null;
theSequence = null;
return doParseDisplayEquation(node);
@ -346,7 +346,7 @@ public final class MathConverter extends ConverterHelper {
* @param node the draw:frame
* @return the MathML element, or null if this is not a MathML formula
*/
public Element getMathmlEquation(Element node) {
private Element getMathmlEquation(Element node) {
if (node.getTagName().equals(XMLString.DRAW_FRAME)) {
node=Misc.getFirstChildElement(node);
}

View file

@ -20,7 +20,7 @@
*
* All Rights Reserved.
*
* Version 1.4 (2014-08-05)
* Version 1.4 (2014-08-13)
*
*/
@ -69,7 +69,6 @@ public final class MIMETypes extends writer2latex.api.MIMETypes {
public static final String BIBTEX_EXT = ".bib";
public static final String XHTML_EXT = ".html";
public static final String XHTML_MATHML_EXT = ".xhtml";
public static final String XHTML_MATHML_XSL_EXT = ".xml";
public static final String PNG_EXT = ".png";
public static final String JPEG_EXT = ".jpg"; // this is the default in graphicx.sty
public static final String GIF_EXT = ".gif";
@ -142,7 +141,6 @@ public final class MIMETypes extends writer2latex.api.MIMETypes {
if (BIBTEX.equals(sMIME)) { return BIBTEX_EXT; }
if (XHTML.equals(sMIME)) { return XHTML_EXT; }
if (XHTML_MATHML.equals(sMIME)) { return XHTML_MATHML_EXT; }
if (XHTML_MATHML_XSL.equals(sMIME)) { return XHTML_MATHML_XSL_EXT; }
return "";
}

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2012 by Henrik Just
* Copyright: 2002-2014 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.4 (2012-04-12)
* Version 1.4 (2014-08-13)
*
*/
@ -41,7 +41,7 @@ import writer2latex.util.Misc;
public class XhtmlConfig extends writer2latex.base.ConfigBase {
// Implement configuration methods
protected int getOptionCount() { return 58; }
protected int getOptionCount() { return 57; }
protected String getDefaultConfigPath() { return "/writer2latex/xhtml/config/"; }
// Override setOption: To be backwards compatible, we must accept options
@ -152,12 +152,11 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
private static final int APPLY_PRINT_RANGES = 49;
private static final int USE_TITLE_AS_HEADING = 50;
private static final int USE_SHEET_NAMES_AS_HEADINGS = 51;
private static final int XSLT_PATH = 52;
private static final int SAVE_IMAGES_IN_SUBDIR = 53;
private static final int UPLINK = 54;
private static final int DIRECTORY_ICON = 55;
private static final int DOCUMENT_ICON = 56;
private static final int ZEN_HACK = 57; // temporary hack for ePub Zen Garden styles
private static final int SAVE_IMAGES_IN_SUBDIR = 52;
private static final int UPLINK = 53;
private static final int DIRECTORY_ICON = 54;
private static final int DOCUMENT_ICON = 55;
private static final int ZEN_HACK = 56; // temporary hack for ePub Zen Garden styles
protected ComplexOption xheading = addComplexOption("heading-map");
protected ComplexOption xpar = addComplexOption("paragraph-map");
@ -284,7 +283,6 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
options[APPLY_PRINT_RANGES] = new BooleanOption("apply_print_ranges","false");
options[USE_TITLE_AS_HEADING] = new BooleanOption("use_title_as_heading","true");
options[USE_SHEET_NAMES_AS_HEADINGS] = new BooleanOption("use_sheet_names_as_headings","true");
options[XSLT_PATH] = new Option("xslt_path","");
options[SAVE_IMAGES_IN_SUBDIR] = new BooleanOption("save_images_in_subdir","false");
options[UPLINK] = new Option("uplink","");
options[DIRECTORY_ICON] = new Option("directory_icon","");
@ -412,7 +410,6 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
public boolean applyPrintRanges() { return ((BooleanOption) options[APPLY_PRINT_RANGES]).getValue(); }
public boolean xhtmlUseTitleAsHeading() { return ((BooleanOption) options[USE_TITLE_AS_HEADING]).getValue(); }
public boolean xhtmlUseSheetNamesAsHeadings() { return ((BooleanOption) options[USE_SHEET_NAMES_AS_HEADINGS]).getValue(); }
public String getXsltPath() { return options[XSLT_PATH].getString(); }
public boolean saveImagesInSubdir() { return ((BooleanOption) options[SAVE_IMAGES_IN_SUBDIR]).getValue(); }
public String getXhtmlUplink() { return options[UPLINK].getString(); }
public String getXhtmlDirectoryIcon() { return options[DIRECTORY_ICON].getString(); }

View file

@ -16,11 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2012 by Henrik Just
* Copyright: 2002-2014 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.4 (2012-04-07)
* Version 1.4 (2014-08-13)
*
*/
@ -69,16 +69,11 @@ public class XhtmlDocument extends DOMDocument {
/** Constant to identify XHTML + MathML documents */
public static final int XHTML_MATHML = 2;
/** Constant to identify XHTML + MathML documents using the XSL transformations
* from w3c's math working group (http://www.w3.org/Math/XSL/)
*/
public static final int XHTML_MATHML_XSL = 3;
/** Constant to identify HTML5 documents */
public static final int HTML5 = 4;
public static final int HTML5 = 3;
// Some static data
private static final String[] sExtension = { ".html", ".xhtml", ".xhtml", ".xml", ".html" };
private static final String[] sExtension = { ".html", ".xhtml", ".xhtml", ".html" };
private static Set<String> blockPrettyPrint;
private static Set<String> conditionalBlockPrettyPrint;
@ -97,7 +92,6 @@ public class XhtmlDocument extends DOMDocument {
private boolean bNoDoctype = false;
private boolean bAddBOM = false;
private boolean bPrettyPrint = true;
private String sXsltPath = "";
private String sContentId = "content";
private String sHeaderId = "header";
private String sFooterId = "footer";
@ -309,7 +303,6 @@ public class XhtmlDocument extends DOMDocument {
case XHTML10: return MIMETypes.XHTML;
case XHTML11: return MIMETypes.XHTML_MATHML; // TODO: Change the constant names in MIMETypes, this is a bit confusing...
case XHTML_MATHML: return MIMETypes.XHTML_MATHML;
case XHTML_MATHML_XSL: return MIMETypes.XHTML_MATHML_XSL;
case HTML5: return MIMETypes.HTML5;
}
return "";
@ -436,7 +429,6 @@ public class XhtmlDocument extends DOMDocument {
sSystemId = "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";
break;
case XHTML_MATHML :
case XHTML_MATHML_XSL :
sPublicId = "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN";
sSystemId = "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd";
//sSystemId = "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd"; (old version)
@ -514,7 +506,6 @@ public class XhtmlDocument extends DOMDocument {
bPrettyPrint = config.prettyPrint();
bUseNamedEntities = config.useNamedEntities();
bHexadecimalEntities = config.hexadecimalEntities();
sXsltPath = config.getXsltPath();
String[] sTemplateIds = config.templateIds().split(",");
int nIdCount = sTemplateIds.length;
@ -575,15 +566,9 @@ public class XhtmlDocument extends DOMDocument {
if (nType!=XHTML10 && nType!=HTML5) {
osw.write("<?xml version=\"1.0\" encoding=\""+sEncoding+"\" ?>\n");
}
// Either specify doctype or xsl transformation (the user may require
// that no doctype is used; this may be desirable for further transformations)
if (nType==XHTML_MATHML_XSL) {
// Original url: http://www.w3.org/Math/XSL/pmathml.xsl
// Add trailing slash if needed
String sSlash = sXsltPath.length()>0 && !sXsltPath.endsWith("/") ? "/" : "";
osw.write("<?xml-stylesheet type=\"text/xsl\" href=\""+sXsltPath+sSlash+"pmathml.xsl\"?>\n");
}
else if (!bNoDoctype) {
// Specify DOCTYPE (the user may require that no DOCTYPE is used;
// this may be desirable for further transformations)
if (!bNoDoctype) {
if (nType==HTML5) {
osw.write("<!DOCTYPE html>\n");
}
@ -763,7 +748,7 @@ public class XhtmlDocument extends DOMDocument {
return;
}
String s=getMathMLEntity(c);
if (s!=null && (nType==XHTML_MATHML || nType==XHTML_MATHML_XSL)) {
if (s!=null && (nType==XHTML_MATHML)) {
// There's a MathML entity to use
osw.write(s);
return;

View file

@ -1,35 +0,0 @@
/************************************************************************
*
* XhtmlMathMLXSLConverter.java
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
* Copyright: 2002-2008 by Henrik Just
*
* All Rights Reserved.
*
* Version 1.0 (2008-09-09)
*
*/
package writer2latex.xhtml;
public class XhtmlMathMLXSLConverter extends Converter {
public XhtmlMathMLXSLConverter() {
super(XhtmlDocument.XHTML_MATHML_XSL);
}
}