diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-10-13 11:38:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-13 11:38:19 +0200 |
commit | 4eff6076788d6852974985a0bfcbf73c4d12244e (patch) | |
tree | d9b882c7c0d14195385033cf305f15148d08f318 /src/Text/Pandoc/Shared.hs | |
parent | cbeb72d06b4eb3718479eba5257a33a385f642fe (diff) | |
parent | 63966f6375d22557d0873ba088205ba192d3f9f9 (diff) | |
download | pandoc-4eff6076788d6852974985a0bfcbf73c4d12244e.tar.gz |
Merge pull request #3072 from tarleb/lineblock
Read and write LineBlock elements
Diffstat (limited to 'src/Text/Pandoc/Shared.hs')
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 04752a194..7e9d0f62b 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -64,6 +64,7 @@ module Text.Pandoc.Shared ( compactify, compactify', compactify'DL, + linesToPara, Element (..), hierarchicalize, uniqueIdent, @@ -630,6 +631,15 @@ compactify'DL items = | otherwise -> items _ -> items +-- | Combine a list of lines by adding hard linebreaks. +combineLines :: [[Inline]] -> [Inline] +combineLines = intercalate [LineBreak] + +-- | Convert a list of lines into a paragraph with hard line breaks. This is +-- useful e.g. for rudimentary support of LineBlock elements in writers. +linesToPara :: [[Inline]] -> Block +linesToPara = Para . combineLines + isPara :: Block -> Bool isPara (Para _) = True isPara _ = False @@ -1035,6 +1045,7 @@ collapseFilePath = Posix.joinPath . reverse . foldl go [] . splitDirectories blockToInlines :: Block -> [Inline] blockToInlines (Plain ils) = ils blockToInlines (Para ils) = ils +blockToInlines (LineBlock lns) = combineLines lns blockToInlines (CodeBlock attr str) = [Code attr str] blockToInlines (RawBlock fmt str) = [RawInline fmt str] blockToInlines (BlockQuote blks) = blocksToInlines blks |