software:dokuwiki:format-plugin

Format plugin

See http://www.dokuwiki.org/plugin:format

The format plugin allows you to run external programs and put resulting images or other files into a wiki page. I'm using it to allow a person to draw diagrams or graphs by giving the commands in the page and having DokuWiki convert those commands to a picture through an external program.

The examples below no longer work because of security restrictions on my current server.

GNU PIC (using dpic)

Dwight Aplevich wrote dpic (http://www.ece.uwaterloo.ca/~aplevich/dpic/), a wonderful implementation of the GNU PIC language. This program allows a person to draw diagrams with a very easy programming language. I've personally used this extensively in drawing graphs for my research.
Putting this in a wiki page

<format dpic>
  box "start" 
  arrow right 2 "process" above
  circle "end"
</format>

yields the diagram

<format dpic>
box “start” arrow right 2 “process” above
circle “end” </format>

More examples and a manual of the syntax come with dpic and also can be found in the “pic” section of http://www.kohala.com/start/troff/troff.html or pic_language.

Graphing (using GLE)

GLE (http://glx.sourceforge.net/) is a program for drawing graphs and diagrams. I use it to insert nice graphs into a wiki.

Putting this in a wiki page

<format graph>
  ! An exclamation point is the comment character
  size 7 4 ! Make the picture 7cm by 4cm
  begin graph
    size 7 4 ! Make the graph fit the picture
    xaxis min 0 max 2*pi dticks pi/2 format "pi" ! Set up the x-axis
    yaxis nticks 5 ! Set up the y-axis
    
    ! Define three data sets
    let d1 = 1/x from 0.2 to 10 
    let d2 = sin(x)*2+2 from 0 to 10 
    let d3 = 10*(1/sqrt(2*pi))*exp(-2*(sqr(x-4)/sqr(2))) from 0.2 to 10 step .1 


    d1 line ! Plot dataset d1
    d2 line lstyle 2 color red  ! Plot dataset d2 in red
    d3 line impulses color light_grey ! Plot dataset d3
  end graph 
</format>

yields

<format graph>

! An exclamation point is the comment character
size 7 4 ! Make the picture 7cm by 4cm
begin graph
  size 7 4 ! Make the graph fit the picture
  xaxis min 0 max 2*pi dticks pi/2 format "pi" ! Set up the x-axis
  yaxis nticks 5 ! Set up the y-axis
  
  ! Define three data sets
  let d1 = 1/x from 0.2 to 10 
  let d2 = sin(x)*2+2 from 0 to 10 
  let d3 = 10*(1/sqrt(2*pi))*exp(-2*(sqr(x-4)/sqr(2))) from 0.2 to 10 step .1 
  d1 line ! Plot dataset d1
  d2 line lstyle 2 color red  ! Plot dataset d2 in red
  d3 line impulses color light_grey ! Plot dataset d3
end graph 

</format>

More examples can be found at:

Graphing (with gnuplot)

I decided not to use gnuplot because it is not safe. There is no way to make sure that the wiki user can't execute arbitrary commands on the wiki server. However, if you want to use gnuplot, you can.


Page Tools