# Transforms vector-presented polynomial into html style.

poly=!trim $poly
n=!itemnum $poly
poly_html=
!for i from 1 to $n
  k=!item $i of $poly
  !if $k != 0
    !ifval $k>=0 
      poly_html=$poly_html+
    !endif
    !ifval $k=0
      poly_html=$poly_html(
    !endif
    p=!eval $i-1
    !if $k = -1 and $p != 0
      poly_html=$poly_html-
    !else
      !if $k != 1 or $p=0
        poly_html=$poly_html$k
      !endif
    !endif
    !ifval $k=0
      poly_html=$poly_html)
    !endif
    !ifval $p>0
      poly_html=$(poly_html)X
      !ifval $p>1
        poly_html=$poly_html<sup>$p</sup>
      !endif
    !endif
  !endif
!next i

t=!char 1 of $poly_html
!if $t=+
 poly_html=!char 2 to -1 of $poly_html
!endif

poly_html=!replace + by $ + $ in $poly_html
poly_html=!replace - by $ - $ in $poly_html


