2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2010 - Calixte DENIZET
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13 package org.scilab.modules.helptools;
16 import java.io.IOException;
17 import java.lang.Character.UnicodeBlock;
19 import java.net.URISyntaxException;
20 import java.util.Date;
22 import java.util.Stack;
23 import java.util.regex.Pattern;
25 import org.xml.sax.InputSource;
26 import org.xml.sax.SAXException;
28 import org.scilab.modules.commons.ScilabConstants;
29 import org.scilab.modules.helptools.image.ImageConverter;
30 import org.scilab.modules.helptools.image.LaTeXImageConverter;
31 import org.scilab.modules.helptools.image.MathMLImageConverter;
32 import org.scilab.modules.helptools.image.ScilabImageConverter;
33 import org.scilab.modules.helptools.image.SVGImageConverter;
34 import org.scilab.modules.helptools.image.XcosImageConverter;
35 import org.scilab.modules.helptools.scilab.ScilabLexer;
36 import org.scilab.modules.helptools.scilab.HTMLScilabCodeHandler;
37 import org.scilab.modules.helptools.scilab.AbstractScilabCodeHandler;
38 import org.scilab.modules.helptools.XML.XMLLexer;
39 import org.scilab.modules.helptools.XML.HTMLXMLCodeHandler;
40 import org.scilab.modules.helptools.c.CLexer;
41 import org.scilab.modules.helptools.c.HTMLCCodeHandler;
42 import org.scilab.modules.helptools.java.JavaLexer;
43 import org.scilab.modules.localization.Messages;
46 * Class to convert DocBook to HTML
47 * @author Calixte DENIZET
49 public class HTMLDocbookTagConverter extends DocbookTagConverter implements TemplateFiller {
51 public static enum GenerationType { WEB, JAVAHELP, CHM, HTML };
53 private static final String SCILAB_URI = "http://www.scilab.org";
54 private static final String LATEXBASENAME = "_LaTeX_";
55 private static final String VERSION = Messages.gettext("Version");
56 private static final String DESCRIPTION = Messages.gettext("Description");
58 private StringBuilder buffer = new StringBuilder(8192);
59 private int latexCompt = 1;
60 private String imageDir;
61 private String urlBase;
62 private boolean linkToTheWeb;
63 private boolean hasExamples;
66 protected String outName;
67 protected String outImages;
69 protected Map<String, String> mapId;
70 protected Map<String, String> tocitem;
71 protected HTMLDocbookLinkResolver.TreeId tree;
72 protected Map<String, HTMLDocbookLinkResolver.TreeId> mapTreeId;
73 protected Map<String, String> mapIdPurpose;
74 protected Map<String, String> mapIdRefname;
76 protected TemplateHandler templateHandler;
78 protected ScilabLexer scilabLexer;
79 protected XMLLexer xmlLexer;
80 protected CLexer cLexer;
81 protected JavaLexer javaLexer;
83 protected String bookTitle = "";
84 protected String partTitle = "";
85 protected String chapterTitle = "";
86 protected String sectionTitle = "";
87 protected String fileSubtitle = "";
89 protected String refpurpose = "";
90 protected String refname = "";
91 protected String version;
92 protected String appendToProgramListing;
93 protected String appendForExecToProgramListing;
94 protected String prependToProgramListing;
95 protected String currentId;
96 protected String indexFilename = "index" /*UUID.randomUUID().toString()*/ + ".html";
97 protected String language;
99 protected boolean isToolbox;
100 protected final GenerationType type;
104 * @param inName the name of the input stream
105 * @param outName the output directory
106 * @param primConf the file containing the primitives of Scilab
107 * @param macroConf the file containing the macros of Scilab
108 * @param template the template to use
109 * @param version the version
110 * @param imageDir the image directory (relative to outName)
111 * @param isToolbox is true when compile a toolbox' help
112 * @param urlBase the base url for external link
114 public HTMLDocbookTagConverter(String inName, String outName, String[] primConf, String[] macroConf, String template, String version, String imageDir, boolean isToolbox, String urlBase, String language, GenerationType type) throws IOException, SAXException {
117 this.version = version;
118 this.imageDir = imageDir;
119 this.outName = outName + File.separator;
120 this.outImages = this.outName;
121 HTMLDocbookLinkResolver resolver = new HTMLDocbookLinkResolver(inName);
122 mapId = resolver.getMapId();
123 tocitem = resolver.getToc();
124 tree = resolver.getTree();
125 mapTreeId = resolver.getMapTreeId();
126 mapIdPurpose = resolver.getMapIdPurpose();
127 mapIdRefname = resolver.getMapIdRefname();
129 scilabLexer = new ScilabLexer(primConf, macroConf);
130 this.urlBase = urlBase;
131 this.linkToTheWeb = urlBase != null && !urlBase.equals("scilab://");
132 this.isToolbox = isToolbox;
133 this.language = language;
135 if (isToolbox) {// we generate a toolbox's help
136 HTMLScilabCodeHandler.setLinkWriter(new AbstractScilabCodeHandler.LinkWriter() {
137 public String getLink(String id) {
138 if (id.length() > 0 && id.charAt(0) == '%') {
139 id = id.replace("%", "percent");
141 String link = mapId.get(id);
143 return HTMLDocbookTagConverter.this.urlBase + id;
149 } else {// we generate Scilab's help
150 HTMLScilabCodeHandler.setLinkWriter(new AbstractScilabCodeHandler.LinkWriter() {
151 public String getLink(String id) {
152 if (id.length() > 0 && id.charAt(0) == '%') {
153 id = id.replace("%", "percent");
155 return mapId.get(id);
160 xmlLexer = new XMLLexer();
161 cLexer = new CLexer();
162 javaLexer = new JavaLexer();
163 File tpl = new File(template);
164 templateHandler = new TemplateHandler(this, tpl, language);
165 ImageConverter.registerExternalImageConverter(LaTeXImageConverter.getInstance(this));
166 ImageConverter.registerExternalImageConverter(MathMLImageConverter.getInstance(this));
167 ImageConverter.registerExternalImageConverter(SVGImageConverter.getInstance(this));
168 ImageConverter.registerExternalImageConverter(ScilabImageConverter.getInstance(this));
169 ImageConverter.registerExternalImageConverter(XcosImageConverter.getInstance(this));
172 public static boolean containsCJK(CharSequence seq) {
177 for (int i = 0; i < seq.length(); i++) {
178 Character.UnicodeBlock block = Character.UnicodeBlock.of(seq.charAt(i));
179 if (block == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
180 || block == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
181 || block == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
182 || block == Character.UnicodeBlock.CJK_COMPATIBILITY_FORMS
183 || block == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
184 || block == Character.UnicodeBlock.CJK_RADICALS_SUPPLEMENT
185 || block == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
186 || block == Character.UnicodeBlock.ENCLOSED_CJK_LETTERS_AND_MONTHS) {
194 public static boolean containsCyrillic(CharSequence seq) {
199 for (int i = 0; i < seq.length(); i++) {
200 Character.UnicodeBlock block = Character.UnicodeBlock.of(seq.charAt(i));
201 if (block == Character.UnicodeBlock.CYRILLIC || block == Character.UnicodeBlock.CYRILLIC_SUPPLEMENTARY) {
210 * Replace special chars
212 public static final String replaceEntity(final String str) {
213 return str.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("\'", "'");
217 * Get the type of the generation
218 * @return the generation type
220 public final GenerationType getGenerationType() {
224 public String getBaseImagePath() {
228 public String getLanguage() {
233 * @return the buffer used
235 public StringBuilder getBuffer() {
240 * @param tag the tag name
241 * @param contents the contents to enclose between opening and closing tags
243 public String encloseContents(final String tag, final String contents) {
248 if (contents != null) {
249 buffer.append(contents);
255 return buffer.toString();
259 * @param tag the tag name
260 * @param attrs the attributes {attr1, value1, attr2, value2, ...}
261 * @param contents the contents to enclose between opening and closing tags
263 public String encloseContents(final String tag, final String[] attrs, final String contents) {
268 for (int i = 0; i < attrs.length; i += 2) {
269 if (attrs[i + 1] != null && !attrs[i + 1].isEmpty()) {
271 buffer.append(attrs[i]);
272 buffer.append("=\"");
273 buffer.append(attrs[i + 1]);
280 if (contents != null) {
281 buffer.append(contents);
287 return buffer.toString();
291 * @param tag the tag name
292 * @param clazz the css class name
293 * @param contents the contents to enclose between opening and closing tags
295 public String encloseContents(final String tag, final String clazz, final String contents) {
299 buffer.append(" class=\"");
300 buffer.append(clazz);
301 buffer.append("\">");
302 if (contents != null) {
303 buffer.append(contents);
309 return buffer.toString();
315 public boolean isEscapable(final String tagName, final String uri) {
316 return !"latex".equals(tagName) && !"screen".equals(tagName) && !"programlisting".equals(tagName) && !"code".equals(tagName) && !"synopsis".equals(tagName) && !(uri.equals(SCILAB_URI) && tagName.equals("image"));
322 public boolean isTrimable(final String tagName) {
323 return !"screen".equals(tagName) && !"programlisting".equals(tagName) && !"code".equals(tagName) && !"synopsis".equals(tagName);
327 * @param fileName the file to create
328 * @param subtitle the subtitle of the file
329 * @param contents the contents of the file
331 public void createHTMLFile(final String id, final String fileName, final String subtitle, final String contents) {
333 fileSubtitle = subtitle;
335 templateHandler.generateFileFromTemplate(outName + fileName, id, contents);
342 public String makeTitle(final String id) {
343 if (refname.length() > 0) {
344 return tocitem.get(id);
353 public String makeSubtitle(final String id) {
360 public String makePrevious(final String id) {
362 buffer.append("<span class=\"previous\">");
363 HTMLDocbookLinkResolver.TreeId leaf = mapTreeId.get(id);
367 HTMLDocbookLinkResolver.TreeId prev = leaf.getPrevious();
368 if (prev.parent != null) {
369 buffer.append("<a href=\"");
370 buffer.append(mapId.get(prev.id));
371 buffer.append("\"><< ");
372 buffer.append(tocitem.get(prev.id));
373 buffer.append("</a></span>\n");
375 return buffer.toString();
384 public String makePath(final String id) {
386 buffer.append("<span class=\"path\">");
387 HTMLDocbookLinkResolver.TreeId leaf = mapTreeId.get(id);
391 String str = tocitem.get(id);
393 while (leaf != null && !leaf.isRoot()) {
394 str = "<a href=\"" + mapId.get(leaf.id) + "\">" + tocitem.get(leaf.id) + "</a> > " + str;
398 str = "<a href=\"" + indexFilename + "\">" + bookTitle + "</a> >> " + str;
400 buffer.append("</span>\n");
402 return buffer.toString();
408 public String makeTop(final String id) {
410 buffer.append("<span class=\"top\">");
411 HTMLDocbookLinkResolver.TreeId leaf = mapTreeId.get(id);
418 buffer.append("<a href=\"");
419 if (!leaf.isRoot()) {
420 buffer.append(mapId.get(leaf.id));
421 buffer.append("\">");
422 buffer.append(tocitem.get(leaf.id));
424 buffer.append(indexFilename);
425 buffer.append("\">");
426 buffer.append(bookTitle);
428 buffer.append("</a></span>\n");
433 return buffer.toString();
439 public String makeNext(final String id) {
441 buffer.append("<span class=\"next\">");
442 HTMLDocbookLinkResolver.TreeId leaf = mapTreeId.get(id);
446 HTMLDocbookLinkResolver.TreeId next = leaf.getNext();
448 buffer.append("<a href=\"");
449 buffer.append(mapId.get(next.id));
450 buffer.append("\">");
451 buffer.append(tocitem.get(next.id));
452 buffer.append(" >></a></span>\n");
454 return buffer.toString();
463 public String makeStart(final String id) {
465 buffer.append("<span class=\"start\">");
466 buffer.append("<a href=\"");
467 buffer.append(indexFilename);
468 buffer.append("\">");
469 buffer.append(bookTitle);
470 buffer.append("</a></span>\n");
472 return buffer.toString();
478 public String makeTocList(final String id) {
480 HTMLDocbookLinkResolver.TreeId leaf = mapTreeId.get(id);
485 HTMLDocbookLinkResolver.TreeId parent = leaf.parent;
486 buffer.append("<ul class=\"toc\">\n");
488 while (parent != null && !parent.isRoot()) {
489 str = "<li class=\"parent\"><a href=\"" + mapId.get(parent.id) + "\">" + tocitem.get(parent.id) + "</a></li>\n" + str;
490 parent = parent.parent;
492 buffer.append("<li class=\"root\"><a href=\"");
493 buffer.append(indexFilename);
494 buffer.append("\">");
495 buffer.append(bookTitle);
496 buffer.append("</a></li>\n");
499 parent = leaf.parent;
501 for (HTMLDocbookLinkResolver.TreeId c : parent.children) {
503 buffer.append("<li class=\"list-active\"><a href=\"");
505 buffer.append("<li><a href=\"");
507 buffer.append(mapId.get(c.id));
508 buffer.append("\">");
509 buffer.append(tocitem.get(c.id));
510 buffer.append("</a></li>\n");
512 buffer.append("</ul>\n");
514 return buffer.toString();
520 public String makeLastModified(final String id) {
523 buffer.append("<span class=\"lastmodified\">");
524 buffer.append(new Date(new File(new URI(currentFileName)).lastModified()).toString());
525 buffer.append("</span>\n");
526 } catch (URISyntaxException e) {
529 return buffer.toString();
535 public String makeGenerationDate(final String id) {
537 buffer.append("<span class=\"generationdate\">");
538 buffer.append(new Date(System.currentTimeMillis()).toString());
539 buffer.append("</span>\n");
541 return buffer.toString();
547 public String makeVersion(final String id) {
549 buffer.append("<span class=\"version\">");
550 buffer.append(version);
551 buffer.append("</span>\n");
553 return buffer.toString();
556 public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
558 return super.resolveEntity(publicId, systemId);
563 * @param attributes the tag attributes
564 * @param contents the tag contents
565 * @return the HTML code
566 * @throws SAXEception if an error is encountered
568 public String handleRefentry(final Map<String, String> attributes, final String contents) throws SAXException {
569 String id = attributes.get("id");
573 String fileName = mapId.get(currentId);
574 String needsExampleAttr = attributes.get("needs-examples");
575 createHTMLFile(currentId, fileName, refpurpose, contents);
576 if (!hasExamples && (needsExampleAttr == null || !needsExampleAttr.equals("no"))) {
578 //System.err.println("Warning (should be fixed): no example in " + currentFileName);
582 String rp = encloseContents("span", "refentry-description", refpurpose);
583 String str = encloseContents("li", encloseContents("a", new String[] {"href", fileName, "class", "refentry"}, refname) + " — " + rp);
593 * @param attributes the tag attributes
594 * @param contents the tag contents
595 * @return the HTML code
596 * @throws SAXEception if an error is encountered
598 public String handleSection(final Map<String, String> attributes, final String contents) throws SAXException {
599 String fileName = attributes.get("id") + ".html";
600 String str = encloseContents("ul", "list-refentry", contents);
601 String title = encloseContents("h3", "title-section", sectionTitle);
602 createHTMLFile(attributes.get("id"), fileName, sectionTitle, title + "\n" + str);
604 str = encloseContents("li", encloseContents("a", new String[] {"href", fileName, "class", "section"}, sectionTitle) + "\n" + str);
612 * @param attributes the tag attributes
613 * @param contents the tag contents
614 * @return the HTML code
615 * @throws SAXEception if an error is encountered
617 public String handleBook(final Map<String, String> attributes, final String contents) throws SAXException {
618 String str = encloseContents("ul", "list-part", contents);
620 if (bookTitle.trim().equalsIgnoreCase("Scilab")) {
625 String title = encloseContents("h3", "book-title", btitle);
626 createHTMLFile("index", indexFilename, btitle, title + "\n" + str);
629 System.err.println("Total files without example: " + warnings);
630 System.err.println("Total generated html files: " + nbFiles);
633 return encloseContents("li", encloseContents("a", new String[] {"href", indexFilename, "class", "part"}, bookTitle) + "\n" + str);
638 * @param attributes the tag attributes
639 * @param contents the tag contents
640 * @return the HTML code
641 * @throws SAXEception if an error is encountered
643 public String handlePart(final Map<String, String> attributes, final String contents) throws SAXException {
644 String fileName = attributes.get("id") + ".html";
645 String str = encloseContents("ul", "list-chapter", contents);
646 String title = encloseContents("h3", "title-part", partTitle);
647 createHTMLFile(attributes.get("id"), fileName, partTitle, title + "\n" + str);
648 str = encloseContents("li", encloseContents("a", new String[] {"href", fileName, "class", "part"}, partTitle) + "\n" + str);
656 * @param attributes the tag attributes
657 * @param contents the tag contents
658 * @return the HTML code
659 * @throws SAXEception if an error is encountered
661 public String handleChapter(final Map<String, String> attributes, final String contents) throws SAXException {
662 String fileName = attributes.get("id") + ".html";
663 String str = encloseContents("ul", "list-refentry", contents);
664 String title = encloseContents("h3", "title-chapter", chapterTitle);
665 createHTMLFile(attributes.get("id"), fileName, chapterTitle, title + "\n" + str);
667 str = encloseContents("li", encloseContents("a", new String[] {"href", fileName, "class", "chapter"}, chapterTitle) + "\n" + str);
673 // partiellement merdique car le style de title depend du noeud pere.
676 * @param attributes the tag attributes
677 * @param contents the tag contents
678 * @return the HTML code
679 * @throws SAXEception if an error is encountered
681 public String handleTitle(final Map<String, String> attributes, final String contents) throws SAXException {
682 String clazz = "title";
683 String parent = getParentTagName();
684 if (parent.equals("chapter")) {
685 chapterTitle = contents;
686 } else if (parent.equals("part")) {
687 partTitle = contents;
688 } else if (parent.equals("info")) {
689 bookTitle = contents;
690 } else if (parent.equals("section")) {
691 sectionTitle = contents;
692 } else if (parent.equals("refsection") && Pattern.matches("^[ \\t]*ex[ea]mpl[eo].*", contents.toLowerCase())) {
694 return encloseContents("h3", clazz, contents);
696 return encloseContents("h3", clazz, contents);
704 * @param attributes the tag attributes
705 * @param contents the tag contents
706 * @return the HTML code
707 * @throws SAXEception if an error is encountered
709 public String handlePara(final Map<String, String> attributes, final String contents) throws SAXException {
710 return encloseContents("p", "para", contents);
715 * @param attributes the tag attributes
716 * @param contents the tag contents
717 * @return the HTML code
718 * @throws SAXEception if an error is encountered
720 public String handleLiteral(final Map<String, String> attributes, final String contents) throws SAXException {
721 return encloseContents("code", "literal", contents);
726 * @param attributes the tag attributes
727 * @param contents the tag contents
728 * @return the HTML code
729 * @throws SAXEception if an error is encountered
731 public String handleVarname(final Map<String, String> attributes, final String contents) throws SAXException {
732 return encloseContents("code", "varname", contents);
737 * @param attributes the tag attributes
738 * @param contents the tag contents
739 * @return the HTML code
740 * @throws SAXEception if an error is encountered
742 public String handleCommand(final Map<String, String> attributes, final String contents) throws SAXException {
743 return encloseContents("code", "command", contents);
748 * @param attributes the tag attributes
749 * @param contents the tag contents
750 * @return the HTML code
751 * @throws SAXEception if an error is encountered
753 public String handleCode(final Map<String, String> attributes, final String contents) throws SAXException {
754 return encloseContents("code", "scilabcode", scilabLexer.convert(HTMLScilabCodeHandler.getInstance(refname, currentFileName), contents));//encloseContents("code", "code", contents);
759 * @param attributes the tag attributes
760 * @param contents the tag contents
761 * @return the HTML code
762 * @throws SAXEception if an error is encountered
764 public String handleFunction(final Map<String, String> attributes, final String contents) throws SAXException {
765 return encloseContents("code", "function", contents);
770 * @param attributes the tag attributes
771 * @param contents the tag contents
772 * @return the HTML code
773 * @throws SAXEception if an error is encountered
775 public String handleConstant(final Map<String, String> attributes, final String contents) throws SAXException {
776 return encloseContents("code", "constant", contents);
781 * @param attributes the tag attributes
782 * @param contents the tag contents
783 * @return the HTML code
784 * @throws SAXEception if an error is encountered
786 public String handleOption(final Map<String, String> attributes, final String contents) throws SAXException {
787 return encloseContents("code", "option", contents);
791 * Handle a refnamediv
792 * @param attributes the tag attributes
793 * @param contents the tag contents
794 * @return the HTML code
795 * @throws SAXEception if an error is encountered
797 public String handleRefnamediv(final Map<String, String> attributes, final String contents) throws SAXException {
798 String id = attributes.get("id");
803 return encloseContents("div", "refnamediv", contents);
808 * @param attributes the tag attributes
809 * @param contents the tag contents
810 * @return the HTML code
811 * @throws SAXEception if an error is encountered
813 public String handleRefname(final Map<String, String> attributes, final String contents) throws SAXException {
815 return encloseContents("h1", "refname", contents);
819 * Handle a refpurpose
820 * @param attributes the tag attributes
821 * @param contents the tag contents
822 * @return the HTML code
823 * @throws SAXEception if an error is encountered
825 public String handleRefpurpose(final Map<String, String> attributes, final String contents) throws SAXException {
826 refpurpose = contents;
827 return encloseContents("p", "refpurpose", contents);
831 * Handle a refsynopsisdiv
832 * @param attributes the tag attributes
833 * @param contents the tag contents
834 * @return the HTML code
835 * @throws SAXEception if an error is encountered
837 public String handleRefsynopsisdiv(final Map<String, String> attributes, final String contents) throws SAXException {
838 String id = attributes.get("id");
840 return "<a name=\"" + id + "\"></a>" + encloseContents("div", "refsynopsisdiv", contents);
842 return encloseContents("div", "refsynopsisdiv", contents);
848 * @param attributes the tag attributes
849 * @param contents the tag contents
850 * @return the HTML code
851 * @throws SAXEception if an error is encountered
853 public String handleSynopsis(final Map<String, String> attributes, final String contents) throws SAXException {
854 String id = attributes.get("id");
855 String str = encloseContents("div", "synopsis", encloseContents("pre", SynopsisLexer.convert(refname, contents)));
857 return "<a name=\"" + id + "\"></a>" + str;
865 * @param attributes the tag attributes
866 * @param contents the tag contents
867 * @return the HTML code
868 * @throws SAXEception if an error is encountered
870 public String handleInfo(final Map<String, String> attributes, final String contents) throws SAXException {
871 String id = attributes.get("id");
873 return "<a name=\"" + id + "\"></a>" + encloseContents("div", "info", contents);
875 return encloseContents("div", "info", contents);
880 * Handle a refsection
881 * @param attributes the tag attributes
882 * @param contents the tag contents
883 * @return the HTML code
884 * @throws SAXEception if an error is encountered
886 public String handleRefsection(final Map<String, String> attributes, final String contents) throws SAXException {
887 String id = attributes.get("id");
889 return "<a name=\"" + id + "\"></a>" + encloseContents("div", "refsection", contents);
891 return encloseContents("div", "refsection", contents);
896 * Handle a progamlisting
897 * @param attributes the tag attributes
898 * @param contents the tag contents
899 * @return the HTML code
900 * @throws SAXEception if an error is encountered
902 public String handleProgramlisting(final Map<String, String> attributes, final String contents) throws SAXException {
903 String id = attributes.get("id");
904 String role = attributes.get("role");
907 String code = encloseContents("pre", "scilabcode", scilabLexer.convert(HTMLScilabCodeHandler.getInstance(refname, currentFileName), contents));
908 if (prependToProgramListing != null) {
909 code = prependToProgramListing + code;
911 if (appendToProgramListing != null) {
912 code += appendToProgramListing;
914 str = encloseContents("div", "programlisting", code);
916 if (role.equals("xml")) {
917 str = encloseContents("div", "programlisting", encloseContents("pre", "xmlcode", xmlLexer.convert(HTMLXMLCodeHandler.getInstance(), contents)));
918 } else if (role.equals("c") || role.equals("cpp") || role.equals("code_gateway")) {
920 str = encloseContents("div", "programlisting", encloseContents("pre", "ccode", cLexer.convert(HTMLCCodeHandler.getInstance(), contents)));
921 } else if (role.equals("java")) {
923 str = encloseContents("div", "programlisting", encloseContents("pre", "ccode", javaLexer.convert(HTMLCCodeHandler.getInstance(), contents)));
924 } else if (role.equals("exec")) {
925 String code = encloseContents("pre", "scilabcode", scilabLexer.convert(HTMLScilabCodeHandler.getInstance(refname, currentFileName), contents));
926 if (prependToProgramListing != null) {
927 code = prependToProgramListing + code;
929 if (appendForExecToProgramListing != null) {
930 code += appendForExecToProgramListing;
932 str = encloseContents("div", "programlisting", code);
933 } else if (role.equals("no-scilab-exec")) {
935 String code = encloseContents("pre", "scilabcode", scilabLexer.convert(HTMLScilabCodeHandler.getInstance(refname, currentFileName), contents));
936 str = encloseContents("div", "programlisting", code);
938 String code = encloseContents("pre", "scilabcode", scilabLexer.convert(HTMLScilabCodeHandler.getInstance(refname, currentFileName), contents));
939 if (prependToProgramListing != null) {
940 code = prependToProgramListing + code;
942 if (appendToProgramListing != null) {
943 code += appendToProgramListing;
945 str = encloseContents("div", "programlisting", code);
949 return "<a name=\"" + id + "\"></a>" + str;
957 * @param attributes the tag attributes
958 * @param contents the tag contents
959 * @return the HTML code
960 * @throws SAXEception if an error is encountered
962 public String handleScreen(final Map<String, String> attributes, final String contents) throws SAXException {
963 String id = attributes.get("id");
964 String str = encloseContents("div", "screen", encloseContents("pre", contents));
966 return "<a name=\"" + id + "\"></a>" + str;
974 * @param attributes the tag attributes
975 * @param contents the tag contents
976 * @return the HTML code
977 * @throws SAXEception if an error is encountered
979 public String handlePubdate(final Map<String, String> attributes, final String contents) throws SAXException {
984 * Handle a simplelist
985 * @param attributes the tag attributes
986 * @param contents the tag contents
987 * @return the HTML code
988 * @throws SAXEception if an error is encountered
990 public String handleSimplelist(final Map<String, String> attributes, final String contents) throws SAXException {
991 String style = "itemizedlist";
993 return encloseContents("ul", style, contents);
998 * @param attributes the tag attributes
999 * @param contents the tag contents
1000 * @return the HTML code
1001 * @throws SAXEception if an error is encountered
1003 public String handleMember(final Map<String, String> attributes, final String contents) throws SAXException {
1004 return encloseContents("li", "member", contents);
1009 * @param attributes the tag attributes
1010 * @param contents the tag contents
1011 * @return the HTML code
1012 * @throws SAXEception if an error is encountered
1014 public String handleLink(final Map<String, String> attributes, final String contents) throws SAXException {
1015 String link = attributes.get("linkend");
1017 throw new SAXException("No linkend attribute in tag link");
1020 String type = attributes.get("type");
1022 if (type != null && type.equals("scilab")) {
1023 if (this.type == GenerationType.JAVAHELP) {
1024 id = resolvScilabLink(link);
1028 } else if (type != null && type.equals("remote")) {
1029 id = makeRemoteLink(link);
1031 id = mapId.get(link);
1036 System.err.println("Warning (should be fixed): invalid internal link to " + link + " in " + currentFileName + "\nat line " + locator.getLineNumber());
1040 Stack<DocbookElement> stack = getStack();
1041 String refnameTarget = mapIdRefname.get(link);
1043 if (contents != null && !contents.isEmpty()) {
1046 str = refnameTarget;
1051 System.err.println("Warning (should be fixed): empty link (no text will be printed) to " + link + " in " + currentFileName + "\nat line " + locator.getLineNumber());
1054 String href = encloseContents("a", new String[] {"href", id, "class", "link"}, str);
1056 int s = stack.size();
1058 DocbookElement elem = stack.get(s - 3);
1059 if (elem.getName().equals("refsection")) {
1060 String role = elem.getAttributes().get("role");
1061 if (role != null && role.equals("see also")) {
1062 String purpose = mapIdPurpose.get(link);
1063 if (purpose != null) {
1064 return href + " — " + purpose;
1076 * Rewrite a link when its type is "scilab"
1077 * @param link the link
1078 * @return the modified link with protocol scilab:// for example
1080 protected String resolvScilabLink(String link) {
1081 int pos = link.indexOf("/");
1085 String first = link.substring(0, pos);
1086 String second = link.substring(pos + 1);
1087 String[] toks = first.split("\\.");
1088 if (toks == null || toks.length != 2) {
1092 if (!linkToTheWeb) {
1093 return urlBase + link;
1095 if (toks[0].equals("scilab") && toks[1].equals("help")) {
1096 return urlBase + second + ".html";
1104 * Make a remote link
1105 * @param link the link
1106 * @return the good link
1108 protected String makeRemoteLink(String link) {
1114 * @param attributes the tag attributes
1115 * @param contents the tag contents
1116 * @return the HTML code
1117 * @throws SAXEception if an error is encountered
1119 public String handleUlink(final Map<String, String> attributes, final String contents) throws SAXException {
1120 String link = attributes.get("url");
1122 throw new SAXException("No url attribute in tag ulink");
1125 return encloseContents("a", new String[] {"href", link, "class", "ulink"}, contents);
1130 * @param attributes the tag attributes
1131 * @param contents the tag contents
1132 * @return the HTML code
1133 * @throws SAXEception if an error is encountered
1135 public String handleXref(final Map<String, String> attributes, final String contents) throws SAXException {
1136 String link = attributes.get("linkend");
1138 throw new SAXException("No linkend attribute in tag link");
1141 String id = mapId.get(link);
1144 System.err.println("Warning (should be fixed): invalid internal link to " + link + " in " + currentFileName + "\nat line " + locator.getLineNumber());
1148 return encloseContents("a", new String[] {"href", id, "class", "xref"}, contents);
1152 * Handle a latex (not really a docbook tag...)
1153 * @param attributes the tag attributes
1154 * @param contents the tag contents
1155 * @return the HTML code
1156 * @throws SAXEception if an error is encountered
1158 public String handleLatex(final Map<String, String> attributes, final String contents) throws SAXException {
1159 boolean isLocalized = "true".equals(attributes.get("localized"));
1162 f = new File(outImages + "/" + imageDir, LATEXBASENAME + currentBaseName + "_" + language + "_" + (latexCompt++) + ".png");
1164 if ("ru_RU".equals(language) && HTMLDocbookTagConverter.containsCyrillic(contents)) {
1165 System.err.println("Warning: LaTeX code in " + getCurrentFileName() + " contains cyrillic character. The tag <latex> should contain the attribute scilab:localized=\"true\"");
1166 } else if ("ja_JP".equals(language) && HTMLDocbookTagConverter.containsCJK(contents)) {
1167 System.err.println("Warning: LaTeX code in " + getCurrentFileName() + " contains CJK character. The tag <latex> should contain the attribute scilab:localized=\"true\"");
1169 f = new File(outImages + "/" + imageDir, LATEXBASENAME + currentBaseName + "_" + (latexCompt++) + ".png");
1172 String parent = getParentTagName();
1173 if (parent.equals("para") && !attributes.containsKey("style")) {
1174 attributes.put("style", "text");
1176 String fs = attributes.get("fontsize");
1178 attributes.put("fontsize", "16");
1180 return ImageConverter.getImageByCode(currentFileName, contents, attributes, "image/latex", f, imageDir + "/" + f.getName(), getBaseImagePath(), locator.getLineNumber(), language, isLocalized);
1185 * @param attributes the tag attributes
1186 * @param contents the tag contents
1187 * @return the HTML code
1188 * @throws SAXEception if an error is encountered
1190 public String handleTerm(final Map<String, String> attributes, final String contents) throws SAXException {
1191 String id = attributes.get("id");
1193 return "<a name=\"" + id + "\"></a>" + encloseContents("span", "term", contents);
1195 return encloseContents("span", "term", contents);
1201 * @param attributes the tag attributes
1202 * @param contents the tag contents
1203 * @return the HTML code
1204 * @throws SAXEception if an error is encountered
1206 public String handleListitem(final Map<String, String> attributes, final String contents) throws SAXException {
1207 String parent = getParentTagName();
1208 if (parent.equals("varlistentry")) {
1209 return encloseContents("dd", contents);
1211 return encloseContents("li", contents);
1215 * Handle a varlistentry
1216 * @param attributes the tag attributes
1217 * @param contents the tag contents
1218 * @return the HTML code
1219 * @throws SAXEception if an error is encountered
1221 public String handleVarlistentry(final Map<String, String> attributes, final String contents) throws SAXException {
1222 return encloseContents("dt", contents);
1226 * Handle a variablelist
1227 * @param attributes the tag attributes
1228 * @param contents the tag contents
1229 * @return the HTML code
1230 * @throws SAXEception if an error is encountered
1232 public String handleVariablelist(final Map<String, String> attributes, final String contents) throws SAXException {
1233 return encloseContents("dl", contents);
1237 * Handle an itemizedlist
1238 * @param attributes the tag attributes
1239 * @param contents the tag contents
1240 * @return the HTML code
1241 * @throws SAXEception if an error is encountered
1243 public String handleItemizedlist(final Map<String, String> attributes, final String contents) throws SAXException {
1244 String id = attributes.get("id");
1246 return "<a name=\"" + id + "\"></a>" + encloseContents("ul", "itemizedlist", contents);
1248 return encloseContents("ul", "itemizedlist", contents);
1253 * Handle an emphasis
1254 * @param attributes the tag attributes
1255 * @param contents the tag contents
1256 * @return the HTML code
1257 * @throws SAXEception if an error is encountered
1259 public String handleEmphasis(final Map<String, String> attributes, final String contents) throws SAXException {
1260 String role = attributes.get("role");
1262 if (role.equals("bold")) {
1263 return encloseContents("b", contents);
1265 if (role.equals("italic")) {
1266 return encloseContents("i", contents);
1270 return encloseContents("em", contents);
1275 * @param attributes the tag attributes
1276 * @param contents the tag contents
1277 * @return the HTML code
1278 * @throws SAXEception if an error is encountered
1280 public String handleTr(final Map<String, String> attributes, final String contents) throws SAXException {
1281 String bgcolor = attributes.get("bgcolor");
1282 return encloseContents("tr", new String[] {"bgcolor", bgcolor}, contents);
1287 * @param attributes the tag attributes
1288 * @param contents the tag contents
1289 * @return the HTML code
1290 * @throws SAXEception if an error is encountered
1292 public String handleTd(final Map<String, String> attributes, final String contents) throws SAXException {
1293 String align = attributes.get("align");
1294 String bgcolor = attributes.get("bgcolor");
1295 return encloseContents("td", new String[] {"align", align, "bgcolor", bgcolor}, contents);
1299 * Handle an informaltable
1300 * @param attributes the tag attributes
1301 * @param contents the tag contents
1302 * @return the HTML code
1303 * @throws SAXEception if an error is encountered
1305 public String handleInformaltable(final Map<String, String> attributes, final String contents) throws SAXException {
1306 String id = attributes.get("id");
1307 String bgcolor = attributes.get("bgcolor");
1308 String border = attributes.get("border");
1309 String cellpadding = attributes.get("cellpadding");
1310 String width = attributes.get("width");
1312 return "<a name=\"" + id + "\"></a>" + encloseContents("table", new String[] {"class", "informaltable", "border", border, "cellpadding", cellpadding, "width", width}, contents);
1314 return encloseContents("table", new String[] {"class", "informaltable", "border", border, "cellpadding", cellpadding, "width", width}, contents);
1319 * Handle an imagedata
1320 * @param attributes the tag attributes
1321 * @param contents the tag contents
1322 * @return the HTML code
1323 * @throws SAXEception if an error is encountered
1325 public String handleImagedata(final Map<String, String> attributes, final String contents) throws SAXException {
1326 String fileref = attributes.get("fileref");
1327 if (fileref == null) {
1328 if (contents == null || contents.length() == 0) {
1329 throw new SAXException("No fileref attribute or no data in tag imagedata");
1336 String path = new File(new URI(currentFileName)).getParent();
1337 File file = ImageConverter.imageExists(path, fileref);
1339 throw new SAXException("The given fileref is not on an existing image file:\n" + fileref + " [" + file + "]");
1342 return ImageConverter.getImageByFile(attributes, path, fileref, outImages, imageDir, getBaseImagePath());
1343 } catch (URISyntaxException e) {
1344 System.err.println(e);
1351 * Handle an imageobject
1352 * @param attributes the tag attributes
1353 * @param contents the tag contents
1354 * @return the HTML code
1355 * @throws SAXEception if an error is encountered
1357 public String handleImageobject(final Map<String, String> attributes, final String contents) throws SAXException {
1362 * Handle an inlinemediaobject
1363 * @param attributes the tag attributes
1364 * @param contents the tag contents
1365 * @return the HTML code
1366 * @throws SAXEception if an error is encountered
1368 public String handleInlinemediaobject(final Map<String, String> attributes, final String contents) throws SAXException {
1369 return encloseContents("span", contents);
1373 * Handle a screenshot
1374 * @param attributes the tag attributes
1375 * @param contents the tag contents
1376 * @return the HTML code
1377 * @throws SAXEception if an error is encountered
1379 public String handleScreenshot(final Map<String, String> attributes, final String contents) throws SAXException {
1380 String id = attributes.get("id");
1382 return "<a name=\"" + id + "\"></a>" + encloseContents("div", "screenshot", contents);
1384 return encloseContents("div", "screenshot", contents);
1389 * Handle a mediaobject
1390 * @param attributes the tag attributes
1391 * @param contents the tag contents
1392 * @return the HTML code
1393 * @throws SAXEception if an error is encountered
1395 public String handleMediaobject(final Map<String, String> attributes, final String contents) throws SAXException {
1396 String id = attributes.get("id");
1397 String c = contents.replaceFirst("top:([0-9]+)px;", "");
1399 return "<a name=\"" + id + "\"></a>" + encloseContents("div", "mediaobject", c);
1401 return encloseContents("div", "mediaobject", c);
1406 * Handle an informalequation
1407 * @param attributes the tag attributes
1408 * @param contents the tag contents
1409 * @return the HTML code
1410 * @throws SAXEception if an error is encountered
1412 public String handleInformalequation(final Map<String, String> attributes, final String contents) throws SAXException {
1413 String id = attributes.get("id");
1415 return "<a name=\"" + id + "\"></a>" + encloseContents("div", "informalequation", contents);
1417 return encloseContents("div", "informalequation", contents);
1422 * Handle an orderedlist
1423 * @param attributes the tag attributes
1424 * @param contents the tag contents
1425 * @return the HTML code
1426 * @throws SAXEception if an error is encountered
1428 public String handleOrderedlist(final Map<String, String> attributes, final String contents) throws SAXException {
1429 String numeration = "1";
1430 String numAttr = attributes.get("numeration");
1431 if (numAttr != null) {
1432 if (numAttr.equals("loweralpha")) {
1434 } else if (numAttr.equals("upperalpha")) {
1436 } else if (numAttr.equals("lowerroman")) {
1438 } else if (numAttr.equals("upperroman")) {
1443 String id = attributes.get("id");
1445 return "<a name=\"" + id + "\"></a>" + encloseContents("ol", new String[] {"type", numeration}, contents);
1447 return encloseContents("ol", new String[] {"type", numeration}, contents);
1452 * Handle a subscript
1453 * @param attributes the tag attributes
1454 * @param contents the tag contents
1455 * @return the HTML code
1456 * @throws SAXEception if an error is encountered
1458 public String handleSubscript(final Map<String, String> attributes, final String contents) throws SAXException {
1459 return encloseContents("sub", contents);
1463 * Handle a superscript
1464 * @param attributes the tag attributes
1465 * @param contents the tag contents
1466 * @return the HTML code
1467 * @throws SAXEception if an error is encountered
1469 public String handleSuperscript(final Map<String, String> attributes, final String contents) throws SAXException {
1470 return encloseContents("sup", contents);
1474 * Handle a replaceable
1475 * @param attributes the tag attributes
1476 * @param contents the tag contents
1477 * @return the HTML code
1478 * @throws SAXEception if an error is encountered
1480 public String handleReplaceable(final Map<String, String> attributes, final String contents) throws SAXException {
1481 return encloseContents("span", "replaceable", contents);
1486 * @param attributes the tag attributes
1487 * @param contents the tag contents
1488 * @return the HTML code
1489 * @throws SAXEception if an error is encountered
1491 public String handleQuestion(final Map<String, String> attributes, final String contents) throws SAXException {
1492 return encloseContents("dt", encloseContents("strong", contents));
1497 * @param attributes the tag attributes
1498 * @param contents the tag contents
1499 * @return the HTML code
1500 * @throws SAXEception if an error is encountered
1502 public String handleAnswer(final Map<String, String> attributes, final String contents) throws SAXException {
1503 return encloseContents("dd", contents);
1507 * Handle a qandaentry
1508 * @param attributes the tag attributes
1509 * @param contents the tag contents
1510 * @return the HTML code
1511 * @throws SAXEception if an error is encountered
1513 public String handleQandaentry(final Map<String, String> attributes, final String contents) throws SAXException {
1514 return encloseContents("dl", contents);
1519 * @param attributes the tag attributes
1520 * @param contents the tag contents
1521 * @return the HTML code
1522 * @throws SAXEception if an error is encountered
1524 public String handleQandaset(final Map<String, String> attributes, final String contents) throws SAXException {
1525 return encloseContents("div", "qandaset", contents);
1530 * @param attributes the tag attributes
1531 * @param contents the tag contents
1532 * @return the HTML code
1533 * @throws SAXEception if an error is encountered
1535 public String handleCaption(final Map<String, String> attributes, final String contents) throws SAXException {
1536 return encloseContents("caption", encloseContents("b", contents));
1541 * @param attributes the tag attributes
1542 * @param contents the tag contents
1543 * @return the HTML code
1544 * @throws SAXEception if an error is encountered
1546 public String handleTbody(final Map<String, String> attributes, final String contents) throws SAXException {
1547 return encloseContents("tbody", "tbody", contents);
1552 * @param attributes the tag attributes
1553 * @param contents the tag contents
1554 * @return the HTML code
1555 * @throws SAXEception if an error is encountered
1557 public String handleTable(final Map<String, String> attributes, final String contents) throws SAXException {
1558 String id = attributes.get("id");
1559 String bgcolor = attributes.get("bgcolor");
1560 String border = attributes.get("border");
1561 String cellpadding = attributes.get("cellpadding");
1564 return "<a name=\"" + id + "\"></a>" + encloseContents("table", new String[] {"class", "doctable", "bgcolor", bgcolor, "border", border, "cellpadding", cellpadding}, contents);
1566 return encloseContents("table", new String[] {"class", "doctable", "bgcolor", bgcolor, "border", border, "cellpadding", cellpadding}, contents);
1572 * @param attributes the tag attributes
1573 * @param contents the tag contents
1574 * @return the HTML code
1575 * @throws SAXEception if an error is encountered
1577 public String handleSurname(final Map<String, String> attributes, final String contents) throws SAXException {
1578 return encloseContents("span", "surname", contents);
1582 * Handle a firstname
1583 * @param attributes the tag attributes
1584 * @param contents the tag contents
1585 * @return the HTML code
1586 * @throws SAXEception if an error is encountered
1588 public String handleFirstname(final Map<String, String> attributes, final String contents) throws SAXException {
1589 return encloseContents("span", "firstname", contents);
1593 * Handle a bibliomset
1594 * @param attributes the tag attributes
1595 * @param contents the tag contents
1596 * @return the HTML code
1597 * @throws SAXEception if an error is encountered
1599 public String handleBibliomset(final Map<String, String> attributes, final String contents) throws SAXException {
1600 String id = attributes.get("id");
1602 return "<a name=\"" + id + "\"></a>" + encloseContents("div", "bibliomset", contents);
1604 return encloseContents("div", "bibliomset", contents);
1609 * Handle a bibliomixed
1610 * @param attributes the tag attributes
1611 * @param contents the tag contents
1612 * @return the HTML code
1613 * @throws SAXEception if an error is encountered
1615 public String handleBibliomixed(final Map<String, String> attributes, final String contents) throws SAXException {
1616 String id = attributes.get("id");
1618 return "<a name=\"" + id + "\"></a>" + encloseContents("div", "bibliomixed", contents);
1620 return encloseContents("div", "bibliomixed", contents);
1626 * @param attributes the tag attributes
1627 * @param contents the tag contents
1628 * @return the HTML code
1629 * @throws SAXEception if an error is encountered
1631 public String handleTh(final Map<String, String> attributes, final String contents) throws SAXException {
1632 return encloseContents("th", contents);
1636 * Handle a revhistory
1637 * @param attributes the tag attributes
1638 * @param contents the tag contents
1639 * @return the HTML code
1640 * @throws SAXEception if an error is encountered
1642 public String handleRevhistory(final Map<String, String> attributes, final String contents) throws SAXException {
1643 String id = attributes.get("id");
1644 String str = "<table class=\"revhistory\"><tr class=\"title\"><td>" + VERSION + "</td><td>" + DESCRIPTION + "</td></tr>" + contents + "</table>";
1646 return "<a name=\"" + id + "\"></a>" + str;
1654 * @param attributes the tag attributes
1655 * @param contents the tag contents
1656 * @return the HTML code
1657 * @throws SAXEception if an error is encountered
1659 public String handleRevision(final Map<String, String> attributes, final String contents) throws SAXException {
1660 return encloseContents("tr", contents);
1664 * Handle a revnumber
1665 * @param attributes the tag attributes
1666 * @param contents the tag contents
1667 * @return the HTML code
1668 * @throws SAXEception if an error is encountered
1670 public String handleRevnumber(final Map<String, String> attributes, final String contents) throws SAXException {
1671 return encloseContents("td", "revnumber", contents);
1675 * Handle a revremark
1676 * @param attributes the tag attributes
1677 * @param contents the tag contents
1678 * @return the HTML code
1679 * @throws SAXEception if an error is encountered
1681 public String handleRevremark(final Map<String, String> attributes, final String contents) throws SAXException {
1682 return encloseContents("td", "revremark", contents);
1686 * Handle a revdescription
1687 * @param attributes the tag attributes
1688 * @param contents the tag contents
1689 * @return the HTML code
1690 * @throws SAXEception if an error is encountered
1692 public String handleRevdescription(final Map<String, String> attributes, final String contents) throws SAXException {
1693 return encloseContents("td", "revdescription", contents);
1698 * @param attributes the tag attributes
1699 * @param contents the tag contents
1700 * @return the HTML code
1701 * @throws SAXEception if an error is encountered
1703 public String handleNote(final Map<String, String> attributes, final String contents) throws SAXException {
1704 String id = attributes.get("id");
1705 String code = "<table><tr><td valign=\"top\"><img src=\"" + getBaseImagePath() + "ScilabNote.png\"/></td><td valign=\"top\">" + encloseContents("div", "note", contents) + "</tr></table>";
1707 return "<a name=\"" + id + "\"></a>" + code;
1715 * @param attributes the tag attributes
1716 * @param contents the tag contents
1717 * @return the HTML code
1718 * @throws SAXEception if an error is encountered
1720 public String handleWarning(final Map<String, String> attributes, final String contents) throws SAXException {
1721 String id = attributes.get("id");
1722 String code = "<table><tr><td valign=\"top\"><img src=\"" + getBaseImagePath() + "ScilabWarning.png\"/></td><td valign=\"top\">" + encloseContents("div", "warning", contents) + "</tr></table>";
1724 return "<a name=\"" + id + "\"></a>" + code;
1732 * @param attributes the tag attributes
1733 * @param contents the tag contents
1734 * @return the HTML code
1735 * @throws SAXEception if an error is encountered
1737 public String handleCaution(final Map<String, String> attributes, final String contents) throws SAXException {
1738 String id = attributes.get("id");
1739 String code = "<table><tr><td valign=\"top\"><img src=\"" + getBaseImagePath() + "ScilabCaution.png\"/></td><td valign=\"top\">" + encloseContents("div", "caution", contents) + "</tr></table>";
1741 return "<a name=\"" + id + "\"></a>" + code;
1749 * @param attributes the tag attributes
1750 * @param contents the tag contents
1751 * @return the HTML code
1752 * @throws SAXEception if an error is encountered
1754 public String handleTip(final Map<String, String> attributes, final String contents) throws SAXException {
1755 String id = attributes.get("id");
1756 String code = "<table><tr><td valign=\"top\"><img src=\"" + getBaseImagePath() + "ScilabTip.png\"/></td><td valign=\"top\">" + encloseContents("div", "tip", contents) + "</tr></table>";
1758 return "<a name=\"" + id + "\"></a>" + code;
1765 * Handle a important
1766 * @param attributes the tag attributes
1767 * @param contents the tag contents
1768 * @return the HTML code
1769 * @throws SAXEception if an error is encountered
1771 public String handleImportant(final Map<String, String> attributes, final String contents) throws SAXException {
1772 String id = attributes.get("id");
1773 String code = "<table><tr><td valign=\"top\"><img src=\"" + getBaseImagePath() + "ScilabImportant.png\"/></td><td valign=\"top\">" + encloseContents("div", "important", contents) + "</tr></table>";
1775 return "<a name=\"" + id + "\"></a>" + code;