summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2022-08-14 21:22:24 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2022-08-14 21:22:24 -0700
commit257587f55b832fef00baaa70ad08716ce8723fc7 (patch)
treeb4806db87530d2a58439fed2f4f2dcaf5779bc9b /server
parent3966b016d16d0c89c266c396acd2175a490c1d61 (diff)
Server: add citeproc support.
Diffstat (limited to 'server')
-rw-r--r--server/PandocServer.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/server/PandocServer.hs b/server/PandocServer.hs
index 2c0ecf997..1a7520e27 100644
--- a/server/PandocServer.hs
+++ b/server/PandocServer.hs
@@ -13,6 +13,7 @@ import Data.Aeson.TH
import Network.Wai
import Servant
import Text.Pandoc
+import Text.Pandoc.Citeproc (processCitations)
import qualified Text.Pandoc.UTF8 as UTF8
import Data.Text (Text)
import qualified Data.Text as T
@@ -53,6 +54,7 @@ data Params = Params
, defaultImageExtension :: Maybe Text
, trackChanges :: Maybe TrackChanges
, stripComments :: Maybe Bool
+ , citeproc :: Maybe Bool
} deriving (Show)
instance Default Params where
@@ -71,6 +73,7 @@ instance Default Params where
, defaultImageExtension = Nothing
, trackChanges = Nothing
, stripComments = Nothing
+ , citeproc = Nothing
}
-- Automatically derive code to convert to/from JSON.
@@ -163,7 +166,11 @@ server = convert
let writer = case writerSpec of
TextWriter w -> w writeropts
ByteStringWriter w -> fmap (encodeBase64 . toStrict) . w writeropts
- reader (text params) >>= writer
+ reader (text params) >>=
+ (if citeproc params == Just True
+ then processCitations
+ else return) >>=
+ writer
handleErr (Right t) = return t
handleErr (Left err) = throwError $