Replaced individual wrapping routines in RST, Man, and

Markdown writers with 'wrapped' from Text.Pandoc.Shared.


git-svn-id: https://pandoc.googlecode.com/svn/trunk@967 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
fiddlosopher 2007-08-30 22:59:13 +00:00
parent 7ff2706838
commit dcb1dd1ee4
3 changed files with 6 additions and 23 deletions

View file

@ -98,12 +98,6 @@ noteToMan opts num note = do
let marker = text "\n.SS [" <> text (show num) <> char ']'
return $ marker $$ contents
wrappedMan :: WriterOptions -> [Inline] -> State WriterState Doc
wrappedMan opts sect = do
let chunks = splitBy Space sect
chunks' <- mapM (inlineListToMan opts) chunks
return $ fsep chunks'
-- | Association list of characters to escape.
manEscapes :: [(Char, String)]
manEscapes = [('\160', "\\ "), ('\'', "\\[aq]")] ++ backslashEscapes "\".@\\"
@ -121,9 +115,9 @@ blockToMan :: WriterOptions -- ^ Options
-> Block -- ^ Block element
-> State WriterState Doc
blockToMan opts Null = return empty
blockToMan opts (Plain inlines) = wrappedMan opts inlines
blockToMan opts (Plain inlines) = wrapped (inlineListToMan opts) inlines
blockToMan opts (Para inlines) = do
contents <- wrappedMan opts inlines
contents <- wrapped (inlineListToMan opts) inlines
return $ text ".PP" $$ contents
blockToMan opts (RawHtml str) = return $ text str
blockToMan opts HorizontalRule = return $ text $ ".PP\n * * * * *"

View file

@ -96,12 +96,6 @@ noteToMarkdown opts num blocks = do
let marker = text "[^" <> text (show num) <> text "]:"
return $ hang marker (writerTabStop opts) contents
wrappedMarkdown :: WriterOptions -> [Inline] -> State WriterState Doc
wrappedMarkdown opts sect = do
let chunks = splitBy Space sect
chunks' <- mapM (inlineListToMarkdown opts) chunks
return $ fsep chunks'
-- | Escape special characters for Markdown.
escapeString :: String -> String
escapeString = escapeStringUsing markdownEscapes
@ -150,9 +144,10 @@ blockToMarkdown :: WriterOptions -- ^ Options
-> Block -- ^ Block element
-> State WriterState Doc
blockToMarkdown opts Null = return empty
blockToMarkdown opts (Plain inlines) = wrappedMarkdown opts inlines
blockToMarkdown opts (Plain inlines) =
wrapped (inlineListToMarkdown opts) inlines
blockToMarkdown opts (Para inlines) = do
contents <- wrappedMarkdown opts inlines
contents <- wrapped (inlineListToMarkdown opts) inlines
return $ contents <> text "\n"
blockToMarkdown opts (RawHtml str) = return $ text str
blockToMarkdown opts HorizontalRule = return $ text "\n* * * * *\n"

View file

@ -107,15 +107,9 @@ pictToRST opts (label, (src, _)) = do
-- | Take list of inline elements and return wrapped doc.
wrappedRST :: WriterOptions -> [Inline] -> State WriterState Doc
wrappedRST opts inlines =
mapM (wrappedRSTSection opts) (splitBy LineBreak inlines) >>=
mapM (wrapped (inlineListToRST opts)) (splitBy LineBreak inlines) >>=
return . vcat
wrappedRSTSection :: WriterOptions -> [Inline] -> State WriterState Doc
wrappedRSTSection opts sect = do
let chunks = splitBy Space sect
chunks' <- mapM (inlineListToRST opts) chunks
return $ fsep chunks'
-- | Escape special characters for RST.
escapeString :: String -> String
escapeString = escapeStringUsing (backslashEscapes "`\\|*_")