
!if $wims_read_parm!=slib_header
 !goto proc
!endif
slib_title=Graphviz
slib_parms=2\
,description du graphe dans le language de graphviz\
,options separated by white spaces : can be dot jpg png plain url charset= 
slib_author=Bernadette PERRIN-RIOU
slib_out=in the case where the format is dot, output the url address of the image,\
in the case there is no format, output the code to show the image : &lt;img src=...> ;\
in the case where the format is jpg, give the coordinates
slib_comment=
slib_example=digraph bar {1 -> 1 ; 2 -> 1 ; 1 -> 2 ; 3 -> 2  ; 2 -> 3  ;},png dot url\
digraph bar {1 -> 1 ; 2 -> 1 ; 1 -> 2 ; 3 -> 2  ; 2 -> 3  ;},url neato\
digraph bar {1 -> 1 ; 2 -> 1 ; 1 -> 2 ; 3 -> 2  ; 2 -> 3  ;},png\
digraph bar {1 -> 1 ; 2 -> 1 ; 1 -> 2 ; 3 -> 2  ; 2 -> 3  ;},plain\
digraph bar {1 -> 1 ; 2 -> 1 ; 1 -> 2 ; 3 -> 2  ; 2 -> 3  ;},png
slib_require=graphviz
!exit

:proc

slib_out=
### faire le test
!distribute items $wims_read_parm into slib_data,slib_option
graphviz_charset=!getopt charset in $slib_option
!if $slib_option issametext 
  slib_option=url
 !endif
!if plain iswordof $slib_option 
    graphviz_output=plain
!endif
!if dot iswordof $slib_option 
    graphviz_format=dot
!endif
!if neato iswordof $slib_option 
    graphviz_format=neato
!endif
!if jpg iswordof $slib_option 
    graphviz_output=jpg
!endif
!if gif iswordof $slib_option 
    graphviz_output=gif
!endif
!if png iswordof $slib_option 
    graphviz_output=png
!endif
!if plain iswordof $slib_option 
    graphviz_output=plain
!endif

!default graphviz_output=jpg
!default graphviz_format=dot
!if $graphviz_output=plain
  graphviz_output=jpg
   graphviz_out=!exec graphviz $slib_data
   slib_out=!line 1 to -1 of $ graphviz_out
  !exit
!endif
!if $graphviz_output iswordof jpg png gif
  graphviz_out=!exec graphviz $slib_data
  slib_d=!line 1 of $graphviz_out
  !if url iswordof $slib_option 
    slib_out=<img src="$slib_d">
  !else
    slib_out=!line 1 of $slib_d
  !endif
!endif

