git.iko.soy/typeable/pandoc
on master help sign in
Shared: Removed unneeded prettyprinting functions:
f15d479John MacFarlane
src/Text/Pandoc/Shared.hs−75
@@ -46,12 +46,6 @@ module Text.Pandoc.Shared (
46 escapeURI,
46 escapeURI,
47 unescapeURI,
47 unescapeURI,
48 tabFilter,
48 tabFilter,
49− -- * Prettyprinting
50− wrapped,
51− wrapIfNeeded,
52− wrappedTeX,
53− wrapTeXIfNeeded,
54− hang',
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 (
78
72
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
221
213
222−--
223−-- Prettyprinting
224−--
225−
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) >>=
229− return . fsep
230−
231−-- | Wrap inlines if the text wrap option is selected.
232−wrapIfNeeded :: Monad m => WriterOptions -> ([Inline] -> m Doc) ->
233− [Inline] -> m Doc
234−wrapIfNeeded opts = if writerWrapText opts
235− then wrapped
236− else ($)
237−
238−-- auxiliary function for wrappedTeX
239−isNote :: Inline -> Bool
240−isNote (Note _) = True
241−isNote _ = False
242−
243−-- | Wrap inlines to line length, treating footnotes in a way that
244−-- makes sense in LaTeX and ConTeXt.
245−wrappedTeX :: Monad m
246− => Bool
247− -> ([Inline] -> m Doc)
248− -> [Inline]
249− -> m Doc
250−wrappedTeX includePercent listWriter sect = do
251− let (firstpart, rest) = break isNote sect
252− firstpartWrapped <- wrapped listWriter firstpart
253− if null rest
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
263− then return empty
264− else listWriter rest1
265− rest2Wrapped <- if null rest2
266− then return empty
267− else wrappedTeX includePercent listWriter (tail rest2)
268− noteText <- listWriter [note]
269− return $ (firstpartWrapped <> if includePercent then PP.char '%' else empty) $$
270− (noteText <> rest1Out) $$
271− rest2Wrapped
272−
273−-- | Wrap inlines if the text wrap option is selected, specialized
274−-- for LaTeX and ConTeXt.
275−wrapTeXIfNeeded :: Monad m
276− => WriterOptions
277− -> Bool
278− -> ([Inline] -> m Doc)
279− -> [Inline]
280− -> m Doc
281−wrapTeXIfNeeded opts includePercent = if writerWrapText opts
282− then wrappedTeX includePercent
283− else ($)
284−
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)
288−
289--
214--
290-- Pandoc block and inline list processing
215-- Pandoc block and inline list processing
291--
216--