* Bug 16081 fixed: prettyprint(): HTML added. Page overhauled. 90/20990/11
Samuel GOUGEON [Wed, 29 May 2019 19:47:18 +0000 (21:47 +0200)]
  http://bugzilla.scilab.org/16081

  PDF page: http://bugzilla.scilab.org/attachment.cgi?id=4962

  Pre-requisite: https://codereview.scilab.org/20966

Change-Id: I8d7a402f7f28ebb309a1cdbbeebc4f2b585ec6ea

23 files changed:
scilab/CHANGES.md
scilab/modules/gui/images/icons/closeBrace.png [new file with mode: 0644]
scilab/modules/gui/images/icons/closeBracket.png [new file with mode: 0644]
scilab/modules/gui/images/icons/closeParen.png [new file with mode: 0644]
scilab/modules/gui/images/icons/openBrace.png [new file with mode: 0644]
scilab/modules/gui/images/icons/openBracket.png [new file with mode: 0644]
scilab/modules/gui/images/icons/openParen.png [new file with mode: 0644]
scilab/modules/helptools/etc/images_md5.txt
scilab/modules/helptools/images/Bache_gui.gif
scilab/modules/helptools/images/PerteDP_gui.gif
scilab/modules/helptools/images/PuitsP_gui.gif
scilab/modules/helptools/images/SourceP_gui.gif
scilab/modules/helptools/images/VanneReglante_gui.gif
scilab/modules/helptools/images/prettyprint_1.png [new file with mode: 0644]
scilab/modules/string/help/en_US/prettyprint.xml
scilab/modules/string/help/images/prettyprint_HTML4_GUI.png [new file with mode: 0644]
scilab/modules/string/help/images/prettyprint_HTML_table_borders.png [new file with mode: 0644]
scilab/modules/string/help/images/prettyprint_LaTeX_MathJax.png [new file with mode: 0644]
scilab/modules/string/help/images/prettyprint_MathML.png [new file with mode: 0644]
scilab/modules/string/help/ja_JP/prettyprint.xml [deleted file]
scilab/modules/string/macros/prettyprint.sci
scilab/modules/string/tests/unit_tests/prettyprint.tst
scilab/modules/string/tests/unit_tests/prettyprint_syslin.tst

index c7695b9..8b7db12 100644 (file)
@@ -115,6 +115,7 @@ Feature changes and additions
 * `profileEnable`, `profileDisable`, `profileGetInfo` could be used to instrument functions and gather execution information within Scilab.
 * `prettyprint` is upgraded:
   - Integer and Text input are now actually supported.
+  - HTML is now supported as output format.
   - Default input arguments can be skipped instead of still having to be provided.
   - The result string is better formatted to be easily wrappable and indented.
 * `mesh2d` has been introduced to compute a 2d mesh from vectors (x,y) of points.
