summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2022-08-14 21:50:00 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2022-08-14 21:50:00 -0700
commit5d9b36ae539bdb799a60d44601a91c68580c6b76 (patch)
tree84a0bec4a53e4a5297ac416f3658708a8cc027f5 /server
parent257587f55b832fef00baaa70ad08716ce8723fc7 (diff)
Server: support more writer options.
Diffstat (limited to 'server')
-rw-r--r--server/PandocServer.hs40
1 files changed, 39 insertions, 1 deletions
diff --git a/server/PandocServer.hs b/server/PandocServer.hs
index 1a7520e27..d1dae038f 100644
--- a/server/PandocServer.hs
+++ b/server/PandocServer.hs
@@ -12,6 +12,7 @@ import Data.Aeson
import Data.Aeson.TH
import Network.Wai
import Servant
+import Text.DocTemplates as DocTemplates
import Text.Pandoc
import Text.Pandoc.Citeproc (processCitations)
import qualified Text.Pandoc.UTF8 as UTF8
@@ -55,6 +56,15 @@ data Params = Params
, trackChanges :: Maybe TrackChanges
, stripComments :: Maybe Bool
, citeproc :: Maybe Bool
+ , variables :: Maybe (DocTemplates.Context Text)
+ , tableOfContents :: Maybe Bool
+ , incremental :: Maybe Bool
+ , htmlMathMethod :: Maybe HTMLMathMethod
+ , numberSections :: Maybe Bool
+ , numberOffset :: Maybe [Int]
+ , sectionDivs :: Maybe Bool
+ , referenceLinks :: Maybe Bool
+ , dpi :: Maybe Int
} deriving (Show)
instance Default Params where
@@ -74,6 +84,15 @@ instance Default Params where
, trackChanges = Nothing
, stripComments = Nothing
, citeproc = Nothing
+ , variables = Nothing
+ , tableOfContents = Nothing
+ , incremental = Nothing
+ , htmlMathMethod = Nothing
+ , numberSections = Nothing
+ , numberOffset = Nothing
+ , sectionDivs = Nothing
+ , referenceLinks = Nothing
+ , dpi = Nothing
}
-- Automatically derive code to convert to/from JSON.
@@ -155,7 +174,26 @@ server = convert
, writerWrapText = fromMaybe WrapAuto (wrapText params)
, writerColumns = fromMaybe 72 (columns params)
, writerTemplate = mbTemplate
- , writerSyntaxMap = defaultSyntaxMap }
+ , writerSyntaxMap = defaultSyntaxMap
+ , writerVariables =
+ fromMaybe mempty (variables params)
+ , writerTableOfContents =
+ fromMaybe False (tableOfContents params)
+ , writerIncremental =
+ fromMaybe False (incremental params)
+ , writerHTMLMathMethod =
+ fromMaybe PlainMath (htmlMathMethod params)
+ , writerNumberSections =
+ fromMaybe False (numberSections params)
+ , writerNumberOffset =
+ fromMaybe [] (numberOffset params)
+ , writerSectionDivs =
+ fromMaybe False (sectionDivs params)
+ , writerReferenceLinks =
+ fromMaybe False (referenceLinks params)
+ , writerDpi =
+ fromMaybe 96 (dpi params)
+ }
let reader = case readerSpec of
TextReader r -> r readeropts
ByteStringReader r -> \t -> do