parent
a0d1749162
commit
eb96defcc6
2 changed files with 7 additions and 9 deletions
|
@ -38,7 +38,6 @@ import qualified Control.Exception as E
|
||||||
import Text.Pandoc.Shared (safeStrRead, headerShift, filterIpynbOutput,
|
import Text.Pandoc.Shared (safeStrRead, headerShift, filterIpynbOutput,
|
||||||
eastAsianLineBreakFilter, stripEmptyParagraphs)
|
eastAsianLineBreakFilter, stripEmptyParagraphs)
|
||||||
import Text.Pandoc.App.Opt ( IpynbOutput (..), Opt(..), defaultOpts )
|
import Text.Pandoc.App.Opt ( IpynbOutput (..), Opt(..), defaultOpts )
|
||||||
import Text.Pandoc.Filter (Filter(..))
|
|
||||||
import Text.Pandoc.Builder (setMeta)
|
import Text.Pandoc.Builder (setMeta)
|
||||||
import Text.Pandoc.SelfContained (makeSelfContained)
|
import Text.Pandoc.SelfContained (makeSelfContained)
|
||||||
import System.Exit
|
import System.Exit
|
||||||
|
@ -122,6 +121,7 @@ data Params = Params
|
||||||
{ options :: Opt
|
{ options :: Opt
|
||||||
, text :: Text
|
, text :: Text
|
||||||
, files :: Maybe (M.Map FilePath Blob)
|
, files :: Maybe (M.Map FilePath Blob)
|
||||||
|
, citeproc :: Maybe Bool
|
||||||
} deriving (Show)
|
} deriving (Show)
|
||||||
|
|
||||||
instance Default Params where
|
instance Default Params where
|
||||||
|
@ -129,6 +129,7 @@ instance Default Params where
|
||||||
{ options = defaultOpts
|
{ options = defaultOpts
|
||||||
, text = mempty
|
, text = mempty
|
||||||
, files = Nothing
|
, files = Nothing
|
||||||
|
, citeproc = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Automatically derive code to convert to/from JSON.
|
-- Automatically derive code to convert to/from JSON.
|
||||||
|
@ -138,6 +139,7 @@ instance FromJSON Params where
|
||||||
<$> parseJSON (Object o)
|
<$> parseJSON (Object o)
|
||||||
<*> o .: "text"
|
<*> o .: "text"
|
||||||
<*> o .:? "files"
|
<*> o .:? "files"
|
||||||
|
<*> o .:? "citeproc"
|
||||||
|
|
||||||
|
|
||||||
-- This is the API. The "/convert" endpoint takes a request body
|
-- 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 addMetadata m' (Pandoc m bs) = Pandoc (m <> m') bs
|
||||||
|
|
||||||
let hasCiteprocFilter [] = False
|
|
||||||
hasCiteprocFilter (CiteprocFilter:_) = True
|
|
||||||
hasCiteprocFilter (_:xs) = hasCiteprocFilter xs
|
|
||||||
|
|
||||||
reader (text params) >>=
|
reader (text params) >>=
|
||||||
return . transforms . addMetadata meta >>=
|
return . transforms . addMetadata meta >>=
|
||||||
(if hasCiteprocFilter (optFilters opts)
|
(case citeproc params of
|
||||||
then processCitations
|
Just True -> processCitations
|
||||||
else return) >>=
|
_ -> return) >>=
|
||||||
writer
|
writer
|
||||||
|
|
||||||
htmlFormat :: Maybe Text -> Bool
|
htmlFormat :: Maybe Text -> Bool
|
||||||
|
|
|
@ -83,7 +83,7 @@ function convert() {
|
||||||
to: params.to,
|
to: params.to,
|
||||||
text: params.text,
|
text: params.text,
|
||||||
standalone: params.standalone,
|
standalone: params.standalone,
|
||||||
filters: params.citeproc ? ["citeproc"] : [] })
|
citeproc: params.citeproc })
|
||||||
})
|
})
|
||||||
.then(handleErrors)
|
.then(handleErrors)
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
|
|
Loading…
Add table
Reference in a new issue