Skip to content

Instantly share code, notes, and snippets.

@mrvdb
Created December 22, 2015 16:14
Show Gist options
  • Select an option

  • Save mrvdb/967d3f2e57d876bd6f93 to your computer and use it in GitHub Desktop.

Select an option

Save mrvdb/967d3f2e57d876bd6f93 to your computer and use it in GitHub Desktop.
diff --git a/app/servius.hs b/app/servius.hs
index 14ed7ec..76350e4 100644
--- a/app/servius.hs
+++ b/app/servius.hs
@@ -22,8 +22,10 @@ import Text.Lucius (luciusRT)
import Text.Markdown (def, msXssProtect, msAddHeadingId, markdown)
import WaiAppStatic.CmdLine (docroot, runCommandLine)
-import Text.Pandoc (def, readOrg, writeHtml)
+#if orgmode-support
+import Text.Pandoc (readOrg, writeHtml)
import Text.Pandoc.Error (handleError)
+#endif
main :: IO ()
main = runCommandLine (shake . docroot)
@@ -36,7 +38,9 @@ shake docroot app req respond
| ".lucius" `T.isSuffixOf` l = lucius pr >>= respond
| ".markdown" `T.isSuffixOf` l = markdown' pr >>= respond
| ".md" `T.isSuffixOf` l = markdown' pr >>= respond
+#if orgmode-support
| ".org" `T.isSuffixOf` l = orgmode pr >>= respond
+#endif
| otherwise = app req respond
where
p = pathInfo req
@@ -80,9 +84,10 @@ markdown' fp = do
, msAddHeadingId = True
}
+#if orgmode-support
orgmode :: Text -> IO Response
orgmode fp = do
str <- readFileUtf8 fp
let html = writeHtml def (handleError $ readOrg def str)
return $ responseBuilder status200 [("Content-Type", "text/html; charset=utf-8")] $ renderHtmlBuilder html
-
+#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment