@@ -46,12 +46,6 @@ module Text.Pandoc.Shared (
46 escapeURI,
46 escapeURI,
47 unescapeURI,
47 unescapeURI,
48 tabFilter,
48 tabFilter,
55 -- * Pandoc block and inline list processing
49 -- * Pandoc block and inline list processing
56 orderedListMarkers,
50 orderedListMarkers,
57 normalizeSpaces,
51 normalizeSpaces,
@@ -78,8 +72,6 @@ module Text.Pandoc.Shared (
79import Text.Pandoc.Definition
73import Text.Pandoc.Definition
80import qualified Text.Pandoc.UTF8 as UTF8 (readFile)
74import qualified Text.Pandoc.UTF8 as UTF8 (readFile)
81−import Text.PrettyPrint.HughesPJ ( Doc, fsep, ($$), (<>), empty, nest )
82−import qualified Text.PrettyPrint.HughesPJ as PP
83import Data.Char ( toLower, isLower, isUpper, isAlpha, isAscii,
75import Data.Char ( toLower, isLower, isUpper, isAlpha, isAscii,
84 isLetter, isDigit )
76 isLetter, isDigit )
85import Data.List ( find, isPrefixOf, intercalate )
77import Data.List ( find, isPrefixOf, intercalate )
@@ -219,73 +211,6 @@ tabFilter tabStop =
219 x : go (spsToNextStop - 1) xs
211 x : go (spsToNextStop - 1) xs
220 in go tabStop
212 in go tabStop
226−-- | Wrap inlines to line length.
227−wrapped :: Monad m => ([Inline] -> m Doc) -> [Inline] -> m Doc
228−wrapped listWriter sect = (mapM listWriter $ splitBy (== Space) sect) >>=
231−-- | Wrap inlines if the text wrap option is selected.
232−wrapIfNeeded :: Monad m => WriterOptions -> ([Inline] -> m Doc) ->
234−wrapIfNeeded opts = if writerWrapText opts
238−-- auxiliary function for wrappedTeX
239−isNote :: Inline -> Bool
240−isNote (Note _) = True
243−-- | Wrap inlines to line length, treating footnotes in a way that
244−-- makes sense in LaTeX and ConTeXt.
245−wrappedTeX :: Monad m
247− -> ([Inline] -> m Doc)
250−wrappedTeX includePercent listWriter sect = do
251− let (firstpart, rest) = break isNote sect
252− firstpartWrapped <- wrapped listWriter firstpart
254− then return firstpartWrapped
255− else do let (note:rest') = rest
256− let (rest1, rest2) = break (== Space) rest'
257− -- rest1 is whatever comes between the note and a Space.
258− -- if the note is followed directly by a Space, rest1 is null.
259− -- rest1 is printed after the note but before the line break,
260− -- to avoid spurious blank space the note and immediately
261− -- following punctuation.
262− rest1Out <- if null rest1
264− else listWriter rest1
265− rest2Wrapped <- if null rest2
267− else wrappedTeX includePercent listWriter (tail rest2)
268− noteText <- listWriter [note]
269− return $ (firstpartWrapped <> if includePercent then PP.char '%' else empty) $$
270− (noteText <> rest1Out) $$
273−-- | Wrap inlines if the text wrap option is selected, specialized
274−-- for LaTeX and ConTeXt.
275−wrapTeXIfNeeded :: Monad m
278− -> ([Inline] -> m Doc)
281−wrapTeXIfNeeded opts includePercent = if writerWrapText opts
282− then wrappedTeX includePercent
285−-- | A version of hang that works like the version in pretty-1.0.0.0
286−hang' :: Doc -> Int -> Doc -> Doc
287−hang' d1 n d2 = d1 $$ (nest n d2)
290-- Pandoc block and inline list processing
215-- Pandoc block and inline list processing