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

@ -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);
}
}