From 5ea21760d901a7dc0712075e56abea2e00e0f12a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 4 Jul 2014 18:56:11 -0600 Subject: MediaWiki writer: Minor renaming of 'st' prefixed names. --- src/Text/Pandoc/Writers/MediaWiki.hs | 62 ++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs index baf3ce240..cab55be9b 100644 --- a/src/Text/Pandoc/Writers/MediaWiki.hs +++ b/src/Text/Pandoc/Writers/MediaWiki.hs @@ -48,8 +48,8 @@ data WriterState = WriterState { data WriterReader = WriterReader { options :: WriterOptions -- Writer options - , stListLevel :: String -- String at beginning of list items, e.g. "**" - , stUseTags :: Bool -- True if we should use HTML tags because we're in a complex list + , listLevel :: String -- String at beginning of list items, e.g. "**" + , useTags :: Bool -- True if we should use HTML tags because we're in a complex list } type MediaWikiWriter = ReaderT WriterReader (State WriterState) @@ -58,7 +58,7 @@ type MediaWikiWriter = ReaderT WriterReader (State WriterState) writeMediaWiki :: WriterOptions -> Pandoc -> String writeMediaWiki opts document = let initialState = WriterState { stNotes = False } - env = WriterReader { options = opts, stListLevel = [], stUseTags = False } + env = WriterReader { options = opts, listLevel = [], useTags = False } in evalState (runReaderT (pandocToMediaWiki document) env) initialState -- | Return MediaWiki representation of document. @@ -110,12 +110,12 @@ blockToMediaWiki (Para [Image txt (src,'f':'i':'g':':':tit)]) = do return $ "[[Image:" ++ src ++ "|frame|none" ++ opt ++ "]]\n" blockToMediaWiki (Para inlines) = do - useTags <- asks stUseTags - listLevel <- asks stListLevel + tags <- asks useTags + lev <- asks listLevel contents <- inlineListToMediaWiki inlines - return $ if useTags + return $ if tags then "

" ++ contents ++ "

" - else contents ++ if null listLevel then "\n" else "" + else contents ++ if null lev then "\n" else "" blockToMediaWiki (RawBlock f str) | f == Format "mediawiki" = return str @@ -162,37 +162,37 @@ blockToMediaWiki (Table capt aligns widths headers rows') = do return $ "{|\n" ++ caption ++ tableBody ++ "|}\n" blockToMediaWiki x@(BulletList items) = do - useTags <- fmap (|| not (isSimpleList x)) $ asks stUseTags - if useTags + tags <- fmap (|| not (isSimpleList x)) $ asks useTags + if tags then do - contents <- local (\ s -> s { stUseTags = True }) $ mapM listItemToMediaWiki items + contents <- local (\ s -> s { useTags = True }) $ mapM listItemToMediaWiki items return $ "\n" else do - listLevel <- asks stListLevel - contents <- local (\s -> s { stListLevel = stListLevel s ++ "*" }) $ mapM listItemToMediaWiki items - return $ vcat contents ++ if null listLevel then "\n" else "" + lev <- asks listLevel + contents <- local (\s -> s { listLevel = listLevel s ++ "*" }) $ mapM listItemToMediaWiki items + return $ vcat contents ++ if null lev then "\n" else "" blockToMediaWiki x@(OrderedList attribs items) = do - useTags <- fmap (|| not (isSimpleList x)) $ asks stUseTags - if useTags + tags <- fmap (|| not (isSimpleList x)) $ asks useTags + if tags then do - contents <- local (\s -> s { stUseTags = True }) $ mapM listItemToMediaWiki items + contents <- local (\s -> s { useTags = True }) $ mapM listItemToMediaWiki items return $ "\n" ++ vcat contents ++ "\n" else do - listLevel <- asks stListLevel - contents <- local (\s -> s { stListLevel = stListLevel s ++ "#" }) $ mapM listItemToMediaWiki items - return $ vcat contents ++ if null listLevel then "\n" else "" + lev <- asks listLevel + contents <- local (\s -> s { listLevel = listLevel s ++ "#" }) $ mapM listItemToMediaWiki items + return $ vcat contents ++ if null lev then "\n" else "" blockToMediaWiki x@(DefinitionList items) = do - useTags <- fmap (|| not (isSimpleList x)) $ asks stUseTags - if useTags + tags <- fmap (|| not (isSimpleList x)) $ asks useTags + if tags then do - contents <- local (\s -> s { stUseTags = True }) $ mapM definitionListItemToMediaWiki items + contents <- local (\s -> s { useTags = True }) $ mapM definitionListItemToMediaWiki items return $ "
\n" ++ vcat contents ++ "
\n" else do - listLevel <- asks stListLevel - contents <- local (\s -> s { stListLevel = stListLevel s ++ ";" }) $ mapM definitionListItemToMediaWiki items - return $ vcat contents ++ if null listLevel then "\n" else "" + lev <- asks listLevel + contents <- local (\s -> s { listLevel = listLevel s ++ ";" }) $ mapM definitionListItemToMediaWiki items + return $ vcat contents ++ if null lev then "\n" else "" -- Auxiliary functions for lists: @@ -211,11 +211,11 @@ listAttribsToString (startnum, numstyle, _) = listItemToMediaWiki :: [Block] -> MediaWikiWriter String listItemToMediaWiki items = do contents <- blockListToMediaWiki items - useTags <- asks stUseTags - if useTags + tags <- asks useTags + if tags then return $ "
  • " ++ contents ++ "
  • " else do - marker <- asks stListLevel + marker <- asks listLevel return $ marker ++ " " ++ contents -- | Convert definition list item (label, list of blocks) to MediaWiki. @@ -224,12 +224,12 @@ definitionListItemToMediaWiki :: ([Inline],[[Block]]) definitionListItemToMediaWiki (label, items) = do labelText <- inlineListToMediaWiki label contents <- mapM blockListToMediaWiki items - useTags <- asks stUseTags - if useTags + tags <- asks useTags + if tags then return $ "
    " ++ labelText ++ "
    \n" ++ intercalate "\n" (map (\d -> "
    " ++ d ++ "
    ") contents) else do - marker <- asks stListLevel + marker <- asks listLevel return $ marker ++ " " ++ labelText ++ "\n" ++ intercalate "\n" (map (\d -> init marker ++ ": " ++ d) contents) -- cgit v1.2.3