@@ -412,10 +413,11 @@ Bug Fixes
 * [#16072](https://bugzilla.scilab.org/16072): `prettyprint` did not actually support input encoded integers.
 * [#16075](https://bugzilla.scilab.org/16075): `prettyprint` was broken for cells.
 * [#16079](https://bugzilla.scilab.org/16079): `part("",$)` and `part("",$-1:$+2)` yielded an error instead of returning "" and "  ".
+* [#16081](https://bugzilla.scilab.org/16081): `prettyprint` did not allow to export objects into HTML.
 * [#16085](https://bugzilla.scilab.org/16085): insertion in an empty struct was broken.
 * [#16087](https://bugzilla.scilab.org/16087): Insertion of struct in a non-empty struct crashed Scilab.
 * [#16089](https://bugzilla.scilab.org/16089): x=1:1e10 freezed Scilab.
-* [#16090](https://bugzilla.scilab.org/16090): The documentation of `prbs_a()` was poor and unclear.
+* [#16090](https://bugzilla.scilab.org/16090): The documentation of `prbs_a` was poor and unclear.
 * [#16095](https://bugzilla.scilab.org/16095): For a matrix of graphic handles of same types, it was no longer possible to clear a property by assigning [].
 * [#16097](https://bugzilla.scilab.org/16097): `coth` was more than twice slower than `1./tanh()`. `tanh` and `coth` did not accept sparse-encoded input.
 * [#16102](https://bugzilla.scilab.org/16102): `lstcat` could not concatenate input lists with mixed objects of types>10 like 1:$, sin, sind, struct, cells, tlists or mlists. In addition, it was slow for very long inputs lists.
diff --git a/scilab/modules/gui/images/icons/closeBrace.png b/scilab/modules/gui/images/icons/closeBrace.png
new file mode 100644 (file)
index 0000000..d9e0d0b
Binary files /dev/null and b/scilab/modules/gui/images/icons/closeBrace.png differ
diff --git a/scilab/modules/gui/images/icons/closeBracket.png b/scilab/modules/gui/images/icons/closeBracket.png
new file mode 100644 (file)
index 0000000..a8cc11c
Binary files /dev/null and b/scilab/modules/gui/images/icons/closeBracket.png differ
diff --git a/scilab/modules/gui/images/icons/closeParen.png b/scilab/modules/gui/images/icons/closeParen.png
new file mode 100644 (file)
index 0000000..f214741
Binary files /dev/null and b/scilab/modules/gui/images/icons/closeParen.png differ
diff --git a/scilab/modules/gui/images/icons/openBrace.png b/scilab/modules/gui/images/icons/openBrace.png
new file mode 100644 (file)
index 0000000..4d4cbfd
Binary files /dev/null and b/scilab/modules/gui/images/icons/openBrace.png differ
diff --git a/scilab/modules/gui/images/icons/openBracket.png b/scilab/modules/gui/images/icons/openBracket.png
new file mode 100644 (file)
index 0000000..dc4028c
Binary files /dev/null and b/scilab/modules/gui/images/icons/openBracket.png differ
diff --git a/scilab/modules/gui/images/icons/openParen.png b/scilab/modules/gui/images/icons/openParen.png
new file mode 100644 (file)
index 0000000..0d4ba1f
Binary files /dev/null and b/scilab/modules/gui/images/icons/openParen.png differ
index f6e4114..e5e9f87 100644 (file)
@@ -984,6 +984,7 @@ polyline_properties_2.png=3349e39fe563e09fc488e9ed03c6e4ae
 polyline_properties_3.png=0c758a8eb88f3a7383151da8a94cf808
 prbs_a_1.png=4e8551544fa2d2085e74ddfe799ec579
 prbs_a_2.png=ef716bac583e1660fe1f49a4352b7b4b
+prettyprint_1.png=5d60f609825ec81746672b39278e27ad
 rainbowcolormap_1.png=68be57c62080633d0e67a91389f5ecd8
 reglin_1.png=9b22e4b782eb58eb90e5dccd50dfb466
 reglin_2.png=109258bc122deeadf53e2b832d510201
index ba2ffcd..4662c5d 100644 (file)
Binary files a/scilab/modules/helptools/images/Bache_gui.gif and b/scilab/modules/helptools/images/Bache_gui.gif differ
index 3c67dde..ed651bc 100644 (file)
Binary files a/scilab/modules/helptools/images/PerteDP_gui.gif and b/scilab/modules/helptools/images/PerteDP_gui.gif differ
index 34804b1..4da564a 100644 (file)
Binary files a/scilab/modules/helptools/images/PuitsP_gui.gif and b/scilab/modules/helptools/images/PuitsP_gui.gif differ
index aa6d84b..95ff2b6 100644 (file)
Binary files a/scilab/modules/helptools/images/SourceP_gui.gif and b/scilab/modules/helptools/images/SourceP_gui.gif differ
index 9512a39..5e0ce47 100644 (file)
Binary files a/scilab/modules/helptools/images/VanneReglante_gui.gif and b/scilab/modules/helptools/images/VanneReglante_gui.gif differ
diff --git a/scilab/modules/helptools/images/prettyprint_1.png b/scilab/modules/helptools/images/prettyprint_1.png
new file mode 100644 (file)
index 0000000..6fa029c
Binary files /dev/null and b/scilab/modules/helptools/images/prettyprint_1.png differ
index c48e9e9..9ca65e9 100644 (file)
@@ -1,8 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - 2010 - Calixte DENIZET
+ * Copyright (C) 2012 - 2016 - Scilab Enterprises
+ * Copyright (C) 2019 - Samuel GOUGEON
  *
- * The initial version of this help file was generated from prettyprint.sci using help_from_sci().
- * Following versions have been improved only here.
+ * This file is hereby licensed under the terms of the GNU GPL v2.0,
+ * pursuant to article 5.3.4 of the CeCILL v.2.1.
+ * This file was originally licensed under the terms of the CeCILL v2.1,
+ * and continues to be available under such terms.
+ * For more information, see the COPYING file which you should have received
+ * along with this program.
  *
  -->
 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
@@ -12,7 +20,7 @@
     <refnamediv>
         <refname>prettyprint</refname>
         <refpurpose>
-          Converts a Scilab object into some corresponding LaTeX, TeX or MathML string(s)
+          Converts a Scilab object into some corresponding LaTeX, TeX, MathML or HTML strings
         </refpurpose>
     </refnamediv>
     <refsynopsisdiv>
@@ -20,9 +28,9 @@
         <synopsis>
             str = prettyprint(a)
             str = prettyprint(a, exportFormat)
-            str = prettyprint(a, exportFormat, delim)
-            str = prettyprint(a, exportFormat, delim, processByElement)
-            str = prettyprint(a, exportFormat, delim, processByElement, isWrapped)
+            str = prettyprint(a, exportFormat, delimiter)
+            str = prettyprint(a, exportFormat, delimiter, processByElement)
+            str = prettyprint(a, exportFormat, delimiter, processByElement, isWrapped)
         </synopsis>
     </refsynopsisdiv>
     <refsection>
@@ -40,8 +48,8 @@
                                 other Tlists.
                             </listitem>
                             <listitem>
-                                Supported sizes: scalar, vector, matrix. Hypermatrices are
-                                not supported (only the first page is processed.)
+                                Supported sizes: scalar, vector, matrix. Hypermatrices are not
+                                supported (only the first page is processed.)
                             </listitem>
                         </itemizedlist>
                     </para>
                 <listitem>
                     <para>
                       is the output format. Possible case-insensitive values are 'latex' (default),
-                      'tex', or 'mathml'.
+                      'tex', 'mathml', 'html', or 'html4'.
                     </para>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 <term>delimiter</term>
                 <listitem>
-                    <para> is a string indicating the delimiter to bracket the whole
-                       resulting matrix. It is used only if <varname>processByElement</varname> is
-                       false. It can be '(' (default), '{', '[', '|', '||', or '' if no bracketting
-                      is required.
+                    <para> is a string indicating the delimiter type to bracket the whole
+                       resulting matrix. It is only used if <varname>processByElement</varname> is
+                       false. It can be '(' (default), '{', '[', '|', '||', or '' if no bracketing
+                       is required.
+                    </para>
+                    <para>
+                        In HTML, the '_' delimiter value can be used to format the input matrix
+                        without delimiter but with cells borders.
+                    </para>
+                    <para>
+                        <warning>
+                            Delimiters used for the components defining a linear dynamical system
+                            are always "(" and ")", even with <varname>delimiter</varname>="",
+                            unless <varname>exportFormat</varname>="html4" is used: Then, "|"
+                            is imposed as inner syslin delimiter. This is useful when the result
+                            must be rendered in a Scilab GUI like <literal>messagebox()</literal>,
+                            that supports only a restricted version of HTML.4
+                        </warning>
                     </para>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 <term>isWrapped</term>
                 <listitem>
-                    <para> is a boolean to indicate if the result must be wrapped
-                        inside delimiters ('$' for latex and tex or nothing for
-                        mathml) to be used with xstring or xtitle. The default value is %T (true).
+                    <para>
+                        is a boolean to indicate if the result must be wrapped inside technical
+                        delimiters. The default value is %T (true).
+                        The delimiters depend on the export format. It is
+                        <itemizedlist>
+                            <listitem>
+                                '$' for latex and tex
+                            </listitem>
+                            <listitem>
+                                nothing for mathml
+                            </listitem>
+                            <listitem>
+                                <para>
+                                    for HTML:
+                                    <itemizedlist>
+                                        <listitem>
+                                            nothing if <varname>processByElement</varname> is
+                                            <literal>%T</literal> ;
+                                        </listitem>
+                                        <listitem>
+                                            or the opening tag
+                                            <literal>&lt;table valign="middle" cellspacing="0" cellpadding="3" ..></literal>
+                                            otherwise. Note that the "&lt;/table>"
+                                            closure is then always included, even if
+                                            <varname>isWrapped</varname> is <literal>%F</literal>.
+                                            This allows to fully customize the table style and attributes,
+                                            instead of using the default ones.
+                                        </listitem>
+                                    </itemizedlist>
+                                </para>
+                            </listitem>
+                        </itemizedlist>
                     </para>
                 </listitem>
             </varlistentry>
                 <listitem>
                   <para> a single string (if <varname>processByElement</varname> is %F),
                     or a matrix of strings otherwise (with size(str)==size(a)):
-                    the representation of the input <varname>a</varname>.
+                    the representation of the input object <varname>a</varname>.
                   </para>
                 </listitem>
             </varlistentry>
     <refsection>
         <title>Description</title>
         <para>
-            Taking a variable, the prettyprint function will provide a formatted representation of it.
-            Formats can be TeX, LaTeX or MathML.
-            They can be used in third party applications but also within Scilab with the most of the
-            <link linkend="math_rendering_features_in_graphic">Scilab graphic features</link>.
+            <literal>prettyprint()</literal> provides a formatted representation of a Scilab object.
+            The format can be TeX, LaTeX, MathML, or HTML.
+        </para>
+        <para>
+            The result can be used in third party applications, or within Scilab: Almost all graphic
+            functions requiring or accepting some text input support it as LaTeX expressions
+            (see <link linkend="math_rendering_features_in_graphic">Scilab graphic features</link>).
         </para>
+        <para>
+            In addition, some GUI features accept and render HTML inputs. The special export format
+            'html4' must be used to display linear dynamical systems in a Scilab GUI like messagebox().
+        </para>
+        <warning>
+            When an array of cells includes some matrices or other arrays, the same chosen delimiters
+            are used for the cells array and for its elements that are also arrays.
+        </warning>
+        <note>
+            <para>
+            The output format of all decimal numbers included in the input object is driven by the
+            <literal>format()</literal> function.
+            </para>
+        </note>
+        <refsect3>
+            <title>Rendering some MathML or/and LaTeX codes in a HTML page:</title>
+            <para>
+                Only the Firefox web browser supports natively the &lt;math> MathML tag,
+                that can embed some mathML code, and renders it.
+            </para>
+            <para>
+                To render MathML code in <emphasis>any</emphasis> web browser,
+                <itemizedlist>
+                    <listitem>
+                        put the following HTML instruction only once before the first use of
+                        <literal>&lt;math></literal>:
+                        &lt;script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async/>.
+                        This is typically done in the <literal>&lt;head>..&lt;/head></literal>
+                        section of the HTML page.
+                    </listitem>
+                    <listitem>
+                        put every set of MathML instructions between <literal>&lt;math>..&lt;/math></literal>.
+                    </listitem>
+                </itemizedlist>
+            </para>
+            <note>
+                <para>
+                    The same <literal>&lt;script..></literal> instruction declaring the
+                    <emphasis>MathJax</emphasis> package can be used to parse and render
+                    LaTeX expressions directly written in the HTML code, embedded between
+                    <literal>\[ ..\]</literal> brackets instead of
+                    <literal>&lt;math>..&lt;/math></literal>.
+                </para>
+                <para>
+                    Hence, the HTML code of a page can mix some LaTeX and MathML instructions
+                    that will be parsed and rendered accordingly.
+                </para>
+           </note>
+            <para>Please see examples provided in the dedicated section below.</para>
+        </refsect3>
     </refsection>
     <refsection>
         <title>Examples</title>
@@ -117,14 +221,381 @@ prettyprint(rand(3,4),"mathml","[") // Return the MathML representation of a 3,4
 s=poly(0,'s'); G=[1,s;1+s^2,3*s^3];
 xstring(0.2,0.2,prettyprint(G*s-1)); // Show a polynomial through a LaTeX representation
  ]]></programlisting>
+    <para/>
+    <para>
+        <emphasis role="bold">
+            Set of objects to be defined before using them in all next examples:
+        </emphasis>
+    </para>
+        <programlisting role="example"><![CDATA[
+bool = [ %t %t ; %f %t ]
+i16 = int16([
+  26595  1212  4257 -4466  9784
+  -4226  3404  5743    3  10032
+  30471     6 14918  267     30 ])
+num = [-123.45, %inf, 5.427e-123
+        %nan  ,  0  , -%inf ]
+cx = [complex(1,%nan), complex(-1.25d-12, 2)
+      complex(%inf,6.1e167), complex(1,-%inf)]
+p  = [[0*%z ; %z], (%i-%z).^[1 3;2 4]]; string(p)
+text = ["André''s got 50% of 1430 $, & the ""remainder"" 1 month later."
+        "x=A\B is such that A*x=B, with A in {a<b, 1-a, ~a, ^a}. _#"]
+ce = {["a b"; "cdefg"], %t, %z./[%z-1, %z^2+1] ; (1-%s)^3, %pi, int8(rand(2,3)*200)}
+
+A = grand(3,3,"uin",-999,999)/100;
+B = grand(3,2,"uin",-999,999)/100;
+C = grand(2,3,"uin",-999,999)/100;
+linsys = syslin("c", A, B, C);
+
+L = list("Booleans:", bool, "int16:", i16, "Decimal numbers:", num, ..
+         "Complex numbers:", cx, "Polynomials:", p, "Text:", text, ..
+         "Cells array, embedding rationals:", ce, "Linear dynamical system:");
+ ]]></programlisting>
+    <screen><![CDATA[
+--> bool = [ %t %t; %f %t ];
+ bool  =
+  T T
+  F T
+
+--> i16 = int16([
+  >   26595  1212  4257 -4466  9784
+  >   -4226  3404  5743    3  10032
+  >   30471     6 14918  267     30 ])
+ i16  =
+  26595  1212  4257 -4466  9784
+ -4226  3404  5743    3  10032
+  30471    6  14918  267    30
+
+
+--> num = [-123.45, %inf, 5.427e-123
+  >         %nan  ,  0  , -%inf ]
+ num  =
+  -123.45   Inf   0.
+   Nan      0.   -Inf
+
+
+--> cx = [complex(1,%nan), complex(-1.25d-12, 2)
+  >       complex(%inf,6.1e167), complex(1,-%inf)]
+ cx  =
+   1. + Nani         -1.250D-12 + 2.i
+   Inf + 6.10D+167i   1. - Infi
+
+
+--> p  = [[0*%z ; %z], (%i-%z).^[1 3;2 4]]; string(p)
+ ans  =
+!                                 2   3      !
+!0  i - z           - i + 3z + 3iz - z       !
+!                                            !
+!                2              2     3   4  !
+!z  - 1 - 2iz + z   1 + 4iz - 6z - 4iz + z   !
+
+
+--> text = ["André''s got 50% of 1430 $, & the ""remainder"" 1 month later."
+  >         "x=A\B is such that A*x=B, with A in {a<b, 1-a, ~a, ^a}. _#"]
+ text  =
+!André's got 50% of 1430 $, & the "remainder" 1 month later.  !
+!x=A\B is such that A*x=B, with A in {a<b, 1-a, ~a, ^a}. _#   !
+
+
+--> ce = makecell([2 3],["a b"; "cdefg"], %t, %z./[%z-1, %z^2+1], ..
+                        (1-%s)^3, %pi, int8(rand(2,3)*200))
+ ce  =
+  [2x1 string    ]  [1x1 boolean ]  [    r   ]
+  [1x1 polynomial]  [1x1 constant]  [2x3 int8]
+]]></screen>
+    <para/>
+    <para>
+        <emphasis role="bold">Export to LaTeX format</emphasis>:
+    </para>
+    <programlisting role="example"><![CDATA[
+// Please run the first example section to define objects to be converted,
+// before executing this section.
+prettyprint(bool, "latex")
+prettyprint(i16, "latex")
+prettyprint(num, "latex")
+prettyprint(cx, "latex")
+prettyprint(p, "latex")
+prettyprint(text, "latex")
+prettyprint(ce, "latex")
+prettyprint(linsys, "latex", "")
+ ]]></programlisting>
+    <screen><![CDATA[
+--> prettyprint(bool, "latex")
+ ans  =
+ ${\begin{pmatrix}T&T\cr F&T\cr \end{pmatrix}}$
+
+--> prettyprint(i16, "latex")
+ ans  =
+ ${\begin{pmatrix}26595&1212&4257&-4466&9784\cr -4226&3404&5743&3&10032\cr 3047
+ 1&6&14918&267&30\cr \end{pmatrix}}$
+
+--> prettyprint(num, "latex")
+ ans  =
+ ${\begin{pmatrix}-123.45&{\infty}&5.43\!\times\!10^{-123}\cr {\mathrm{NaN}}&0&
+ {-\infty}\cr \end{pmatrix}}$
+
+--> prettyprint(cx, "latex")
+ ans  =
+ ${\begin{pmatrix}1+{\mathrm{NaN}}i&-1.250\!\times\!10^{-12}+2i\cr {\infty}+6.1
+ 0\!\times\!10^{167}i&1{-\infty}i\cr \end{pmatrix}}$
+
+--> prettyprint(p, "latex")
+ ans  =
+ ${\begin{pmatrix}0z&i-z &-i+3z +3iz^{2} -z^{3} \cr z &-1-2iz +z^{2} &1+4iz -6z
+ ^{2} -4iz^{3} +z^{4} \cr \end{pmatrix}}$
+
+--> prettyprint(text, "latex")
+ ans  =
+ ${\begin{pmatrix}\mathsf{\text{André's got 50\% of 1430 \$, \& the "remainder"
+  1 month later.}}\cr \mathsf{\text{x=A\backslash\!B is such that A*x=B, with A
+  in \{a\!<\!b, 1-a, \sim\!a, \^\;\,a\}. _#}}\cr \end{pmatrix}}$
+
+--> prettyprint(ce, "latex")
+ ans  =
+ ${\begin{pmatrix}{\begin{pmatrix}\mathsf{\text{a b}}\cr \mathsf{\text{cdefg}}\
+ cr \end{pmatrix}}&T&{\begin{pmatrix}{\frac{z }{-1+z }}&{\frac{z }{1+z^{2} }}\c
+ r \end{pmatrix}}\cr 1-3s +3s^{2} -s^{3} &3.1415927&{\begin{pmatrix}51&23&-121\
+ cr 125&122&66\cr \end{pmatrix}}\cr \end{pmatrix}}$
+
+--> prettyprint(linsys, "latex", "")
+ ans  =
+ ${\begin{matrix}{\left\{\begin{array}{rcl}\dot{X}(t)&=&{\begin{pmatrix}9.35&-5
+ .94&-1.21\cr 6.65&-6.92&2.83\cr 2.49&2.7&0.34\cr \end{pmatrix}} X(t)+{\begin{p
+ matrix}-0.11&-8.3\cr 1.84&7.45\cr -4.93&-1.35\cr \end{pmatrix}}U(t)\cr Y(t) &=
+ & {\begin{pmatrix}5.45&5.61&0.94\cr -5.82&5.41&0.14\cr \end{pmatrix}} X(t) \en
+ d{array}\right.}\cr \end{matrix}}$
+]]></screen>
+    <para/>
+    <para>
+        <emphasis role="bold">Export to LaTeX and rendering in a graphic figure</emphasis>:
+    </para>
+    <programlisting role="example"><![CDATA[
+// Please run the first example section to define objects to be converted,
+// before executing this section.
+y = 1.;
+clf
+gcf().axes_size = [500 670];
+gca().margins = 0.01*[1 1 1 1];
+for obj = L
+    if type(obj)<>10 | part(obj,$)<>":"
+        obj = prettyprint(obj, "latex");
+    end
+    r = stringbox(obj, 0, 0);
+    y = y - strange(r(2,:))-0.015;
+    xstring(0.1, y, obj);
+end
+obj = prettyprint(linsys,"latex","")
+y = y - strange(stringbox(obj, 0, 0)(2,:))-0.02;
+xstring(0.1, y, obj);
+set(gca().children, "fractional_font","on", "font_size",2.5);
+ ]]></programlisting>
+    <scilab:image><![CDATA[
+        bool = [ %t %t; %f %t ]
+        i16 = int16([
+          26595  1212  4257 -4466  9784
+          -4226  3404  5743    3  10032
+          30471     6 14918  267     30 ])
+        num = [-123.45, %inf, 5.427e-123
+                %nan  ,  0  , -%inf ]
+        cx = [complex(1,%nan), complex(-1.25d-12, 2)
+              complex(%inf,6.1e167), complex(1,-%inf)]
+        p  = [[0*%z ; %z], (%i-%z).^[1 3;2 4]]; string(p)
+        text = ["André''s got 50% of 1430 $, & the ""remainder"" 1 month later."
+                "x=A\B is such that A*x=B, with A in {a<b, 1-a, ~a, ^a}. _#"]
+        ce = {["a b"; "cdefg"], %t, %z./[%z-1, %z^2+1] ; (1-%s)^3, %pi, int8(rand(2,3)*200)}
+
+        A = grand(3,3,"uin",-999,999)/100;
+        B = grand(3,2,"uin",-999,999)/100;
+        C = grand(2,3,"uin",-999,999)/100;
+        linsys = syslin("c", A, B, C);
+
+        L = list("Booleans:", bool, "int16:", i16, "Decimal numbers:", num, ..
+                 "Complex numbers:", cx, "Polynomials:", p, "Text:", text, ..
+                 "Cells array, embedding rationals:", ce, "Linear dynamical system:");
+        y = 1.;
+        clf
+        gcf().axes_size = [500 670];
+        gca().margins = 0.01*[1 1 1 1];
+        for obj = L
+            if type(obj)<>10 | part(obj,$)<>":"
+                obj = prettyprint(obj, "latex");
+            end
+            r = stringbox(obj, 0, 0);
+            y = y - strange(r(2,:))-0.015;
+            xstring(0.1, y, obj);
+        end
+        obj = prettyprint(linsys,"latex","")
+        y = y - strange(stringbox(obj, 0, 0)(2,:))-0.02;
+        xstring(0.1, y, obj);
+        set(gca().children, "fractional_font","on", "font_size",2.5);
+    ]]></scilab:image>
+    <para/>
+    <para>
+        <emphasis role="bold">Export to LaTeX and rendering in a HTML.5 page for any web browser</emphasis>,
+        using MathJax:
+    </para>
+    <programlisting role="example"><![CDATA[
+// Please run the first example section to define objects to be converted,
+// before executing this section.
+//
+// Header:
+mathjaxURL = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"
+html = ["<!doctype html>"
+        "<html>"
+        "<meta http-equiv=""Content-Type"" content=""text/html;charset=UTF-8"">"
+        "<script src=''" + mathjaxURL + "'' async></script>"
+        "<!-- then any LaTeX expression delimited with \[ .. \] will be rendered -->"
+        "<body>"
+        ];
+// List of objects:
+for obj = L
+    if type(obj)<>10 | part(obj,$)<>":"
+        obj = prettyprint(obj, "latex", "(", %f, %f);
+        html = [html ; "\[ "+ obj + "\]" ; "<br/>"];
+    else
+        html = [html ; obj + " <br/>"];
+    end
+end
+html = [html ; "\[ "+ prettyprint(linsys, "latex", "") + "\]<br/><br/>"];
+// Footer:
+html = [html ; "</body>" ; "</html>"];
+File = TMPDIR + filesep() + "prettyprint_mathjax.html"
+mputl(html, File);
+
+edit(File)     // See the HTML code
+winopen(File)  // Display the page in your browser
+ ]]></programlisting>
+    <para/>
+    <para>
+        Please note that for text input, the protection needed for some special LaTeX characters
+        is displayed as is by MathJax:
+    </para>
+    <inlinemediaobject>
+        <imageobject>
+            <imagedata fileref="../images/prettyprint_LaTeX_MathJax.png"/>
+        </imageobject>
+    </inlinemediaobject>
+    <para/>
+    <para/>
+    <para>
+        <emphasis role="bold">MathML:</emphasis> Exporting Scilab objects into MathML, and
+        rendering them in a HTML page using the &lt;math> tag.
+        We still use <emphasis>MathJax</emphasis> to render the code in any web browser:
+    </para>
+    <programlisting role="example"><![CDATA[
+// Please run the first example section to define objects to be converted,
+// before executing this section.
+//
+// Header:
+mathjaxURL = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"
+html = ["<!doctype html>"
+        "<html>"
+        "<head>"
+        "<meta http-equiv=""Content-Type"" content=""text/html;charset=UTF-8"">"
+        "<script src=''" + mathjaxURL + "'' async></script>"
+        "<!-- then any MathML expression embedded in <math>..</math> will be rendered -->"
+        "</head>"
+        "<body>"
+        ];
+// List of objects:
+for obj = L
+    if type(obj)<>10 | part(obj,$)<>":"
+        obj = prettyprint(obj, "mathml", "(", %f, %f);
+        html = [html ; "<math>" ; obj ; "</math><br/><br/>"];
+    else
+        html = [html ; obj + " <br/>"];
+    end
+end
+html = [html ; "<math>" ; prettyprint(linsys, "mathml", "") ; "</math>"];
+// Footer:
+html = [html ; "</body>" ; "</html>"];
+File = TMPDIR + filesep() + "prettyprint_mathML.html"
+mputl(html, File);
+
+editor(File)   // See the HTML and MathML code
+winopen(File)  // Render the page in your browser
+ ]]></programlisting>
+    <inlinemediaobject>
+        <imageobject>
+            <imagedata fileref="../images/prettyprint_MathML.png"/>
+        </imageobject>
+    </inlinemediaobject>
+    <para/>
+    <para/>
+    <para>
+        <emphasis role="bold">Export in HTML(4) for rendering in messagebox()</emphasis>:
+        Only the "|" or "||" delimiters can be used (or "" for no delimiter").
+        In addition, "_" is used in HTML mode to get any table with borders:
+    </para>
+    <programlisting role="example"><![CDATA[
+// Please run the first example section to define objects to be converted,
+// before executing this section.
+//
+// Header:
+html = ["<!doctype html>"
+        "<html>"
+        "<meta http-equiv=""Content-Type"" content=""text/html;charset=UTF-8"">"
+        "<body>"
+        ];
+// List of objects:
+for obj = L
+    if type(obj)<>10 | part(obj,$)<>":"
+        obj = prettyprint(obj, "html", "|");
+        html = [html ; obj ; "<br/><br/>"];
+    else
+        html = [html ; obj + " <br/>"];
+    end
+end
+html = [html ; prettyprint(linsys, "html", "|4")];
+// Footer:
+html = [html ; "</body>" ; "</html>"];
+File = TMPDIR + filesep() + "prettyprint_HTML.html"
+mputl(html, File);
+
+edit(File)     // See the HTML code
+winopen(File)  // Display the page in your browser
+messagebox(html, "prettyprint() test => messagebox(HTML.4)");
+ ]]></programlisting>
+    <para/>
+    <para>Rendering in a messagebox():</para>
+    <inlinemediaobject>
+        <imageobject>
+            <imagedata fileref="../images/prettyprint_HTML4_GUI.png"/>
+        </imageobject>
+    </inlinemediaobject>
+    <para/>
+    <para>
+        Still in HTML, using "_" to get table borders:
+    </para>
+    <programlisting role="example"><![CDATA[
+// Please run the first example section to define i16, before executing this section.
+
+messagebox(["The table is:" ; "<br>" ; prettyprint(i16,"html","_")])
+ ]]></programlisting>
+    <para/>
+    <inlinemediaobject>
+        <imageobject>
+            <imagedata fileref="../images/prettyprint_HTML_table_borders.png"/>
+        </imageobject>
+    </inlinemediaobject>
+
     </refsection>
     <refsection role="see also">
         <title>See also</title>
         <simplelist type="inline">
             <member>
+                <ulink url="https://www.mathjax.org">MathJax</ulink>
+            </member>
+            <member>
+                <ulink url="http://www.w3.org/1998/Math/MathML">MathML namespace</ulink>
+            </member>
+            <member>
                 <link linkend="math_rendering_features_in_graphic">math_rendering_features_in_graphic</link>
             </member>
             <member>
+                <link linkend="format">format</link>
+            </member>
+            <member>
                 <link linkend="xnumb">xnumb</link>
             </member>
             <member>
@@ -153,6 +624,12 @@ xstring(0.2,0.2,prettyprint(G*s-1)); // Show a polynomial through a LaTeX repres
                     Function introduced.
                 </revdescription>
             </revision>
+            <revision>
+                <revnumber>6.1.0</revnumber>
+                <revdescription>
+                    Export to HTML added.
+                </revdescription>
+            </revision>
         </revhistory>
     </refsection>
 </refentry>
diff --git a/scilab/modules/string/help/images/prettyprint_HTML4_GUI.png b/scilab/modules/string/help/images/prettyprint_HTML4_GUI.png
new file mode 100644 (file)
index 0000000..6e06c62
Binary files /dev/null and b/scilab/modules/string/help/images/prettyprint_HTML4_GUI.png differ
diff --git a/scilab/modules/string/help/images/prettyprint_HTML_table_borders.png b/scilab/modules/string/help/images/prettyprint_HTML_table_borders.png
new file mode 100644 (file)
index 0000000..59997e4
Binary files /dev/null and b/scilab/modules/string/help/images/prettyprint_HTML_table_borders.png differ
diff --git a/scilab/modules/string/help/images/prettyprint_LaTeX_MathJax.png b/scilab/modules/string/help/images/prettyprint_LaTeX_MathJax.png
new file mode 100644 (file)
index 0000000..2052309
Binary files /dev/null and b/scilab/modules/string/help/images/prettyprint_LaTeX_MathJax.png differ
diff --git a/scilab/modules/string/help/images/prettyprint_MathML.png b/scilab/modules/string/help/images/prettyprint_MathML.png
new file mode 100644 (file)
index 0000000..7bdf735
Binary files /dev/null and b/scilab/modules/string/help/images/prettyprint_MathML.png differ
diff --git a/scilab/modules/string/help/ja_JP/prettyprint.xml b/scilab/modules/string/help/ja_JP/prettyprint.xml
deleted file mode 100644 (file)
index 81f9516..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- *
- * This help file was generated from prettyprint.sci using help_from_sci().
- *
- -->
-<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
-          xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns3="http://www.w3.org/1999/xhtml"
-          xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
-          xmlns:scilab="http://www.scilab.org" xml:id="prettyprint" xml:lang="ja">
-    <refnamediv>
-        <refname>prettyprint</refname>
-        <refpurpose>Scilabデータ型からTeX, LaTeXまたはMathML形式の出力を得る</refpurpose>
-    </refnamediv>
-    <refsynopsisdiv>
-        <title>呼び出し手順</title>
-        <synopsis>
-            str = prettyprint(a) // デフォルト形式 (LaTeX)で変数を表示
-            str = prettyprint(a, exportFormat) // 指定された形式で変数を表示
-            str = prettyprint(a, exportFormat, delim) // 上と同様ですが,デリミタを変更
-            str = prettyprint(a, exportFormat, delim, processByElement) // 上と同様ですが,各要素を独立に処理
-            str = prettyprint(a, exportFormat, delim, processByElement, isWrapped) // 上と同様ですが,TeXまたはLaTeXエクスポートのspecialキーワードを追加
-        </synopsis>
-    </refsynopsisdiv>
-    <refsection>
-        <title>Pパラメータ</title>
-        <variablelist>
-            <varlistentry>
-                <term>a</term>
-                <listitem>
-                    <para>a Scilab object.
-                        <itemizedlist>
-                            <listitem>
-                                Supported types: booleans, encoded integers, real or complex numbers,
-                                polynomials and rationals with real or complex coefficients, texts,
-                                cells, linear dynamical systems (as generated with syslin()),
-                                other Tlists.
-                            </listitem>
-                            <listitem>
-                                Supported sizes: scalar, vector, matrix. Hypermatrices are
-                                not supported (only the first page is processed.)
-                            </listitem>
-                        </itemizedlist>
-                    </para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
-                <term>exportFormat</term>
-                <listitem>
-                    <para>出力形式で,省略された場合はデフォルトで'latex'が使用されます.
-                        'latex', 'tex' または 'mathml'とすることができます. It is case-insensitive.
-                    </para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
-                <term>delimiter</term>
-                <listitem>
-                    <para> 結果の行列で使用されるデリミタを示す文字列で,
-                        isWrappedがtrueの場合にみ使用されます.
-                        It can be '(' (default), '{', '[', '|', '||', or '' if no bracketting
-                        is required.
-                    </para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
-                <term>processByElement</term>
-                <listitem>
-                    <para> 結果の行列が一つの文字列に変換されるかどうかを設定する論理値.</para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
-                <term>isWrapped</term>
-                <listitem>
-                    <para>xstring または xtitleで使用される際,
-                        結果がデリミタ(latexおよびtexの場合は'$',mathmlの場合はなし)で
-                        括られるかどうかを設定する論理値.
-                    </para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
-                <term>str</term>
-                <listitem>
-                    <para>変数aの表現</para>
-                </listitem>
-            </varlistentry>
-        </variablelist>
-    </refsection>
-    <refsection>
-        <title>説明</title>
-        <para>
-            変数を指定すると,
-            prettyprint 関数はこれを整形した結果を出力します.
-            形式はTeX, LaTeX または MathMLです.
-            これらはサードパーティアプリケーションだけでなく,
-            Scilab内でも多くの
-            <link linkend="math_rendering_features_in_graphic">Scilabグラフィック機能</link>で
-            使用できます.
-        </para>
-    </refsection>
-    <refsection>
-        <title>例</title>
-        <programlisting role="example"><![CDATA[
-str = prettyprint(rand(3,3)) // 3x3 行列のLaTeX表現を返す
-xstring(0.2,0.2,str) // グラフィックウインドウに表示
-prettyprint(rand(3,4),"mathml") // 3x4行列のMathML表現を返す
-prettyprint(rand(3,4),"mathml","[") // 3x4行列のMathML表現を'['をデリミタとして 返す
-s=poly(0,'s'); G=[1,s;1+s^2,3*s^3];
-xstring(0.2,0.2,prettyprint(G*s-1)); // LaTeX表現により多項式を表示
- ]]></programlisting>
-    </refsection>
-    <refsection role="see also">
-        <title>参照</title>
-        <simplelist type="inline">
-            <member>
-                <link linkend="math_rendering_features_in_graphic">math_rendering_features_in_graphic</link>
-            </member>
-            <member>
-                <link linkend="xnumb">xnumb</link>
-            </member>
-            <member>
-                <link linkend="string">string</link>
-            </member>
-            <member>
-                <link linkend="pol2str">pol2str</link>
-            </member>
-            <member>
-                <link linkend="msprintf">msprintf</link>
-            </member>
-            <member>
-                <link linkend="uicontrol">uicontrol(table)</link>
-            </member>
-            <member>
-                <link linkend="sci2exp">sci2exp</link>
-            </member>
-        </simplelist>
-    </refsection>
-    <refsection role="history">
-        <title>履歴</title>
-        <revhistory>
-            <revision>
-                <revnumber>5.2.0</revnumber>
-                <revdescription>
-                    Function introduced.
-                </revdescription>
-            </revision>
-        </revhistory>
-    </refsection>
-</refentry>
index f0766c5..ad9633a 100644 (file)
@@ -11,7 +11,7 @@
 // along with this program.
 
 function str = prettyprint(a, exportFormat, delimiter, processByElement, isWrapped)
-    // From any Scilab datatype and provide a representation to the TeX, LaTeX or MathML formats
+    // Provides a representation of a Scilab object to the TeX, LaTeX, MathML or HTML formats
     //
     // Syntax
     // str = prettyprint(a) // Show the variable a with the default format (LaTeX)
@@ -83,8 +83,15 @@ function str = prettyprint(a, exportFormat, delimiter, processByElement, isWrapp
     if type(exportFormat) <> 10 then
         error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"prettyprint",2));
     end
-    if type(delimiter) <> 10 | and(delimiter <> ["(" "[" "|" "||" "{" ""]) then
-        error(msprintf(gettext("%s: Wrong value for input argument #%d: ''%s'', ''%s'', ''%s'', ''%s'', ''%s'' or ''%s'' expected.\n"),"prettyprint",3,"(","[","|","||","{",""));
+    exportFormat = convstr(exportFormat)
+    html4 = exportFormat=="html4"
+    if html4
+        exportFormat = "html"
+    end
+    tmp = ["(" "[" "|" "||" "{" "_" ""]
+    if type(delimiter) <> 10 | ..
+        (and(delimiter <> tmp) & and(part(delimiter,1)<>tmp)) then
+        error(msprintf(gettext("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"), "prettyprint", 3, "''('' ''['' ''|'' ''||'' ''{'' ''_'' ''''"));
     end
     if type(processByElement) <> 4 then
         error(msprintf(gettext("%s: Wrong type for argument #%d: Boolean expected.\n"),"prettyprint",4));
@@ -93,19 +100,31 @@ function str = prettyprint(a, exportFormat, delimiter, processByElement, isWrapp
         error(msprintf(gettext("%s: Wrong type for argument #%d: Boolean expected.\n"),"prettyprint",5));
     end
 
-    // ---------------------
+    // -----------
     try
         execstr("[plus,minus,img,op,cp,ow,cw,d2s]=" + exportFormat + "conf()");
     catch
         error(msprintf(gettext("%s: Wrong export format: %s"),"prettyprint",exportFormat));
     end
 
-    typ = type(a);
+    if exportFormat=="html"
+        dest = strsubst(fileparts(TMPDIR),"\","/")
+        if ~isfile(dest+"closeBrace.png")
+            // We copy all delimiters icons in TMPDIR/..
+            f = ["openBrace"  "openBracket"  "openParen" ..
+                 "closeBrace" "closeBracket" "closeParen"]+".png"
+            src = SCI+"/modules/gui/images/icons/";
+            for s = f
+                copyfile(src+s, dest+s)
+            end
+        end
+    end
 
+    typ = type(a);
 
     select typ
     case 1 then
-        // number : real or complex
+        // Real or complex number
         if or(isinf(a) | isnan(a)) | norm(imag(a)) > %eps * norm(real(a)) then
             str = comp2str(a,plus,minus,img,d2s);
         else
@@ -113,7 +132,7 @@ function str = prettyprint(a, exportFormat, delimiter, processByElement, isWrapp
         end
 
     case 2 then
-        //Polynomial type
+        // Polynomial type
         x = varn(a);
         C = coeff(a);
         [m,n] = size(a);
@@ -136,7 +155,7 @@ function str = prettyprint(a, exportFormat, delimiter, processByElement, isWrapp
                 end
             end
         end
-        //The null polynomial is represented by '' so we must replace it by '0z'
+        // The null polynomial is represented by '' so we must replace it by '0z'
         if exportFormat=="mathml"
             str(str == "") = d2s(0) + "<mi>" + x + "</mi>";
         else
@@ -144,17 +163,17 @@ function str = prettyprint(a, exportFormat, delimiter, processByElement, isWrapp
         end
 
     case 4 then
-        //Boolean type
+        // Boolean type
         str = "F" + emptystr(a);
         str(a) = "T";
         execstr("str=" + exportFormat + "exp(str,1)");
 
     case 8 then
-        //Int type
+        // Int type
         str = d2s(a);
 
     case 10 then
-        //String type
+        // String type
         if or(exportFormat == ["tex" "latex"])
             a = strsubst(a, "\", "\backslash\!")
             a = strsubst(a, "$", "\$")
@@ -177,21 +196,27 @@ function str = prettyprint(a, exportFormat, delimiter, processByElement, isWrapp
             a = strsubst(a, "<", "&lt;")
             // " ' and & do not need protection
             execstr("a = " + exportFormat + "exp(a,1)");
+        elseif exportFormat == "html"
+            a = strsubst(a, "&", "&amp;")
+            a = strsubst(a, "<", "&lt;")
         end
         str = a;
 
     case 16 then
-        //Tlist type
+        // Tlist type
         t = a(1);
         select t(1)
-            //Rationnal type
+            // Rationnal type
         case "r" then
             num = prettyprint(a("num"), exportFormat, "(", %T, %F);
             den = prettyprint(a("den"), exportFormat, "(", %T, %F);
-            execstr("str=rational2" + exportFormat + "(num,den)");
-            //Linear state space type
+            execstr("str = rational2" + exportFormat + "(num, den)");
+            // Linear state space type
         case "lss" then
-            execstr("str=lss2" + exportFormat + "(a)");
+            execstr("str = lss2" + exportFormat + "(a)");
+            if exportFormat=="html"
+                return
+            end
         else
             str = unknown_type(t(1),a,exportFormat);
             return;
@@ -201,33 +226,33 @@ function str = prettyprint(a, exportFormat, delimiter, processByElement, isWrapp
         tof = typeof(a);
         select tof
         case "ce" then
-            //Cell type
+            // Cell type
             dim = double(size(a));
             L = length(dim);
             if L >= 3 then
-                str = unknown_type("ce",a,exportFormat);
+                str = unknown_type("ce", a, exportFormat);
                 return;
             end
             str = emptystr(dim(1),dim(2));
+            iswrapped = exportFormat=="html"
             for i = 1:dim(1) do
                 for j = 1:dim(2) do
-                    str(i,j) = prettyprint(a{i,j},exportFormat,delimiter,%F,%F);
+                    str(i,j) = prettyprint(a{i,j}, exportFormat, delimiter, %F, iswrapped);
                 end
             end
         else
-            str = unknown_type(tof,a,exportFormat);
+            str = unknown_type(tof, a, exportFormat);
             return;
         end
     else
-        str = unknown_type(typeof(a),a,exportFormat);
+        str = unknown_type(typeof(a), a, exportFormat);
         return
     end
 
     [m,n] = size(a);
-    if m*n <> 1 & ~processByElement then
+    if (m*n <> 1 & ~processByElement) // | (exportFormat=="html" & isWrapped) then
         execstr("str=" + exportFormat + "matrix(str,''" + delimiter + "'')");
     end
-
     if isWrapped then
         str = ow + str + cw;
     end
@@ -320,12 +345,12 @@ function str = mathmlmatrix(mat,delimiter)
         com = "<mfenced open=""("" close="")"">";
     case "|" then
         com = "<mfenced open=""&#x2223;"" close=""&#x2223;"">";
-    case "" then
-        com = "<mfenced open="""" close="""">";
     case "{" then
         com = "<mfenced open=""{"" close=""}"">";
     case "||" then
         com = "<mfenced open=""&#x2225;"" close=""&#x2225;"">";
+    case "" then
+        com = "<mfenced open="""" close="""">";
     else
         com = "<mfenced open=""("" close="")"">";
     end
@@ -364,17 +389,193 @@ function str = lss2mathml(sys)
             str = str + "</mtd></mtr>"
         else
             str = str + "<mo>+</mo>" + prettyprint(sys(5),"mathml","(",%F,%F) + ..
-            "<mrow><mi>U</mi>" + ptp + "</mrow></mtd></mtr>" 
+            "<mrow><mi>U</mi>" + ptp + "</mrow></mtd></mtr>"
         end
     catch
         str = str + "<mo>+</mo>" + prettyprint(sys(5),"mathml","(",%F,%F) + ..
-            "<mrow><mi>U</mi>" + ptp + "</mrow></mtd></mtr>" 
+            "<mrow><mi>U</mi>" + ptp + "</mrow></mtd></mtr>"
     end
     str = str + nl + "</mtable>" + nl + "</mfenced>" + nl;
 endfunction
 
 // ----------------------------------------------------------------------------
 
+// HTML
+// ====
+function [plus,minus,img,op,cp,ow,cw,d2s] = htmlconf()
+    plus = " + ";
+    minus = " - ";
+    img = "i";
+    op = "(";
+    cp = ")";
+    ow = "";
+    cw = "";
+    d2s = htmldbl2str;
+endfunction
+
+//This function generates var^n (useful for polynomials)
+function str = htmlexp(var,n)
+    if n >= 2 then
+        str = var  + "<sup>" + msprintf("%d\n",n) + "</sup> "
+    elseif n == 1 then
+        str = var
+    else
+        str = ""
+    end
+endfunction
+
+//This function creates a fraction with the given numerator and denominator
+function str = rational2html(num,den)
+    str = "<table align=""center"" cellspacing=""0"" cellpadding=""1"" border=""0"">" + ..
+             "<tr><td>" + num + "</td></tr>" + ..
+             "<tr><td><hr></td></tr>" + ..
+             "<tr><td>" + den + "</td></tr>" + ..
+           "</table>";
+endfunction
+
+//This function converts a double into a mathml string
+//Negative and positive are handled and the scientific notation too
+function str = htmldbl2str(x)
+    if x == %inf then
+        str = "∞";
+    elseif x == -%inf then
+        str = "- ∞";
+    elseif isnan(x) then
+        str = "NaN";
+    else
+        str = string(x)
+        if type(x) <> 8 & strindex(str,"D") <> []
+            str = strsubst(str,"D+","D");
+            str = strsubst(str,"D","&#x00D7;10<sup>");
+            str = str + "</sup>";
+        end
+    end
+endfunction
+
+//This function generates a matrix with the given delimiter
+function str = htmlmatrix(mat, delimiter, isWrapped)
+    nl = ascii(10)
+    mat = "<td>" + mat + "</td>"
+    mat = "<tr align=""center"">" + nl + ..
+          strcat(mat,nl,"c") + nl + "</tr>" + nl;
+    str = strcat(mat) + "</table>" + nl
+    //
+    if isWrapped then
+        // We put the opening <table with all required attributes
+        // Otherwise only the closing </table> is set (above)
+        tmp = "7px"
+        if part(delimiter,1)=="(", tmp = "5px", end
+        tmp = "style=""padding: 5px 10px; " + ..
+              "background: " + ..
+                "url(file:///" + dest + "open€€.png) left top, " + ..
+                "url(file:///" + dest + "close€€.png) right top; " + ..
+              "background-size: " + tmp + " 100%; background-repeat:no-repeat; "
+        tmp2 = "style=""border-left:hidden; border-right:hidden; "
+        tmp3 = "<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" "+..
+               "style=""display:inline-table;"">" + nl
+
+        if grep(delimiter,"(")<>[]
+            tmp = strsubst(tmp, "€€", "Paren")
+            tmp3 = strsubst(tmp3, "style=""", tmp)
+        elseif grep(delimiter,"[")<>[]
+            tmp = strsubst(tmp, "€€", "Bracket")
+            tmp3 = strsubst(tmp3, "style=""", tmp)
+        elseif grep(delimiter,"{")<>[]
+            tmp = strsubst(tmp, "€€", "Brace")
+            tmp3 = strsubst(tmp3, "style=""", tmp)
+        elseif grep(delimiter,"||")<>[]
+            tmp = strsubst(tmp2, "hidden", "double 3px")
+            tmp3 = strsubst(tmp3, "style=""", tmp)
+        elseif grep(delimiter,"|")<>[]
+            if grep(delimiter,"_")<>[]
+                tmp = strsubst(tmp2, "hidden", "solid 2px")
+            else
+                tmp = strsubst(tmp2, "hidden", "solid 1px")
+            end
+            tmp3 = strsubst(tmp3, "style=""", tmp)
+        end
+        str = nl + tmp3 + str
+        if grep(delimiter,"_")<>[] then
+            str = strsubst(str, "<table ", ..
+                                "<table border=""1"" ");
+            str = strsubst(str, "style=""",..
+             "style=""border-collapse:collapse; border-style:solid; border-width:0px; ");
+        end
+    end     // if isWrapped
+endfunction
+
+//This function handles the syslin
+function str = lss2html(sys)
+    ptp = "(t)";
+    nl = ascii(10);
+    if html4
+        delim = "|"
+        str = "<table style=""display:inline-table; border-left: solid 1px; border-right:hidden;"">" + nl
+    else
+        delim = "("
+        str = "<table style=""display:inline-table; padding: 5px 10px; "+..
+            "background: url(file:///" + dest + "openBrace.png) left top; "+..
+            "background-size: 7px 100%; background-repeat:no-repeat;"">" + nl
+    end
+    // In messagebox(msg) (HTML 4), "nowrap" is not taken into account
+    //  => we must put all elements in separated <td> along each row.
+
+    // Row #1
+    str = str + "<tr>" + nl + "<td nowrap style=""white-space:nowrap"">" + nl
+    if sys(7) == "c" then
+        der = "<table><tr><td>dX<br><hr>dt</td><td>" + ptp + "</td></tr></table>"
+    else
+        der = "X<sup>+</sup>" + ptp
+    end
+    str = str + der + nl + "</td>" + nl + "<td>=</td>" + nl
+    if ~html4 then
+        str = str + "<td nowrap=""nowrap"" style=""white-space:nowrap"">" + nl
+        str = str + prettyprint(sys(2), "html", delim, %F, %T) + " X" + ptp + " + " + nl
+        str = str + prettyprint(sys(3), "html", delim, %F, %T) + " U" + ptp + nl
+        str = str + "</td>" + nl + "</tr>" + nl
+    else
+        str = str + "<td align=""right"">" + nl
+        str = str + prettyprint(sys(2), "html", delim, %F, %T) + nl
+        str = str + "</td>" + nl
+        str = str + "<td>X" + ptp + "&nbsp;&nbsp;+ " + "</td>" + nl
+        str = str + "<td align=""right"">" + nl
+        str = str + prettyprint(sys(3), "html", delim, %F, %T) + nl
+        str = str + "</td>" + nl
+        str = str + "<td>U" + ptp + "</td>" + nl
+        str = str + "</tr>" + nl
+    end
+    // Row #2
+    str = str + "<tr>" + nl + "<td nowrap style=""white-space:nowrap"">" + nl
+    str = str + "Y" + ptp + "</td>" + nl + "<td>=</td>" + nl
+    str = str + "<td nowrap=""nowrap"" style=""white-space:nowrap"">" + nl
+    str = str + prettyprint(sys(4),"html",delim, %F, %T)
+    hasD = %T
+    try
+        hasD = norm(sys(5),1) <> 0
+    end
+    if ~html4 then
+        str = str + " X" + ptp + nl
+        if hasD then
+            str = str + " + " + nl
+            str = str + prettyprint(sys(5), "html", delim, %F, %T) + " U" + ptp + nl
+        end
+    else
+        str = str + nl + "</td>" + nl + "<td>X" + ptp
+        if ~hasD then
+            str = str + "</td>" + nl + "<td></td><td></td>" + nl
+        else
+            str = str + "&nbsp;&nbsp;+ " + "</td>" + nl
+            str = str + "<td align=""right"">" + nl
+            str = str + prettyprint(sys(5), "html", delim, %F, %T) + "</td>" + nl
+            str = str + "<td>U" + ptp + "</td>" + nl
+        end
+    end
+    // Closures
+    str = str + "</tr>" + nl + "</table>" + nl
+endfunction
+
+// ----------------------------------------------------------------------------
+
 // LATEX
 // =====
 function [plus,minus,img,op,cp,ow,cw,d2s] = latexconf()
@@ -473,11 +674,11 @@ function str = latexmatrix(mat,delimiter)
             str = str + strcat(mat(i,:),"&") + "\cr ";
         end
     end
-
     str = str + "\end{" + com + "}}";
 endfunction
 
 // ----------------------------------------------------------------------------
+
 // TEX
 // ===
 function [plus,minus,img,op,cp,ow,cw,d2s] = texconf()
@@ -562,7 +763,7 @@ function str = texmatrix(mat,delimiter)
     str = str + "}}";
 endfunction
 
-// ==========================================================================
+// ----------------------------------------------------------------------------
 
 //This function converts a complex (or a double) into a string in using the
 //function d2s (double2string) fixed by mathmlconf or latexconf.
@@ -625,6 +826,7 @@ function str = comp2coef(z,var,plus,minus,img,op,cp,d2s)
         end
         return;
     end
+    // Scalar case
     re = real(z);
     im = imag(z);
     if var <> "" & var <> " " then
@@ -654,6 +856,8 @@ function str = comp2coef(z,var,plus,minus,img,op,cp,d2s)
     end
 endfunction
 
+// ----------------------------------------------------------------------------
+
 function str = unknown_type(typ,a,exportFormat)
     try
         execstr("str=" + typ + "2" + exportFormat + "(a)");
index 258200b..a4412fe 100644 (file)
@@ -11,6 +11,7 @@
 
 // syslin objects: tests in prettyprint_syslin.tst
 
+TMP = strsubst(fileparts(TMPDIR), "\", "/");
 
 // TEXTS
 // =====
@@ -40,11 +41,17 @@ ref = [""
 ref = strcat(ref, ascii(10));
 assert_checkequal(prettyprint(text, "mathml"), ref);
 
+// HTML > 4
+ref = "£<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""padding: 5px 10px; background: url(file:///"+TMP+"openParen.png) left top, url(file:///"+TMP+"closeParen.png) right top; background-size: 5px 100%; background-repeat:no-repeat; display:inline-table;"">£<tr align=""center"">£<td>André''s got 50% of 1430 $, &amp; the ""remainder"" 1 month later.</td>£</tr>£<tr align=""center"">£<td>x=A\B is such that A*x=B, with A in {a&lt;b, 1-a, ~a, ^a}. _#</td>£</tr>£</table>£";
+ref = strsubst(ref, "£", ascii(10));
+assert_checkequal(prettyprint(text, "html"), ref);
+
 
 // DECIMAL NUMBERS
 // ===============
 assert_checkequal(prettyprint(%inf), "${\infty}$");
 assert_checkequal(prettyprint(%inf,"mathml"), "<mi>∞</mi>");
+assert_checkequal(prettyprint(%inf,"html"), "∞");
 
 ref = "${\begin{pmatrix}{\infty}&0&1&{-\infty}\cr \end{pmatrix}}$";
 assert_checkequal(prettyprint([%inf 0  1 -%inf]), ref);
@@ -137,6 +144,7 @@ assert_checkequal(prettyprint(B,"mathml"), ref);
 c = complex(0,%nan);
 assert_checkequal(prettyprint(c), "${\mathrm{NaN}}i$");
 assert_checkequal(prettyprint(c,"mathml"), "<mi>NaN</mi><mi>i</mi>");
+assert_checkequal(prettyprint(c,"html"), "NaNi");
 
 //
 c = [complex(1,%nan), complex(-1.25d-12, 2)
@@ -146,6 +154,11 @@ assert_checkequal(prettyprint(c), ref);
 ref = "${\pmatrix{1+{\mathrm{NaN}}i&-1.250\!\times\!10^{-12}+2i\cr {\infty}+6.10\!\times\!10^{167}i&1{-\infty}i\cr }}$";
 assert_checkequal(prettyprint(c,"tex"), ref);
 
+// HTML
+ref = "£<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""padding: 5px 10px; background: url(file:///"+TMP+"openParen.png) left top, url(file:///"+TMP+"closeParen.png) right top; background-size: 5px 100%; background-repeat:no-repeat; display:inline-table;"">£<tr align=""center"">£<td>1 + NaNi</td>£<td>-1.250&#x00D7;10<sup>-12</sup> + 2i</td>£</tr>£<tr align=""center"">£<td>∞ + 6.10&#x00D7;10<sup>167</sup>i</td>£<td>1- ∞i</td>£</tr>£</table>£";
+ref = strsubst(ref, "£", ascii(10));
+assert_checkequal(prettyprint(c,"html"), ref);
+
 
 // INTEGERS
 // ========
@@ -153,15 +166,12 @@ i = int16([
   26595  1212  4257 -4466  9784
   -4226  3404  5743    3  10032
   30471     6 14918  267     30 ]);
-
 // LaTeX
 ref = "${\begin{pmatrix}26595&1212&4257&-4466&9784\cr -4226&3404&5743&3&10032\cr 30471&6&14918&267&30\cr \end{pmatrix}}$";
 assert_checkequal(prettyprint(i), ref);
-
 // TeX
 ref = "${\pmatrix{26595&1212&4257&-4466&9784\cr -4226&3404&5743&3&10032\cr 30471&6&14918&267&30\cr }}$";
 assert_checkequal(prettyprint(i, "tex"), ref);
-
 // MathML
 ref  = [""
 "<mfenced open=""("" close="")"">"
@@ -193,6 +203,11 @@ ref  = [""
 ref = strcat(ref, ascii(10));
 assert_checkequal(prettyprint(i, "mathml"), ref);
 
+// HTML
+ref = "£<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""border-left:solid 1px; border-right:solid 1px; display:inline-table;"">£<tr align=""center"">£<td>26595</td>£<td>1212</td>£<td>4257</td>£<td>-4466</td>£<td>9784</td>£</tr>£<tr align=""center"">£<td>-4226</td>£<td>3404</td>£<td>5743</td>£<td>3</td>£<td>10032</td>£</tr>£<tr align=""center"">£<td>30471</td>£<td>6</td>£<td>14918</td>£<td>267</td>£<td>30</td>£</tr>£</table>£";
+ref = strsubst(ref, "£", ascii(10));
+assert_checkequal(prettyprint(i, "html", "|"), ref);
+
 
 // BOOLEANS
 // ========
@@ -221,15 +236,22 @@ ref = [""
 ref = strcat(ref, ascii(10));
 assert_checkequal(prettyprint(C,"mathml"), ref);
 
+// HTML
+ref = "£<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""border-left:solid 1px; border-right:solid 1px; display:inline-table;"">£<tr align=""center"">£<td>T</td>£<td>T</td>£</tr>£<tr align=""center"">£<td>F</td>£<td>T</td>£</tr>£</table>£";
+ref = strsubst(ref, "£", ascii(10));
+assert_checkequal(prettyprint(C,"html","|"), ref);
+
 
 // POLYNOMIALS
 // ===========
 assert_checkequal(prettyprint(0*%z), "$0z$");
 assert_checkequal(prettyprint(0*%z, "tex"), "$0z$");
 assert_checkequal(prettyprint(0*%z, "mathml"), "<mn>0</mn><mi>z</mi>");
+assert_checkequal(prettyprint(0*%z, "html"), "0z");
 
 p = 1+%s+2*%s^2;
 assert_checkequal(prettyprint(p), "$1+s +2s^{2} $");
+assert_checkequal(prettyprint(p, "html"), "1 + s + 2s<sup>2</sup> ");
 
 D = poly(B,"s");
 DResultLatex="$1.553\!\times\!10^{47}-1.738\!\times\!10^{47}s +8.994\!\times\!10^{46}s^{2} -2.885\!\times\!10^{46}s^{3} +6.474\!\times\!10^{45}s^{4} -1.086\!\times\!10^{45}s^{5} +1.422\!\times\!10^{44}s^{6} -1.493\!\times\!10^{43}s^{7} +1.284\!\times\!10^{42}s^{8} -9.182\!\times\!10^{40}s^{9} +5.527\!\times\!10^{39}s^{10} -2.824\!\times\!10^{38}s^{11} +1.233\!\times\!10^{37}s^{12} -4.626\!\times\!10^{35}s^{13} +1.496\!\times\!10^{34}s^{14} -4.182\!\times\!10^{32}s^{15} +1.011\!\times\!10^{31}s^{16} -2.116\!\times\!10^{29}s^{17} +3.826\!\times\!10^{27}s^{18} -5.965\!\times\!10^{25}s^{19} +7.990\!\times\!10^{23}s^{20} -9.144\!\times\!10^{21}s^{21} +8.876\!\times\!10^{19}s^{22} -7.234\!\times\!10^{17}s^{23} +4.885\!\times\!10^{15}s^{24} -2.683\!\times\!10^{13}s^{25} +1.167\!\times\!10^{11}s^{26} -3.868\!\times\!10^{08}s^{27} +916980.98s^{28} -1384.5606s^{29} +s^{30} $";
@@ -272,6 +294,22 @@ ref = [""
 ref = strcat(ref, ascii(10));
 assert_checkequal(prettyprint(p, "mathml"), ref);
 
+// HTML > 4
+ref = [""
+"<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""border-left:solid 1px; border-right:solid 1px; display:inline-table;"">"
+"<tr align=""center"">"
+"<td>i - z</td>"
+"<td> - i + 3z + 3iz<sup>2</sup>  - z<sup>3</sup> </td>"
+"</tr>"
+"<tr align=""center"">"
+"<td>-1-2iz + z<sup>2</sup> </td>"
+"<td>1 + 4iz-6z<sup>2</sup> -4iz<sup>3</sup>  + z<sup>4</sup> </td>"
+"</tr>"
+"</table>"
+""];
+ref = strcat(ref, ascii(10));
+assert_checkequal(prettyprint(p,"html","|"), ref);
+
 // 2) ---------
 p = poly(complex([1 0 -2],[%nan 0 -1]),"x","coeff");
 // LaTeX
@@ -281,6 +319,8 @@ assert_checkequal(prettyprint(p,"tex"), "$1+{\mathrm{NaN}}i-(2+i)x^{2} $");
 // MathML
 ref = "<mn>1</mn><mo>+</mo><mi>NaN</mi><mi>i</mi><mo>-</mo><mfenced separator=""""><mrow><mn>2</mn><mo>+</mo><mi>i</mi></mrow></mfenced><msup><mi>x</mi><mn>2</mn></msup> ";
 assert_checkequal(prettyprint(p,"mathml"), ref);
+// HTML
+assert_checkequal(prettyprint(p,"html"), "1 + NaNi - (2 + i)x<sup>2</sup> ");
 
 
 // CELLS
@@ -322,3 +362,13 @@ ref = [""
 ""];
 ref = strcat(ref, ascii(10));
 assert_checkequal(prettyprint(c, "mathml", "{"), ref);
+
+// HTML
+ref = "£<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""border-left:solid 1px; border-right:solid 1px; display:inline-table;"">£<tr align=""center"">£<td>£<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""border-left:solid 1px; border-right:solid 1px; display:inline-table;"">£<tr align=""center"">£<td>a bc</td>£</tr>£<tr align=""center"">£<td>defg</td>£</tr>£</table>£</td>£<td>T</td>£</tr>£<tr align=""center"">£<td>1-3s + 3s<sup>2</sup>  - s<sup>3</sup> </td>£<td>3.1415927</td>£</tr>£</table>£";
+ref = strsubst(ref, "£", ascii(10));
+assert_checkequal(prettyprint(c, "html", "|"), ref);
+
+// HTML again
+ref = "£<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""padding: 5px 10px; background: url(file:///"+TMP+"openParen.png) left top, url(file:///"+TMP+"closeParen.png) right top; background-size: 5px 100%; background-repeat:no-repeat; display:inline-table;"">£<tr align=""center"">£<td>£<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""padding: 5px 10px; background: url(file:///"+TMP+"openParen.png) left top, url(file:///"+TMP+"closeParen.png) right top; background-size: 5px 100%; background-repeat:no-repeat; display:inline-table;"">£<tr align=""center"">£<td>a bc</td>£</tr>£<tr align=""center"">£<td>defg</td>£</tr>£</table>£</td>£<td>T</td>£</tr>£<tr align=""center"">£<td>1-3s + 3s<sup>2</sup>  - s<sup>3</sup> </td>£<td>3.1415927</td>£</tr>£</table>£";
+ref = strsubst(ref, "£", ascii(10));
+assert_checkequal(prettyprint(c, "html"), ref);
index c3e21d0..8ce4ad9 100644 (file)
@@ -100,6 +100,16 @@ ref = [""
 ref = strcat(ref, ascii(10));
 assert_checkequal(prettyprint(s, "mathml"), ref);
 
+// HTML > 4
+ref = "<table style=""display:inline-table; padding: 5px 10px; background: url(file:///"+TMP+"openBrace.png) left top; background-size: 7px 100%; background-repeat:no-repeat;"">£<tr>£<td nowrap style=""white-space:nowrap"">£<table><tr><td>dX<br><hr>dt</td><td>(t)</td></tr></table>£</td>£<td>=</td>£<td nowrap=""nowrap"" style=""white-space:nowrap"">££<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""padding: 5px 10px; background: url(file:///"+TMP+"openParen.png) left top, url(file:///"+TMP+"closeParen.png) right top; background-size: 5px 100%; background-repeat:no-repeat; display:inline-table;"">£<tr align=""center"">£<td>2.02</td>£<td>7.14</td>£<td>-8.59</td>£</tr>£<tr align=""center"">£<td>-9.99</td>£<td>-9.64</td>£<td>-1.27</td>£</tr>£<tr align=""center"">£<td>5.59</td>£<td>7.25</td>£<td>7.44</td>£</tr>£</table>£ X(t) + ££<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""padding: 5px 10px; background: url(file:///"+TMP+"openParen.png) left top, url(file:///"+TMP+"closeParen.png) right top; background-size: 5px 100%; background-repeat:no-repeat; display:inline-table;"">£<tr align=""center"">£<td>4.46</td>£<td>-0.62</td>£</tr>£<tr align=""center"">£<td>8.42</td>£<td>-3.3</td>£</tr>£<tr align=""center"">£<td>-2.67</td>£<td>9.04</td>£</tr>£</table>£ U(t)£</td>£</tr>£<tr>£<td nowrap style=""white-space:nowrap"">£Y(t)</td>£<td>=</td>£<td nowrap=""nowrap"" style=""white-space:nowrap"">££<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""padding: 5px 10px; background: url(file:///"+TMP+"openParen.png) left top, url(file:///"+TMP+"closeParen.png) right top; background-size: 5px 100%; background-repeat:no-repeat; display:inline-table;"">£<tr align=""center"">£<td>-7.72</td>£<td>6.86</td>£<td>-6.75</td>£</tr>£<tr align=""center"">£<td>-4.58</td>£<td>-3.59</td>£<td>-8.06</td>£</tr>£</table>£ X(t)£</tr>£</table>£";
+ref = strsubst(ref,"£",ascii(10));
+assert_checkequal(prettyprint(s, "html"), ref);
+
+// HTML 4
+ref = "<table style=""display:inline-table; border-left: solid 1px; border-right:hidden;"">£<tr>£<td nowrap style=""white-space:nowrap"">£<table><tr><td>dX<br><hr>dt</td><td>(t)</td></tr></table>£</td>£<td>=</td>£<td align=""right"">££<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""border-left:solid 1px; border-right:solid 1px; display:inline-table;"">£<tr align=""center"">£<td>2.02</td>£<td>7.14</td>£<td>-8.59</td>£</tr>£<tr align=""center"">£<td>-9.99</td>£<td>-9.64</td>£<td>-1.27</td>£</tr>£<tr align=""center"">£<td>5.59</td>£<td>7.25</td>£<td>7.44</td>£</tr>£</table>££</td>£<td>X(t)&nbsp;&nbsp;+ </td>£<td align=""right"">££<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""border-left:solid 1px; border-right:solid 1px; display:inline-table;"">£<tr align=""center"">£<td>4.46</td>£<td>-0.62</td>£</tr>£<tr align=""center"">£<td>8.42</td>£<td>-3.3</td>£</tr>£<tr align=""center"">£<td>-2.67</td>£<td>9.04</td>£</tr>£</table>££</td>£<td>U(t)</td>£</tr>£<tr>£<td nowrap style=""white-space:nowrap"">£Y(t)</td>£<td>=</td>£<td nowrap=""nowrap"" style=""white-space:nowrap"">££<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""border-left:solid 1px; border-right:solid 1px; display:inline-table;"">£<tr align=""center"">£<td>-7.72</td>£<td>6.86</td>£<td>-6.75</td>£</tr>£<tr align=""center"">£<td>-4.58</td>£<td>-3.59</td>£<td>-8.06</td>£</tr>£</table>££</td>£<td>X(t)</td>£<td></td><td></td>£</tr>£</table>£";
+ref = strsubst(ref,"£",ascii(10));
+assert_checkequal(prettyprint(s, "html4", "("), ref);
+
 // Discrete states (and improper syslin):
 // -------------------------------------
 s = syslin("d", A, B, C, [1+%s, 1-%s; -%s, %s]);
@@ -194,3 +204,87 @@ ref = [""
 ""];
 ref = strcat(ref, ascii(10));
 assert_checkequal(prettyprint(s, "mathml"), ref);
+
+// HTML > 4
+ref = [
+"<table style=""display:inline-table; padding: 5px 10px; background: url(file:///"+TMP+"openBrace.png) left top; background-size: 7px 100%; background-repeat:no-repeat;"">"
+"<tr>"
+"<td nowrap style=""white-space:nowrap"">"
+"X<sup>+</sup>(t)"
+"</td>"
+"<td>=</td>"
+"<td nowrap=""nowrap"" style=""white-space:nowrap"">"
+""
+"<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""padding: 5px 10px; background: url(file:///"+TMP+"openParen.png) left top, url(file:///"+TMP+"closeParen.png) right top; background-size: 5px 100%; background-repeat:no-repeat; display:inline-table;"">"
+"<tr align=""center"">"
+"<td>2.02</td>"
+"<td>7.14</td>"
+"<td>-8.59</td>"
+"</tr>"
+"<tr align=""center"">"
+"<td>-9.99</td>"
+"<td>-9.64</td>"
+"<td>-1.27</td>"
+"</tr>"
+"<tr align=""center"">"
+"<td>5.59</td>"
+"<td>7.25</td>"
+"<td>7.44</td>"
+"</tr>"
+"</table>"
+" X(t) + "
+""
+"<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""padding: 5px 10px; background: url(file:///"+TMP+"openParen.png) left top, url(file:///"+TMP+"closeParen.png) right top; background-size: 5px 100%; background-repeat:no-repeat; display:inline-table;"">"
+"<tr align=""center"">"
+"<td>4.46</td>"
+"<td>-0.62</td>"
+"</tr>"
+"<tr align=""center"">"
+"<td>8.42</td>"
+"<td>-3.3</td>"
+"</tr>"
+"<tr align=""center"">"
+"<td>-2.67</td>"
+"<td>9.04</td>"
+"</tr>"
+"</table>"
+" U(t)"
+"</td>"
+"</tr>"
+"<tr>"
+"<td nowrap style=""white-space:nowrap"">"
+"Y(t)</td>"
+"<td>=</td>"
+"<td nowrap=""nowrap"" style=""white-space:nowrap"">"
+""
+"<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""padding: 5px 10px; background: url(file:///"+TMP+"openParen.png) left top, url(file:///"+TMP+"closeParen.png) right top; background-size: 5px 100%; background-repeat:no-repeat; display:inline-table;"">"
+"<tr align=""center"">"
+"<td>-7.72</td>"
+"<td>6.86</td>"
+"<td>-6.75</td>"
+"</tr>"
+"<tr align=""center"">"
+"<td>-4.58</td>"
+"<td>-3.59</td>"
+"<td>-8.06</td>"
+"</tr>"
+"</table>"
+" X(t)"
+" + "
+""
+"<table valign=""middle"" cellspacing=""0"" cellpadding=""3"" style=""padding: 5px 10px; background: url(file:///"+TMP+"openParen.png) left top, url(file:///"+TMP+"closeParen.png) right top; background-size: 5px 100%; background-repeat:no-repeat; display:inline-table;"">"
+"<tr align=""center"">"
+"<td>1 + s</td>"
+"<td>1 - s</td>"
+"</tr>"
+"<tr align=""center"">"
+"<td> - s</td>"
+"<td>s</td>"
+"</tr>"
+"</table>"
+" U(t)"
+"</tr>"
+"</table>"
+""];
+ref = strcat(ref, ascii(10));
+assert_checkequal(prettyprint(s, "html"), ref);