Skip to content

Commit

Permalink
Added dzslides and asciidoc as export options.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgm committed Feb 26, 2012
1 parent 56b0ee4 commit f7e9e62
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions Network/Gitit/Export.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import System.Process (runProcess, waitForProcess)
import Codec.Binary.UTF8.String (encodeString)
import Text.HTML.SanitizeXSS
import qualified Data.Text as T
import Data.List (isPrefixOf)

defaultRespOptions :: WriterOptions
defaultRespOptions = defaultWriterOptions { writerStandalone = True }
Expand Down Expand Up @@ -99,6 +100,7 @@ respondSlides templ slideVariant _page doc = do
let opts' = defaultRespOptions {
writerSlideVariant = slideVariant
,writerIncremental = True
,writerHtml5 = templ == "dzslides"
,writerHTMLMathMethod = math}
-- We sanitize the body only, to protect against XSS attacks.
-- (Sanitizing the whole HTML page would strip out javascript
Expand All @@ -118,9 +120,18 @@ respondSlides templ slideVariant _page doc = do
template <- case template' of
Right t -> return t
Left e -> liftIO $ throwIO e
dzcore <- if templ == "dzslides"
then do
dztempl <- liftIO $ readDataFile (pandocUserData cfg)
$ "dzslides" </> "template.html"
return $ unlines
$ dropWhile (not . isPrefixOf "<!-- {{{{ dzslides core")
$ lines dztempl
else return ""
let Pandoc meta _ = doc
let h = writeHtmlString opts'{
writerVariables = ("body",body''):variables'
writerVariables =
("body",body''):("dzslides-core",dzcore):variables'
,writerTemplate = template
,writerSourceDirectory = repositoryPath cfg
,writerUserDataDir = pandocUserData cfg
Expand Down Expand Up @@ -159,12 +170,6 @@ respondMan :: String -> Pandoc -> Handler
respondMan = respondS "man" "text/plain; charset=utf-8" ""
writeMan defaultRespOptions

respondS5 :: String -> Pandoc -> Handler
respondS5 = respondSlides "s5" S5Slides

respondSlidy :: String -> Pandoc -> Handler
respondSlidy = respondSlides "slidy" SlidySlides

respondTexinfo :: String -> Pandoc -> Handler
respondTexinfo = respondS "texinfo" "application/x-texinfo" "texi"
writeTexinfo defaultRespOptions
Expand All @@ -181,6 +186,10 @@ respondTextile :: String -> Pandoc -> Handler
respondTextile = respondS "textile" "text/plain; charset=utf-8" ""
writeTextile defaultRespOptions

respondAsciiDoc :: String -> Pandoc -> Handler
respondAsciiDoc = respondS "asciidoc" "text/plain; charset=utf-8" ""
writeAsciiDoc defaultRespOptions

respondMediaWiki :: String -> Pandoc -> Handler
respondMediaWiki = respondS "mediawiki" "text/plain; charset=utf-8" ""
writeMediaWiki defaultRespOptions
Expand Down Expand Up @@ -285,10 +294,12 @@ exportFormats cfg = if pdfExport cfg
, ("MediaWiki", respondMediaWiki)
, ("man", respondMan)
, ("DocBook", respondDocbook)
, ("Slidy", respondSlidy)
, ("S5", respondS5)
, ("Slidy", respondSlides "slidy" SlidySlides)
, ("S5", respondSlides "s5" S5Slides)
, ("DZSlides", respondSlides "dzslides" DZSlides)
, ("ODT", respondODT)
, ("EPUB", respondEPUB)
, ("Org", respondOrg)
, ("Textile", respondTextile)
, ("AsciiDoc", respondAsciiDoc)
, ("RTF", respondRTF) ]

0 comments on commit f7e9e62

Please sign in to comment.