");
+ }
+
+ if (getGenerationType() == Backend.WEB) {
+ /* Prepare the code for the html inclusion */
+ code = convertCode(code);
+ /* Provide a tooltip */
+ return "
" + buffer.toString() + "
";
+ } else {
+ /* No tooltip in the javahelp browser ...
+ * too limited html capabilities */
+ return buffer.toString();
+ }
+ }
+
+ @Override
+ public String generateImageCode(Image img, String fileName, Map attrs) {
+ String style = attrs.get("style");
+ String top = "";
+ boolean display = style != null && style.equals("display");
+
+ if (!display) {
+ top = "top:" + img.descent + "px;";
+ }
+
+ String alignAttr = attrs.get("align");
+ String align = "";
+ String div = "div";
+ if (alignAttr != null) {
+ align = " style=\'text-align:" + alignAttr + "\'";
+ } else if (display) {
+ align = " style=\'text-align:center\'";
+ } else {
+ div = "span";
+ }
+
+ if (getGenerationType() == Backend.JAVAHELP && isLinkedImage()) {
+ // Java HTML renderer is not good... so when the image is linked, we remove the div
+ return ">";
+ } else {
+ return "<" + div + align + ">" + div + ">";
+ }
+ }
+
+ @Override
+ public String generateImageCode(String fileName, Map attrs) {
+ String alignAttr = attrs.get("align");
+ boolean addDiv = getGenerationType() != Backend.JAVAHELP || !isLinkedImage();
+ final StringBuilder buffer = new StringBuilder(128);
+ if (addDiv && alignAttr != null) {
+ buffer.append("
");
+ }
+
+ return buffer.toString();
+ }
+
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
+ latexCompt = 1;
+ return super.resolveEntity(publicId, systemId);
+ }
+
+ /**
+ * Handle a refentry
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleRefentry(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ if (id != null) {
+ currentId = id;
+ }
+ String fileName = mapId.get(currentId);
+ String needsExampleAttr = attributes.get("needs-examples");
+ createHTMLFile(currentId, fileName, refpurpose, contents);
+ if (!hasExamples && (needsExampleAttr == null || !needsExampleAttr.equals("no"))) {
+ warnings++;
+ //System.err.println("Warning (should be fixed): no example in " + currentFileName);
+ } else {
+ hasExamples = false;
+ }
+ String rp = encloseContents("span", "refentry-description", refpurpose);
+ String str = encloseContents("li", encloseContents("a", new String[] {"href", fileName, "class", "refentry"}, refname) + " — " + rp);
+ refpurpose = "";
+ refname = "";
+ currentId = null;
+
+ return str;
+ }
+
+ /**
+ * Handle a section
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleSection(final Map attributes, final String contents) throws SAXException {
+ String fileName = attributes.get("id") + ".html";
+ String str = encloseContents("ul", "list-refentry", contents);
+ String title = encloseContents("h3", "title-section", sectionTitle);
+ createHTMLFile(attributes.get("id"), fileName, sectionTitle, title + "\n" + str);
+
+ str = encloseContents("li", encloseContents("a", new String[] {"href", fileName, "class", "section"}, sectionTitle) + "\n" + str);
+ sectionTitle = "";
+
+ return str;
+ }
+
+ /**
+ * Handle a book
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleBook(final Map attributes, final String contents) throws SAXException {
+ String str = encloseContents("ul", "list-part", contents);
+ String btitle;
+ if (bookTitle.trim().equalsIgnoreCase("Scilab")) {
+ btitle = version;
+ } else {
+ btitle = bookTitle;
+ }
+ String title = encloseContents("h3", "book-title", btitle);
+ createHTMLFile("index", indexFilename, btitle, title + "\n" + str);
+
+ if (warnings != 0) {
+ System.err.println("Total files without example: " + warnings);
+ System.err.println("Total generated html files: " + nbFiles);
+ }
+
+ return encloseContents("li", encloseContents("a", new String[] {"href", indexFilename, "class", "part"}, bookTitle) + "\n" + str);
+ }
+
+ /**
+ * Handle a part
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handlePart(final Map attributes, final String contents) throws SAXException {
+ String fileName = attributes.get("id") + ".html";
+ String str = encloseContents("ul", "list-chapter", contents);
+ String title = encloseContents("h3", "title-part", partTitle);
+ createHTMLFile(attributes.get("id"), fileName, partTitle, title + "\n" + str);
+ str = encloseContents("li", encloseContents("a", new String[] {"href", fileName, "class", "part"}, partTitle) + "\n" + str);
+ partTitle = "";
+
+ return str;
+ }
+
+ /**
+ * Handle a chapter
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleChapter(final Map attributes, final String contents) throws SAXException {
+ String fileName = attributes.get("id") + ".html";
+ String str = encloseContents("ul", "list-refentry", contents);
+ String title = encloseContents("h3", "title-chapter", chapterTitle);
+ createHTMLFile(attributes.get("id"), fileName, chapterTitle, title + "\n" + str);
+
+ str = encloseContents("li", encloseContents("a", new String[] {"href", fileName, "class", "chapter"}, chapterTitle) + "\n" + str);
+ chapterTitle = "";
+
+ return str;
+ }
+
+ // partiellement merdique car le style de title depend du noeud pere.
+ /**
+ * Handle a title
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleTitle(final Map attributes, final String contents) throws SAXException {
+ String clazz = "title";
+ String parent = getParentTagName();
+ if (parent.equals("chapter")) {
+ chapterTitle = contents;
+ } else if (parent.equals("part")) {
+ partTitle = contents;
+ } else if (parent.equals("info")) {
+ bookTitle = contents;
+ } else if (parent.equals("section")) {
+ sectionTitle = contents;
+ } else if (parent.equals("refsection") && Pattern.matches("^[ \\t]*ex[ea]mpl[eo].*", contents.toLowerCase())) {
+ hasExamples = true;
+ return encloseContents("h3", clazz, contents);
+ } else {
+ return encloseContents("h3", clazz, contents);
+ }
+
+ return null;
+ }
+
+ /**
+ * Handle a para
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handlePara(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("p", "para", contents);
+ }
+
+ /**
+ * Handle a literal
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleLiteral(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("code", "literal", contents);
+ }
+
+ /**
+ * Handle a varname
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleVarname(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("code", "varname", contents);
+ }
+
+ /**
+ * Handle a command
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleCommand(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("code", "command", contents);
+ }
+
+ /**
+ * Handle a code
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleCode(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("code", "scilabcode", scilabLexer.convert(HTMLScilabCodeHandler.getInstance(refname, currentFileName), contents));//encloseContents("code", "code", contents);
+ }
+
+ /**
+ * Handle a function
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleFunction(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("code", "function", contents);
+ }
+
+ /**
+ * Handle a constant
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleConstant(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("code", "constant", contents);
+ }
+
+ /**
+ * Handle an option
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleOption(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("code", "option", contents);
+ }
+
+ /**
+ * Handle a refnamediv
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleRefnamediv(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ if (id != null) {
+ currentId = id;
+ }
+
+ return encloseContents("div", "refnamediv", contents);
+ }
+
+ /**
+ * Handle a refname
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleRefname(final Map attributes, final String contents) throws SAXException {
+ refname = contents;
+ return encloseContents("h1", "refname", contents);
+ }
+
+ /**
+ * Handle a refpurpose
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleRefpurpose(final Map attributes, final String contents) throws SAXException {
+ refpurpose = contents;
+ return encloseContents("p", "refpurpose", contents);
+ }
+
+ /**
+ * Handle a refsynopsisdiv
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleRefsynopsisdiv(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ if (id != null) {
+ return "" + encloseContents("div", "refsynopsisdiv", contents);
+ } else {
+ return encloseContents("div", "refsynopsisdiv", contents);
+ }
+ }
+
+ /**
+ * Handle a synopsis
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleSynopsis(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ String str = encloseContents("div", "synopsis", encloseContents("pre", SynopsisLexer.convert(refname, contents)));
+ if (id != null) {
+ return "" + str;
+ } else {
+ return str;
+ }
+ }
+
+ /**
+ * Handle a info
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleInfo(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ if (id != null) {
+ return "" + encloseContents("div", "info", contents);
+ } else {
+ return encloseContents("div", "info", contents);
+ }
+ }
+
+ /**
+ * Handle a refsection
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleRefsection(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ if (id != null) {
+ return "" + encloseContents("div", "refsection", contents);
+ } else {
+ return encloseContents("div", "refsection", contents);
+ }
+ }
+
+ /**
+ * Handle a progamlisting
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleProgramlisting(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ String role = attributes.get("role");
+ String str;
+ if (role == null) {
+ String code = encloseContents("pre", "scilabcode", scilabLexer.convert(HTMLScilabCodeHandler.getInstance(refname, currentFileName), contents));
+ if (prependToProgramListing != null) {
+ code = prependToProgramListing + code;
+ }
+ if (appendToProgramListing != null) {
+ code += appendToProgramListing;
+ }
+ str = encloseContents("div", "programlisting", code);
+ } else {
+ if (role.equals("xml")) {
+ str = encloseContents("div", "programlisting", encloseContents("pre", "xmlcode", xmlLexer.convert(HTMLXMLCodeHandler.getInstance(), contents)));
+ } else if (role.equals("c") || role.equals("cpp") || role.equals("code_gateway")) {
+ hasExamples = true;
+ str = encloseContents("div", "programlisting", encloseContents("pre", "ccode", cLexer.convert(HTMLCCodeHandler.getInstance(), contents)));
+ } else if (role.equals("java")) {
+ hasExamples = true;
+ str = encloseContents("div", "programlisting", encloseContents("pre", "ccode", javaLexer.convert(HTMLCCodeHandler.getInstance(), contents)));
+ } else if (role.equals("exec")) {
+ String code = encloseContents("pre", "scilabcode", scilabLexer.convert(HTMLScilabCodeHandler.getInstance(refname, currentFileName), contents));
+ if (prependToProgramListing != null) {
+ code = prependToProgramListing + code;
+ }
+ if (appendForExecToProgramListing != null) {
+ code += appendForExecToProgramListing;
+ }
+ str = encloseContents("div", "programlisting", code);
+ } else if (role.equals("no-scilab-exec")) {
+ hasExamples = true;
+ String code = encloseContents("pre", "scilabcode", scilabLexer.convert(HTMLScilabCodeHandler.getInstance(refname, currentFileName), contents));
+ str = encloseContents("div", "programlisting", code);
+ } else {
+ String code = encloseContents("pre", "scilabcode", scilabLexer.convert(HTMLScilabCodeHandler.getInstance(refname, currentFileName), contents));
+ if (prependToProgramListing != null) {
+ code = prependToProgramListing + code;
+ }
+ if (appendToProgramListing != null) {
+ code += appendToProgramListing;
+ }
+ str = encloseContents("div", "programlisting", code);
+ }
+ }
+ if (id != null) {
+ return "" + str;
+ } else {
+ return str;
+ }
+ }
+
+ /**
+ * Handle a screen
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleScreen(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ String str = encloseContents("div", "screen", encloseContents("pre", contents));
+ if (id != null) {
+ return "" + str;
+ } else {
+ return str;
+ }
+ }
+
+ /**
+ * Handle a pubdate
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handlePubdate(final Map attributes, final String contents) throws SAXException {
+ return null;
+ }
+
+ /**
+ * Handle a simplelist
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleSimplelist(final Map attributes, final String contents) throws SAXException {
+ String style = "itemizedlist";
+
+ return encloseContents("ul", style, contents);
+ }
+
+ /**
+ * Handle a member
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleMember(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("li", "member", contents);
+ }
+
+ /**
+ * Handle a link
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleLink(final Map attributes, final String contents) throws SAXException {
+ String link = attributes.get("linkend");
+ if (link == null) {
+ throw new SAXException("No linkend attribute in tag link");
+ }
+
+ String type = attributes.get("type");
+ String id;
+ if (type != null && type.equals("scilab")) {
+ if (this.type == Backend.JAVAHELP || this.type == Backend.HTML) {
+ id = resolvScilabLink(link);
+ } else {
+ return contents;
+ }
+ } else if (type != null && type.equals("remote")) {
+ id = makeRemoteLink(link);
+ } else {
+ id = mapId.get(link);
+ }
+
+ if (id == null) {
+ if (isToolbox) {
+ if (this.type == Backend.HTML) {
+ id = urlBase + link;
+ if (linkToTheWeb) {
+ id += ".html";
+ }
+ }
+ if (this.type == Backend.JAVAHELP) {
+ id = urlBase + link;
+ }
+ } else {
+ warnings++;
+ System.err.println("Warning (should be fixed): invalid internal link to " + link + " in " + currentFileName + "\nat line " + locator.getLineNumber());
+ return null;
+ }
+ }
+
+ Stack stack = getStack();
+ String refnameTarget = mapIdRefname.get(link);
+ String str;
+ if (contents != null && !contents.isEmpty()) {
+ str = contents;
+ } else {
+ str = refnameTarget;
+ }
+
+ if (str == null) {
+ warnings++;
+ System.err.println("Warning (should be fixed): empty link (no text will be printed) to " + link + " in " + currentFileName + "\nat line " + locator.getLineNumber());
+ }
+
+ String href = encloseContents("a", new String[] {"href", id, "class", "link"}, str);
+
+ int s = stack.size();
+ if (s >= 3) {
+ DocbookElement elem = stack.get(s - 3);
+ if (elem.getName().equals("refsection")) {
+ String role = elem.getAttributes().get("role");
+ if (role != null && role.equals("see also")) {
+ String purpose = mapIdPurpose.get(link);
+ if (purpose != null) {
+ return href + " — " + purpose;
+ } else {
+ return href;
+ }
+ }
+ }
+ }
+
+ return href;
+ }
+
+ /**
+ * Rewrite a link when its type is "scilab"
+ * @param link the link
+ * @return the modified link with protocol scilab:// for example
+ */
+ protected String resolvScilabLink(String link) {
+ int pos = link.indexOf("/");
+ if (pos == -1) {
+ return null;
+ }
+
+ String first = link.substring(0, pos);
+ String second = link.substring(pos + 1);
+ String[] toks = first.split("\\.");
+ if (toks == null || toks.length != 2) {
+ return null;
+ }
+
+ if (!linkToTheWeb) {
+ return urlBase + link;
+ } else {
+ if (toks[0].equals("scilab") && toks[1].equals("help")) {
+ return urlBase + second + ".html";
+ } else {
+ return "#";
+ }
+ }
+ }
+
+ /**
+ * Make a remote link
+ * @param link the link
+ * @return the good link
+ */
+ protected String makeRemoteLink(String link) {
+ return link;
+ }
+
+ /**
+ * Handle an ulink
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleUlink(final Map attributes, final String contents) throws SAXException {
+ String link = attributes.get("url");
+ if (link == null) {
+ throw new SAXException("No url attribute in tag ulink");
+ }
+
+ return encloseContents("a", new String[] {"href", link, "class", "ulink"}, contents);
+ }
+
+ /**
+ * Handle a xref
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleXref(final Map attributes, final String contents) throws SAXException {
+ String link = attributes.get("linkend");
+ if (link == null) {
+ throw new SAXException("No linkend attribute in tag link");
+ }
+
+ String id = mapId.get(link);
+ if (id == null) {
+ warnings++;
+ System.err.println("Warning (should be fixed): invalid internal link to " + link + " in " + currentFileName + "\nat line " + locator.getLineNumber());
+ return null;
+ }
+
+ return encloseContents("a", new String[] {"href", id, "class", "xref"}, contents);
+ }
+
+ /**
+ * Handle a latex (not really a docbook tag...)
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleLatex(final Map attributes, final String contents) throws SAXException {
+ boolean isLocalized = "true".equals(attributes.get("localized"));
+ File f;
+ if (isLocalized) {
+ f = new File(outImages + "/" + imageDir, LATEXBASENAME + currentBaseName + "_" + language + "_" + (latexCompt++) + ".png");
+ } else {
+ if ("ru_RU".equals(language) && HTMLDocbookTagConverter.containsCyrillic(contents)) {
+ System.err.println("Warning: LaTeX code in " + getCurrentFileName() + " contains cyrillic character. The tag should contain the attribute scilab:localized=\"true\"");
+ } else if ("ja_JP".equals(language) && HTMLDocbookTagConverter.containsCJK(contents)) {
+ System.err.println("Warning: LaTeX code in " + getCurrentFileName() + " contains CJK character. The tag should contain the attribute scilab:localized=\"true\"");
+ }
+ f = new File(outImages + "/" + imageDir, LATEXBASENAME + currentBaseName + "_" + (latexCompt++) + ".png");
+ }
+
+ String parent = getParentTagName();
+ if (parent.equals("para") && !attributes.containsKey("style")) {
+ attributes.put("style", "text");
+ }
+ String fs = attributes.get("fontsize");
+ if (fs == null) {
+ attributes.put("fontsize", "16");
+ }
+
+ return getImageConverter().getImageByCode(currentFileName, contents, attributes, "image/latex", f, imageDir + "/" + f.getName(), getBaseImagePath(), locator.getLineNumber(), language, isLocalized);
+ }
+
+ /**
+ * Handle a term
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleTerm(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ if (id != null) {
+ return "" + encloseContents("span", "term", contents);
+ } else {
+ return encloseContents("span", "term", contents);
+ }
+ }
+
+ /**
+ * Handle a listitem
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleListitem(final Map attributes, final String contents) throws SAXException {
+ String parent = getParentTagName();
+ if (parent.equals("varlistentry")) {
+ return encloseContents("dd", contents);
+ }
+ return encloseContents("li", contents);
+ }
+
+ /**
+ * Handle a varlistentry
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleVarlistentry(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("dt", contents);
+ }
+
+ /**
+ * Handle a variablelist
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleVariablelist(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("dl", contents);
+ }
+
+ /**
+ * Handle an itemizedlist
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleItemizedlist(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ if (id != null) {
+ return "" + encloseContents("ul", "itemizedlist", contents);
+ } else {
+ return encloseContents("ul", "itemizedlist", contents);
+ }
+ }
+
+ /**
+ * Handle an emphasis
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleEmphasis(final Map attributes, final String contents) throws SAXException {
+ String role = attributes.get("role");
+ if (role != null) {
+ if (role.equals("bold")) {
+ return encloseContents("b", contents);
+ }
+ if (role.equals("italic")) {
+ return encloseContents("i", contents);
+ }
+ }
+
+ return encloseContents("em", contents);
+ }
+
+ /**
+ * Handle a tr
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleTr(final Map attributes, final String contents) throws SAXException {
+ String bgcolor = attributes.get("bgcolor");
+
+ return encloseContents("tr", new String[] {"bgcolor", bgcolor}, contents);
+ }
+
+ /**
+ * Handle a td
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleTd(final Map attributes, final String contents) throws SAXException {
+ String align = attributes.get("align");
+ String bgcolor = attributes.get("bgcolor");
+ String colspan = attributes.get("colspan");
+ String rowspan = attributes.get("rowspan");
+
+ return encloseContents("td", new String[] {"align", align, "bgcolor", bgcolor, "colspan", colspan, "rowspan", rowspan}, contents);
+ }
+
+ /**
+ * Handle an informaltable
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleInformaltable(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ String border = attributes.get("border");
+ String cellpadding = attributes.get("cellpadding");
+ String width = attributes.get("width");
+ if (id != null) {
+ return "" + encloseContents("table", new String[] {"class", "informaltable", "border", border, "cellpadding", cellpadding, "width", width}, contents);
+ } else {
+ return encloseContents("table", new String[] {"class", "informaltable", "border", border, "cellpadding", cellpadding, "width", width}, contents);
+ }
+ }
+
+ /**
+ * Handle an imagedata
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleImagedata(final Map attributes, final String contents) throws SAXException {
+ String fileref = attributes.get("fileref");
+ if (fileref == null) {
+ if (contents == null || contents.length() == 0) {
+ throw new SAXException("No fileref attribute or no data in tag imagedata");
+ }
+
+ return contents;
+ }
+
+ try {
+ String path = new File(new URI(currentFileName)).getParent();
+ File file = ImageConverter.imageExists(path, fileref);
+ if (file != null) {
+ throw new SAXException("The given fileref is not on an existing image file:\n" + fileref + " [" + file + "]");
+ }
+
+ return getImageConverter().getImageByFile(attributes, path, fileref, outImages, imageDir, getBaseImagePath());
+ } catch (URISyntaxException e) {
+ System.err.println(e);
+ }
+
+ return null;
+ }
+
+ /**
+ * Handle an imageobject
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleImageobject(final Map attributes, final String contents) throws SAXException {
+ return contents;
+ }
+
+ /**
+ * Handle an textobject (as an alternative to imageobject)
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleTextobject(final Map attributes, final String contents) throws SAXException {
+ return "";
+ }
+
+ /**
+ * Handle an inlinemediaobject
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleInlinemediaobject(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("span", contents);
+ }
+
+ /**
+ * Handle a screenshot
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleScreenshot(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ if (id != null) {
+ return "" + encloseContents("div", "screenshot", contents);
+ } else {
+ return encloseContents("div", "screenshot", contents);
+ }
+ }
+
+ /**
+ * Handle a mediaobject
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleMediaobject(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ String c = contents.replaceFirst("top:([0-9]+)px;", "");
+ if (id != null) {
+ return "" + encloseContents("div", "mediaobject", c);
+ } else {
+ return encloseContents("div", "mediaobject", c);
+ }
+ }
+
+ /**
+ * Handle an informalequation
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleInformalequation(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ if (id != null) {
+ return "" + encloseContents("div", "informalequation", contents);
+ } else {
+ return encloseContents("div", "informalequation", contents);
+ }
+ }
+
+ /**
+ * Handle an orderedlist
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleOrderedlist(final Map attributes, final String contents) throws SAXException {
+ String numeration = "1";
+ String numAttr = attributes.get("numeration");
+ if (numAttr != null) {
+ if (numAttr.equals("loweralpha")) {
+ numeration = "a";
+ } else if (numAttr.equals("upperalpha")) {
+ numeration = "A";
+ } else if (numAttr.equals("lowerroman")) {
+ numeration = "i";
+ } else if (numAttr.equals("upperroman")) {
+ numeration = "I";
+ }
+ }
+
+ String id = attributes.get("id");
+ if (id != null) {
+ return "" + encloseContents("ol", new String[] {"type", numeration}, contents);
+ } else {
+ return encloseContents("ol", new String[] {"type", numeration}, contents);
+ }
+ }
+
+ /**
+ * Handle a subscript
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleSubscript(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("sub", contents);
+ }
+
+ /**
+ * Handle a superscript
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleSuperscript(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("sup", contents);
+ }
+
+ /**
+ * Handle a replaceable
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleReplaceable(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("span", "replaceable", contents);
+ }
+
+ /**
+ * Handle a question
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleQuestion(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("dt", encloseContents("strong", contents));
+ }
+
+ /**
+ * Handle an answer
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleAnswer(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("dd", contents);
+ }
+
+ /**
+ * Handle a qandaentry
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleQandaentry(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("dl", contents);
+ }
+
+ /**
+ * Handle a qandaset
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleQandaset(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("div", "qandaset", contents);
+ }
+
+ /**
+ * Handle a caption
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleCaption(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("caption", encloseContents("b", contents));
+ }
+
+ /**
+ * Handle a tbody
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleTbody(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("tbody", "tbody", contents);
+ }
+
+ /**
+ * Handle a table
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleTable(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ String bgcolor = attributes.get("bgcolor");
+ String border = attributes.get("border");
+ String cellpadding = attributes.get("cellpadding");
+
+ if (id != null) {
+ return "" + encloseContents("table", new String[] {"class", "doctable", "bgcolor", bgcolor, "border", border, "cellpadding", cellpadding}, contents);
+ } else {
+ return encloseContents("table", new String[] {"class", "doctable", "bgcolor", bgcolor, "border", border, "cellpadding", cellpadding}, contents);
+ }
+ }
+
+ /**
+ * Handle a surname
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleSurname(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("span", "surname", contents);
+ }
+
+ /**
+ * Handle a firstname
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleFirstname(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("span", "firstname", contents);
+ }
+
+ /**
+ * Handle a bibliomset
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleBibliomset(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ if (id != null) {
+ return "" + encloseContents("div", "bibliomset", contents);
+ } else {
+ return encloseContents("div", "bibliomset", contents);
+ }
+ }
+
+ /**
+ * Handle a bibliomixed
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleBibliomixed(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ if (id != null) {
+ return "" + encloseContents("div", "bibliomixed", contents);
+ } else {
+ return encloseContents("div", "bibliomixed", contents);
+ }
+ }
+
+ /**
+ * Handle a th
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleTh(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("th", contents);
+ }
+
+ /**
+ * Handle a revhistory
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleRevhistory(final Map attributes, final String contents) throws SAXException {
+ String id = attributes.get("id");
+ String str = "
" + VERSION + "
" + DESCRIPTION + "
" + contents + "
";
+ if (id != null) {
+ return "" + str;
+ } else {
+ return str;
+ }
+ }
+
+ /**
+ * Handle a revision
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleRevision(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("tr", contents);
+ }
+
+ /**
+ * Handle a revnumber
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleRevnumber(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("td", "revnumber", contents);
+ }
+
+ /**
+ * Handle a revremark
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleRevremark(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("td", "revremark", contents);
+ }
+
+ /**
+ * Handle a revdescription
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleRevdescription(final Map attributes, final String contents) throws SAXException {
+ return encloseContents("td", "revdescription", contents);
+ }
+
+ /**
+ * Handle a note
+ * @param attributes the tag attributes
+ * @param contents the tag contents
+ * @return the HTML code
+ * @throws SAXEception if an error is encountered
+ */
+ public String handleNote(final Map