Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Network/Gitit/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ extractConfig cfgmap = do
cfFrontPage <- get "DEFAULT" "front-page"
cfNoEdit <- get "DEFAULT" "no-edit"
cfNoDelete <- get "DEFAULT" "no-delete"
cfPandocExtensions <- get "DEFAULT" "pandoc-extensions"
cfDefaultSummary <- get "DEFAULT" "default-summary"
cfDeleteSummary <- get "DEFAULT" "delete-summary"
cfDisableRegistration <- get "DEFAULT" "disable-registration" >>= readBool
Expand Down Expand Up @@ -250,6 +251,7 @@ extractConfig cfgmap = do
, noDelete = splitCommaList cfNoDelete
, defaultSummary = cfDefaultSummary
, deleteSummary = cfDeleteSummary
, pandocExts = splitCommaList cfPandocExtensions
, disableRegistration = cfDisableRegistration
, accessQuestion = if null cfAccessQuestion
then Nothing
Expand Down
12 changes: 8 additions & 4 deletions src/Network/Gitit/ContentTransformer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,13 @@ pageToWikiPandoc' = applyPreParseTransforms >=>
-- | Converts source text to Pandoc using default page type.
pageToPandoc :: Page -> ContentTransformer Pandoc
pageToPandoc page' = do
cfg <- lift getConfig
let userExts = extensionsFromList . map readExtension $ pandocExts cfg
modifyContext $ \ctx -> ctx{ ctxTOC = pageTOC page'
, ctxCategories = pageCategories page'
, ctxMeta = pageMeta page' }
either (liftIO . E.throwIO) return $ readerFor (pageFormat page') (pageLHS page') (pageText page')
either (liftIO . E.throwIO)
return $ readerFor (pageFormat page') (pageLHS page') (pageText page') userExts

data WasRedirect = WasRedirect | WasNoRedirect

Expand Down Expand Up @@ -664,10 +667,11 @@ updateLayout f = do
-- Pandoc and wiki content conversion support
--

readerFor :: PageType -> Bool -> String -> Either PandocError Pandoc
readerFor pt lhs =
readerFor :: PageType -> Bool -> String -> Extensions -> Either PandocError Pandoc
readerFor pt lhs txt userExts =
let defExts = getDefaultExtensions $ T.toLower $ T.pack $ show pt
defPS = def{ readerExtensions = defExts
<> userExts
<> extensionsFromList [Ext_emoji]
<> getPageTypeDefaultExtensions pt lhs
<> readerExtensions def }
Expand All @@ -680,7 +684,7 @@ readerFor pt lhs =
Textile -> readTextile defPS
Org -> readOrg defPS
DocBook -> readDocBook defPS
MediaWiki -> readMediaWiki defPS) . T.pack
MediaWiki -> readMediaWiki defPS) . T.pack $ txt

wikiLinksTransform :: Pandoc -> PluginM Pandoc
wikiLinksTransform pandoc
Expand Down
2 changes: 2 additions & 0 deletions src/Network/Gitit/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ data Config = Config {
noEdit :: [String],
-- | Pages that cannot be deleted via web
noDelete :: [String],
-- | Pandoc extensions to enable (don't include the "Ext_" prefix)
pandocExts :: [String],
-- | Default summary if description left blank
defaultSummary :: String,
-- | Delete summary
Expand Down