<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>bindings/csharp/Makefile</filename>
    </added>
    <added>
      <filename>bindings/csharp/Pandoc.cs</filename>
    </added>
    <added>
      <filename>bindings/csharp/pandoc.fsx</filename>
    </added>
    <added>
      <filename>bindings/plt-scheme/Makefile</filename>
    </added>
    <added>
      <filename>bindings/plt-scheme/pandoc/info.ss</filename>
    </added>
    <added>
      <filename>bindings/plt-scheme/pandoc/pandoc.ss</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -20,7 +20,6 @@ install: $(LIB)
 test:
 	$H -lpandoc test/test.c -o test/test
 	test/test
-	mzscheme test/test.ss test/README
 
 %.so: %.hs lib$(NAME)-so.c
 	$H $F --make -no-hs-main -optl-shared -o $@ $&lt; lib$(NAME)-so.c</diff>
      <filename>Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 Name:		libpandoc
-Version:	0.1
+Version:	0.2
 Cabal-Version:  &gt;= 1.2
 License:	BSD3
 Author:         Anton Tayanovskyy
@@ -8,6 +8,6 @@ Synopsis:       A configuration of Pandoc built into a shared object (dynamicall
 Build-Type:	Simple
 
 Library
-  Build-Depends: pandoc
+  Build-Depends: pandoc, json
 
 </diff>
      <filename>libpandoc.cabal</filename>
    </modified>
    <modified>
      <diff>@@ -3,52 +3,199 @@
 module LibPandoc (pandoc) where
 
 import Text.Pandoc 
+import Text.Pandoc.Shared
+import Text.JSON
 import Foreign.C.Types
 import Foreign.C.String
 
-convert :: String -&gt; String -&gt; String -&gt; String
-convert src tgt text =
-    case reader src of
-      Left e  -&gt; e 
-      Right r -&gt; writer tgt (r text)
-
-dps = defaultParserState
-
-reader &quot;markdown&quot; = Right $ readMarkdown dps
-reader &quot;html&quot;     = Right $ readHtml     dps
-reader &quot;latex&quot;    = Right $ readLaTeX    dps
-reader &quot;rst&quot;      = Right $ readRST      dps
-reader x          = Left  $ unwords [&quot;unknown reader:&quot;, x, &quot;;&quot;,
-                                     &quot;available readers are:&quot;,
-                                     &quot;markdown, html, latex, rst&quot;]
-
-wo = defaultWriterOptions
-
-writer &quot;context&quot;      = writeConTeXt wo
-writer &quot;docbook&quot;      = writeDocbook wo
-writer &quot;html&quot;         = writeHtmlString wo
-writer &quot;latex&quot;        = writeLaTeX wo
-writer &quot;man&quot;          = writeMan wo
-writer &quot;markdown&quot;     = writeMarkdown wo
-writer &quot;mediawiki&quot;    = writeMediaWiki wo
-writer &quot;opendocument&quot; = writeOpenDocument wo
-writer &quot;rst&quot;          = writeRST wo
-writer &quot;rtf&quot;          = writeRTF wo
-writer &quot;s5&quot;           = writeS5String wo
-writer &quot;texinfo&quot;      = writeTexinfo wo
-writer x = \_ -&gt;
-           unwords [&quot;unknown writer:&quot;, x, &quot;;&quot;,
-                    &quot;available writers are:&quot;,
-                    &quot;context, docbook, html,&quot;,
-                    &quot;latex, man, markdown, mediawiki,&quot;,
-                    &quot;opendocument, rst, rtf, s5, texinfo&quot;]           
-
-pandoc :: CString -&gt; CString -&gt; CString -&gt; IO CString
-pandoc src tgt text = do
-  src' &lt;- peekCString src
-  tgt' &lt;- peekCString tgt
-  txt' &lt;- peekCString text  
-  newCString $ convert src' tgt' txt'
-
-foreign export ccall pandoc :: CString -&gt; CString -&gt; CString -&gt; IO CString
+pandoc_fmt_MARKDOWN     = 0
+pandoc_fmt_RST          = 1
+pandoc_fmt_HTML         = 2
+pandoc_fmt_LATEX        = 3
+pandoc_fmt_S5           = 4
+pandoc_fmt_DOCBOOK      = 5
+pandoc_fmt_ODT          = 6
+pandoc_fmt_CONTEXT      = 7
+pandoc_fmt_TEXINFO      = 8
+pandoc_fmt_MAN          = 9
+pandoc_fmt_MEDIAWIKI    = 10
+pandoc_fmt_RTF          = 11
+
+reader x | x == pandoc_fmt_MARKDOWN = Just readMarkdown
+         | x == pandoc_fmt_HTML     = Just readHtml
+         | x == pandoc_fmt_LATEX    = Just readLaTeX
+         | x == pandoc_fmt_RST      = Just readRST
+         | otherwise                = Nothing
+
+writer x | x == pandoc_fmt_MARKDOWN     = Just writeMarkdown
+         | x == pandoc_fmt_RST          = Just writeRST
+         | x == pandoc_fmt_HTML         = Just writeHtmlString
+         | x == pandoc_fmt_LATEX        = Just writeLaTeX
+         | x == pandoc_fmt_S5           = Just writeS5String
+         | x == pandoc_fmt_DOCBOOK      = Just writeDocbook
+         | x == pandoc_fmt_ODT          = Just writeOpenDocument
+         | x == pandoc_fmt_CONTEXT      = Just writeConTeXt
+         | x == pandoc_fmt_TEXINFO      = Just writeTexinfo
+         | x == pandoc_fmt_MAN          = Just writeMan
+         | x == pandoc_fmt_MEDIAWIKI    = Just writeMediaWiki
+         | x == pandoc_fmt_RTF          = Just writeRTF
+         | otherwise                    = Nothing
+
+defWO          = defaultWriterOptions
+defMath        = writerHTMLMathMethod defWO
+defObfuscation = writerEmailObfuscation defWO
+
+instance JSON ParserContext where
+    showJSON _ = undefined
+    readJSON (JSString s)  = 
+        return $
+        case fromJSString s of
+          &quot;ListItemState&quot; -&gt; ListItemState
+          &quot;NullState&quot;     -&gt; NullState
+          _               -&gt; NullState
+
+instance JSON QuoteContext where
+    showJSON = undefined
+    readJSON (JSString s) = 
+        return $
+        case fromJSString s of
+          &quot;InSingleQuote&quot; -&gt; InSingleQuote
+          &quot;InDoubleQuote&quot; -&gt; InDoubleQuote
+          &quot;NoQuote&quot;       -&gt; NoQuote
+          _               -&gt; NoQuote
+
+instance JSON ParserState where
+    showJSON = undefined
+    readJSON (JSObject j) = 
+        do parseRaw        &lt;- val (stateParseRaw def) &quot;ParseRaw&quot;
+           parserContext   &lt;- val (stateParserContext def) &quot;ParserContext&quot;
+           quoteContext    &lt;- val (stateQuoteContext def) &quot;QuoteContext&quot;
+           sanitizeHTML    &lt;- val (stateSanitizeHTML def) &quot;SanitizeHTML&quot;
+           keys            &lt;- return $ stateKeys def
+           notes           &lt;- return $ stateNotes def
+           tabStop         &lt;- val (stateTabStop def) &quot;TabStop&quot;
+           standalone      &lt;- val (stateStandalone def) &quot;Standalone&quot;
+           title           &lt;- return $ stateTitle def
+           authors         &lt;- val (stateAuthors def) &quot;Authors&quot;
+           date            &lt;- val (stateDate def) &quot;Date&quot;
+           strict          &lt;- val (stateStrict def) &quot;Strict&quot;
+           smart           &lt;- val (stateSmart def) &quot;Smart&quot;
+           literateHaskell &lt;- val (stateLiterateHaskell def) &quot;LiterateHaskell&quot;
+           columns         &lt;- val (stateColumns def) &quot;Columns&quot;
+           headerTable     &lt;- return $ stateHeaderTable def
+           return (ParserState parseRaw
+                               parserContext
+                               quoteContext
+                               sanitizeHTML
+                               keys
+                               notes
+                               tabStop
+                               standalone
+                               title
+                               authors
+                               date
+                               strict
+                               smart
+                               literateHaskell
+                               columns
+                               headerTable)
+               where
+                 def     = defaultParserState
+                 val a n = case valFromObj n j of
+                             Ok x    -&gt; Ok x
+                             Error _ -&gt; Ok a
+    readJSON _ = return defaultParserState
+
+instance JSON HTMLMathMethod where
+    readJSON (JSString s) =  
+        return $
+        case fromJSString s of
+          &quot;PlainMath&quot;   -&gt; PlainMath
+          &quot;GladTeX&quot;     -&gt; GladTeX
+          &quot;LaTeXMathML&quot; -&gt; LaTeXMathML Nothing
+          &quot;JsMath&quot;      -&gt; JsMath Nothing
+          _             -&gt; defMath
+    readJSON (JSObject j) = 
+        return $ 
+        case fromJSObject j of
+          [(&quot;MimeTeX&quot;, JSString s)]     -&gt; MimeTeX (fromJSString s)
+          [(&quot;LaTeXMathML&quot;, JSString s)] -&gt; LaTeXMathML (Just (fromJSString s))
+          [(&quot;JsMath&quot;, JSString s)]      -&gt; JsMath (Just (fromJSString s))
+          _                             -&gt; defMath
+        
+    readJSON _ = return defMath
+    showJSON   = undefined
+
+instance JSON ObfuscationMethod where
+    readJSON (JSString s) = 
+        return $
+        case fromJSString s of
+          &quot;NoObfuscation&quot;         -&gt; NoObfuscation
+          &quot;ReferenceObfuscation&quot;  -&gt; ReferenceObfuscation
+          &quot;JavascriptObfuscation&quot; -&gt; JavascriptObfuscation
+          _ -&gt; defObfuscation
+    readJSON _ = return defObfuscation
+    showJSON   = undefined
+
+instance JSON WriterOptions where
+    readJSON (JSObject j) =     
+        do standalone       &lt;- val (writerStandalone def) &quot;Standalone&quot;
+           header           &lt;- val (writerHeader def) &quot;Header&quot;
+           titlePrefix      &lt;- val (writerTitlePrefix def) &quot;TitlePrefix&quot;
+           tabStop          &lt;- val (writerTabStop def) &quot;TabStop&quot;
+           tableOfContents  &lt;- val (writerTableOfContents def) &quot;TableOfContents&quot;
+           s5               &lt;- val (writerS5 def) &quot;S5&quot;
+           htmlMathMethod   &lt;- val (writerHTMLMathMethod def) &quot;HTMLMathMethod&quot;
+           ignoreNotes      &lt;- val (writerIgnoreNotes def) &quot;IgnoreNotes&quot;
+           incremental      &lt;- val (writerIncremental def) &quot;Incremental&quot;
+           numberSections   &lt;- val (writerNumberSections def) &quot;NumberSections&quot;
+           includeBefore    &lt;- val (writerIncludeBefore def) &quot;IncludeBefore&quot;
+           includeAfter     &lt;- val (writerIncludeAfter def) &quot;IncludeAfter&quot;
+           strictMarkdown   &lt;- val (writerStrictMarkdown def) &quot;StrictMarkdown&quot;
+           wrapText         &lt;- val (writerWrapText def) &quot;WrapText&quot;
+           referenceLinks   &lt;- val (writerReferenceLinks def) &quot;ReferenceLinks&quot;
+           literateHaskell  &lt;- val (writerLiterateHaskell def) &quot;LiterateHaskell&quot;
+           emailObfuscation &lt;- 
+               val (writerEmailObfuscation def) &quot;EmailObfuscation&quot;
+           return $ (WriterOptions standalone
+                                   header
+                                   titlePrefix
+                                   tabStop
+                                   tableOfContents
+                                   s5
+                                   htmlMathMethod
+                                   ignoreNotes
+                                   incremental
+                                   numberSections
+                                   includeBefore
+                                   includeAfter
+                                   strictMarkdown
+                                   referenceLinks
+                                   wrapText
+                                   literateHaskell
+                                   emailObfuscation)
+               where
+                 def     = defWO
+                 val a n = case valFromObj n j of
+                             Ok x    -&gt; Ok x
+                             Error _ -&gt; Ok a
+    readJSON _  = return defWO
+    showJSON    = undefined
+
+pandoc :: CInt -&gt; CString -&gt; CInt -&gt; CString -&gt; CString -&gt; IO CString
+pandoc i ps o wo t = do
+  ps &lt;- fmap decode $ peekCString ps
+  wo &lt;- fmap decode $ peekCString wo
+  t  &lt;- peekCString t
+  newCString $ case (reader i, writer o, wo, ps) of
+                 (Just i, Just o, Ok wo, Ok ps) -&gt; o wo $ i ps t
+                 _ -&gt; &quot;pandoc error: invalid options&quot;
+
+foreign export ccall pandoc :: 
+    CInt    -&gt; -- input format code
+    CString -&gt; -- JSON-encoded extra ParserState options
+    CInt    -&gt; -- output format code
+    CString -&gt; -- JSON-encoded extra WriterOptions
+    CString -&gt; -- input text 
+    IO CString -- output tex
 </diff>
      <filename>libpandoc.hs</filename>
    </modified>
    <modified>
      <diff>@@ -1 +1,19 @@
-char* pandoc(char* src, char* tgt, char* text);
+#define PANDOC_FMT_MARKDOWN      0
+#define PANDOC_FMT_RST           1
+#define PANDOC_FMT_HTML          2
+#define PANDOC_FMT_LATEX         3
+#define PANDOC_FMT_S5            4
+#define PANDOC_FMT_DOCBOOK       5
+#define PANDOC_FMT_ODT           6
+#define PANDOC_FMT_CONTEXT       7
+#define PANDOC_FMT_TEXINFO       8
+#define PANDOC_FMT_MAN           9
+#define PANDOC_FMT_MEDIAWIKI     10
+#define PANDOC_FMT_RTF           11
+
+char* pandoc(int input_format, 
+	     char* parser_state_json,
+	     int output_format,
+	     char* writer_options_json,
+	     char* text);
+</diff>
      <filename>pandoc.h</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,11 @@
 #include &lt;pandoc.h&gt;
 
 void test(void) {
-  printf(&quot;%s&quot;, pandoc(&quot;markdown&quot;, &quot;html&quot;, &quot;[hello](http://hello.com)&quot;));
+  printf(&quot;%s&quot;, pandoc(PANDOC_FMT_MARKDOWN,
+		      &quot;null&quot;,
+		      PANDOC_FMT_HTML,
+		      &quot;{\&quot;WrapText\&quot;: false}&quot;,
+		      &quot;[hello](http://hello.com)&quot;));
 }
 
 int main(int argc, char *argv[]) {</diff>
      <filename>test/test.c</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>test/README</filename>
    </removed>
    <removed>
      <filename>test/test.ss</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>9d17cbedaa3aee05a8fb49bdf842bfdc9b5e7d4d</id>
    </parent>
  </parents>
  <author>
    <name>U-tosh\toyvo</name>
    <email>toyvo@tosh.(none)</email>
  </author>
  <url>http://github.com/toyvo/libpandoc/commit/0e1cb8d30d4f2d5f13dbac82e15779a7390e8d36</url>
  <id>0e1cb8d30d4f2d5f13dbac82e15779a7390e8d36</id>
  <committed-date>2009-03-15T06:18:04-07:00</committed-date>
  <authored-date>2009-03-15T06:18:04-07:00</authored-date>
  <message>added support for Pandoc options via JSON, added C# bindings, PLT Scheme bindings</message>
  <tree>790ac61613935b50364ade95452fa31c73b221bb</tree>
  <committer>
    <name>U-tosh\toyvo</name>
    <email>toyvo@tosh.(none)</email>
  </committer>
</commit>
