aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2022-08-21 21:33:52 -0700
committerJohn MacFarlane <[email protected]>2022-08-21 21:33:52 -0700
commiteb96defcc680047cbf02c32b3b09b94e0992c210 (patch)
tree3b7e672fee45e0745cdd3ef38e0d23ca62086cd5
parenta0d174916266c10a3a9d98a96c69ebc9757da937 (diff)
pandoc-server: handle `citeproc` parameter as documented.
Closes #8235.
-rw-r--r--src/Text/Pandoc/Server.hs14
-rw-r--r--trypandoc/trypandoc.js2
2 files changed, 7 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Server.hs b/src/Text/Pandoc/Server.hs
index a7c46f93f..7dfde3aa3 100644
--- a/src/Text/Pandoc/Server.hs
+++ b/src/Text/Pandoc/Server.hs
@@ -38,7 +38,6 @@ import qualified Control.Exception as E
import Text.Pandoc.Shared (safeStrRead, headerShift, filterIpynbOutput,
eastAsianLineBreakFilter, stripEmptyParagraphs)
import Text.Pandoc.App.Opt ( IpynbOutput (..), Opt(..), defaultOpts )
-import Text.Pandoc.Filter (Filter(..))
import Text.Pandoc.Builder (setMeta)
import Text.Pandoc.SelfContained (makeSelfContained)
import System.Exit
@@ -122,6 +121,7 @@ data Params = Params
{ options :: Opt
, text :: Text
, files :: Maybe (M.Map FilePath Blob)
+ , citeproc :: Maybe Bool
} deriving (Show)
instance Default Params where
@@ -129,6 +129,7 @@ instance Default Params where
{ options = defaultOpts
, text = mempty
, files = Nothing
+ , citeproc = Nothing
}
-- Automatically derive code to convert to/from JSON.
@@ -138,6 +139,7 @@ instance FromJSON Params where
<$> parseJSON (Object o)
<*> o .: "text"
<*> o .:? "files"
+ <*> o .:? "citeproc"
-- This is the API. The "/convert" endpoint takes a request body
@@ -327,15 +329,11 @@ server = convert
let addMetadata m' (Pandoc m bs) = Pandoc (m <> m') bs
- let hasCiteprocFilter [] = False
- hasCiteprocFilter (CiteprocFilter:_) = True
- hasCiteprocFilter (_:xs) = hasCiteprocFilter xs
-
reader (text params) >>=
return . transforms . addMetadata meta >>=
- (if hasCiteprocFilter (optFilters opts)
- then processCitations
- else return) >>=
+ (case citeproc params of
+ Just True -> processCitations
+ _ -> return) >>=
writer
htmlFormat :: Maybe Text -> Bool
diff --git a/trypandoc/trypandoc.js b/trypandoc/trypandoc.js
index e129c251e..063a5bca7 100644
--- a/trypandoc/trypandoc.js
+++ b/trypandoc/trypandoc.js
@@ -83,7 +83,7 @@ function convert() {
to: params.to,
text: params.text,
standalone: params.standalone,
- filters: params.citeproc ? ["citeproc"] : [] })
+ citeproc: params.citeproc })
})
.then(handleErrors)
.then(response => response.text())