HTMLFormat

I have written a spad package HTMLFormat so that users can cut and paste output from the FriCAS command line into an HTML page. This output is enabled by typing:

)set output html on

(of course you need to download HTMLFormat (availible from: http://github.com/martinbaker/multivector/), configure FriCAS and compile everything first)

All the formulas on this page have been cut and pasted from FriCAS using HTMLFormat so you can see what it looks like. (more test results here)

It is based on similar outputs like TeXFormat and MathMLFormat. In some ways HTMLFormat is a compromise between the standard text output and specialised formats like MathMLFormat. The potential quality is never going to be as good as output to a specialised maths renderer but on the other hand it is a lot better than the clunky fixed width font text output.

It does have advantages that the other output formats don't, for instance,

HTMLFormat does not try to interpret syntax, for instance in this example it just takes what OutputForm provides and does not try to replace %A with the bound variable x.

(1) -> integral(x^x,x)
x %A %A * d%A
                                          Type: Expression(Integer)

In order to see how we can make annotations lets generate a more complex expression:

(2) -> series(sin(a*x),x=0)
a*x
-
a 3
6
* x 3
+
a 5
120
* x 5
-
a 7
5040
* x 7
+
a 9
362880
* x 9
-
a 11
39916800
* x 11
+ O ( x 12 )

By using a html or text editor we can remove terms, add text and so on and the formatting automatically adjusts:

a*x
-
a 3
6
* x 3
+
a 5
120<- highlight
* x 5
-
a 7
5040
* x 7
+
a 9
362880
* x 9
term
removed
+ O ( x 12 )

At the moment the default output for a matrix is a grid, my requirement is to fit big matrices on ordinary web pages:

(3) -> matrix [ [x^i + y^j for i in 1..4] for j in 1..4]
y+x y + x 2 y + x 3 y + x 4
y 2 + x y 2 + x 2 y 2 + x 3 y 2 + x 4
y 3 + x y 3 + x 2 y 3 + x 3 y 3 + x 4
y 4 + x y 4 + x 2 y 4 + x 3 y 4 + x 4
                                    Type: Matrix(Polynomial(Integer))

However it easy to modify this for a single matrix, or a whole page or whole site by using css (cascading style sheets). For instance we can get a more conventional looking matrix by adding the following style to the top of the page:

<style type="text/css">
#matl {border-left-style:solid}
#matr {border-right-style:solid}
#matlt {border-left-style:solid;border-top-style:solid}
#matrt {border-right-style:solid;border-top-style:solid}
#matlb {border-left-style:solid;border-bottom-style:solid}
#matrb {border-right-style:solid;border-bottom-style:solid}
</style>

(3) -> matrix [ [x^i + y^j for i in 1..4] for j in 1..4]
y+x y + x 2 y + x 3 y + x 4
y 2 + x y 2 + x 2 y 2 + x 3 y 2 + x 4
y 3 + x y 3 + x 2 y 3 + x 3 y 3 + x 4
y 4 + x y 4 + x 2 y 4 + x 3 y 4 + x 4
                                     Type: Matrix(Polynomial(Integer))

The problem now is that the columns are so close together that it is hard to tell where one column ends and another starts, this is easy to fix with just one line we can increase the cell spacing:

(3) -> matrix [ [x^i + y^j for i in 1..4] for j in 1..4]
y+x y + x 2 y + x 3 y + x 4
y 2 + x y 2 + x 2 y 2 + x 3 y 2 + x 4
y 3 + x y 3 + x 2 y 3 + x 3 y 3 + x 4
y 4 + x y 4 + x 2 y 4 + x 3 y 4 + x 4
                                     Type: Matrix(Polynomial(Integer))

There are still problems with this, it increases the size of the matrix and therefore reduces the ability to have very big matrices on a page, it also accentuates the gaps in the left and right bars. The best solution that I have found so far is to have fainter bars between the elements but there are many possibilities including dotted lines.

(3) -> matrix [ [x^i + y^j for i in 1..4] for j in 1..4]
y+x y + x 2 y + x 3 y + x 4
y 2 + x y 2 + x 2 y 2 + x 3 y 2 + x 4
y 3 + x y 3 + x 2 y 3 + x 3 y 3 + x 4
y 4 + x y 4 + x 2 y 4 + x 3 y 4 + x 4
                                     Type: Matrix(Polynomial(Integer))

There are many other possibilities, for instance we can generate a matrix with bars either side to indicate a determinant.

Further test results on this page.


metadata block
see also:
Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

flag flag flag flag flag flag Axiom Volume 1: Tutorial. Documentation is freely availible from: http://www.axiom-developer.org/axiom-website/documentation.html

 

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2017 Martin John Baker - All rights reserved - privacy policy.