Note that there are some explanatory texts on larger screens.

plurals
  1. POFastCGI Haskell script to make use of Pandoc text conversion
    primarykey
    data
    text
    <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">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 "Content-type" "text/plain" 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 "/20%". </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">Documentation found here.</a> Under the heading "Input" 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 "query" </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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload