!! input: raw_poly
!! output: html_poly

!set poly_dim=!itemcnt $raw_poly

!set html_poly=
!set start=0
!for j=1 to $poly_dim
 !set c=!item $j of $raw_poly
 !ifval $c!=0
  !if $c>0 and $start>0
   !set html_poly=$html_poly+
  !endif
  !ifval abs($c)=1
   !set c=!char 1 to -2 of $c
  !endif
  !if $j=$poly_dim
   !set v=
  !else
   !set v=X
   !if $j<$poly_dim-1
    !set v=$v<sup>$[$poly_dim-$j]</sup>
   !endif
  !endif
  !set html_poly=$html_poly$c$v
  !set start=1
 !endif
!next j
!if $start=0
 !set html_poly=0
!endif

