aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Shared.hs
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-09-27 01:23:44 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-09-27 01:23:44 +0000
commit5b888e8b3be01aebb8ecf7ba4ebee61d2a3d3f31 (patch)
tree6e6d4dce4443d0bc0e8e6bf8ebeb10b28ea3cb81 /src/Text/Pandoc/Shared.hs
parentfa45b970c9b9e748728b58e9471e52139b770570 (diff)
downloadpandoc-5b888e8b3be01aebb8ecf7ba4ebee61d2a3d3f31.tar.gz
Added a writer option for wrapped text and a command-line option
'--no-wrap', which disables text wrapping. (Resolves Issue #26.) + Added support for '--no-wrap' to Main.hs. + Added wrapIfNeeded function to Text.Pandoc.Shared. + Use wrapIfNeeded instead of wrapped in the RST, Man, Docbook, and Markdown writers. + Note: Not yet implemented in HTML, LaTeX, or ConTeXt writers. No documentation yet. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1034 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/Pandoc/Shared.hs')
-rw-r--r--src/Text/Pandoc/Shared.hs40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index 397e681ea..553a93f28 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -44,6 +44,7 @@ module Text.Pandoc.Shared (
camelCaseToHyphenated,
toRomanNumeral,
wrapped,
+ wrapIfNeeded,
-- * Parsing
(>>~),
anyLine,
@@ -210,6 +211,12 @@ wrapped :: Monad m => ([Inline] -> m Doc) -> [Inline] -> m Doc
wrapped listWriter sect = (mapM listWriter $ splitBy Space sect) >>=
return . fsep
+wrapIfNeeded :: Monad m => WriterOptions -> ([Inline] -> m Doc) ->
+ [Inline] -> m Doc
+wrapIfNeeded opts = if writerWrapText opts
+ then wrapped
+ else ($)
+
--
-- Parsing
--
@@ -760,23 +767,26 @@ data WriterOptions = WriterOptions
, writerIncludeAfter :: String -- ^ String to include after the body
, writerStrictMarkdown :: Bool -- ^ Use strict markdown syntax
, writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
+ , writerWrapText :: Bool -- ^ Wrap text to line length
} deriving Show
-- | Default writer options.
defaultWriterOptions :: WriterOptions
defaultWriterOptions =
- WriterOptions { writerStandalone = False,
- writerHeader = "",
- writerTitlePrefix = "",
- writerTabStop = 4,
- writerTableOfContents = False,
- writerS5 = False,
- writerUseASCIIMathML = False,
- writerASCIIMathMLURL = Nothing,
- writerIgnoreNotes = False,
- writerIncremental = False,
- writerNumberSections = False,
- writerIncludeBefore = "",
- writerIncludeAfter = "",
- writerStrictMarkdown = False,
- writerReferenceLinks = False }
+ WriterOptions { writerStandalone = False
+ , writerHeader = ""
+ , writerTitlePrefix = ""
+ , writerTabStop = 4
+ , writerTableOfContents = False
+ , writerS5 = False
+ , writerUseASCIIMathML = False
+ , writerASCIIMathMLURL = Nothing
+ , writerIgnoreNotes = False
+ , writerIncremental = False
+ , writerNumberSections = False
+ , writerIncludeBefore = ""
+ , writerIncludeAfter = ""
+ , writerStrictMarkdown = False
+ , writerReferenceLinks = False
+ , writerWrapText = True
+ }