summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Shared.hs
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-01-15 19:52:42 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-01-15 19:52:42 +0000
commit60989d0637780787fb337b94af212f1ee9e1ae22 (patch)
tree95b5caa1e7e304a47739532a9c4d3767ce54435c /src/Text/Pandoc/Shared.hs
parent4224d913880e4f77a358cda868c9d1ca75820506 (diff)
Added support for tables in markdown reader and in LaTeX,
DocBook, and HTML writers. The syntax is documented in README. Tests have been added to the test suite. git-svn-id: https://pandoc.googlecode.com/svn/trunk@493 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/Pandoc/Shared.hs')
-rw-r--r--src/Text/Pandoc/Shared.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index 624f573de..8ee990827 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -30,6 +30,7 @@ Utility functions and definitions used by the various Pandoc modules.
module Text.Pandoc.Shared (
-- * List processing
splitBy,
+ splitByIndices,
-- * Text processing
gsub,
joinWithSep,
@@ -133,6 +134,8 @@ data ParserState = ParserState
stateDate :: String, -- ^ Date of document
stateStrict :: Bool, -- ^ Use strict markdown syntax
stateSmart :: Bool, -- ^ Use smart typography
+ stateColumns :: Int, -- ^ Number of columns in
+ -- terminal (used for tables)
stateHeaderTable :: [HeaderType] -- ^ List of header types used,
-- in what order (rst only)
}
@@ -154,6 +157,7 @@ defaultParserState =
stateDate = [],
stateStrict = False,
stateSmart = False,
+ stateColumns = 80,
stateHeaderTable = [] }
-- | Indent string as a block.
@@ -292,6 +296,13 @@ splitBy sep lst =
rest' = dropWhile (== sep) rest in
first:(splitBy sep rest')
+-- | Split list into chunks divided at specified indices.
+splitByIndices :: [Int] -> [a] -> [[a]]
+splitByIndices [] lst = [lst]
+splitByIndices (x:xs) lst =
+ let (first, rest) = splitAt x lst in
+ first:(splitByIndices (map (\y -> y - x) xs) rest)
+
-- | Normalize a list of inline elements: remove leading and trailing
-- @Space@ elements, and collapse double @Space@s into singles.
normalizeSpaces :: [Inline] -> [Inline]