title: FastCGI Haskell script to make use of Pandoc text conversion
body: <h1>1. Motivation</h1>
  <p>I'm writing my own mini-wiki. I want to be able to easily convert from markdown to LATEX/HTML and vice versa. After some searching I discovered <a href="http://johnmacfarlane.net/pandoc/" rel="nofollow noreferrer">Pandoc</a>, which is  written in Haskell and that I could use the FastCGI module to run a Haskell program on my Apache server.</p>
  <h1>2. Problem/ Question</h1>
  <p>I'm not sure how to what protocol I should use to send my FastCGI script the input/output variables (POST/GET?) and how this is done exactly. Any ideas, suggestions, solutions?</p>
  <h1>3. Steps taken</h1>
  <h2>3.1 Attempt</h2>
  <p>Here is what I've done so far (based on example code). <em>Note, I have no experience in Haskell and at the moment I don't have too much time to learn the language. I'd just love to be able to use the pandoc text format conversion tool.</em></p>
  <pre><code>module Main ( main ) where
  
  import Control.Concurrent
  import Network.FastCGI
  import Text.Pandoc
  
  --initialize Variables/ functions
  fastcgiResult :: CGI CGIResult
  markdownToHTML:: String -&gt; String
  
  --implement conversion function
  markdownToHTML s = writeLaTeX defaultWriterOptions {writerReferenceLinks = True} (readMarkdown defaultParserState s)    
  
  --main action
  fastcgiResult = do
      setHeader &quot;Content-type&quot; &quot;text/plain&quot;
      n &lt;- queryString
      output $ (markdownToHTML n)
  
  main :: IO ()
  main = runFastCGIConcurrent' forkIO 10 fastcgiResult
  </code></pre>
  <p>This code reads the string after the question mark in the request url. But this is not a good solution as certain characters are omitted (e.g. '#' ) and spaces are replaced by &quot;/20%&quot;.</p>
  <p>Thanks in advance.</p>
  <h2>3.2 Network.CGI</h2>
  <p><a href="http://hackage.haskell.org/packages/archive/cgi/3001.1.5.2/doc/html/Network-CGI.html" rel="nofollow noreferrer">Documentation found here.</a> Under the heading &quot;Input&quot; there are a number of methods to get input. <strong>Which one is right for me?</strong></p>
  <p>Is it :</p>
  <blockquote>
  <p>Get the value of an input variable, for example from a form. If the variable has multiple values, the first one is returned. Example:</p>
  </blockquote>
  <pre><code>query &lt;- getInput &quot;query&quot;
  </code></pre>
  <p>So lets say I have a HTML POST form with <code>name='Joe'</code> can I grab this using getInput? And if so how do I handle the <code>Maybe String</code> type?</p>