git.iko.soy/typeable/pandoc
on master help sign in
Fixed whitespace errors.
commit6d7f0a1b816c405fb48bcf9736db17a0a7d49995 authorJohn MacFarlane <fiddlosopher@gmail.com> dateThu 26 Jul 2012, 22:32 (14 years ago) parente797ab9
26 files changed+385−385
src/Text/Pandoc/MIME.hs+1−1 src/Text/Pandoc/Parsing.hs+25−25 src/Text/Pandoc/Pretty.hs+1−1 src/Text/Pandoc/Readers/DocBook.hs+5−5 src/Text/Pandoc/Readers/HTML.hs+5−5 src/Text/Pandoc/Readers/Markdown.hs+31−31 src/Text/Pandoc/Readers/Native.hs+1−1 src/Text/Pandoc/Readers/RST.hs+26−26 src/Text/Pandoc/Readers/TeXMath.hs+1−1 src/Text/Pandoc/Readers/Textile.hs+12−12 src/Text/Pandoc/SelfContained.hs+2−2 src/Text/Pandoc/Shared.hs+9−9 src/Text/Pandoc/Templates.hs+8−8 src/Text/Pandoc/UTF8.hs+1−1 src/Text/Pandoc/Writers/ConTeXt.hs+23−23 src/Text/Pandoc/Writers/Docbook.hs+33−33 src/Text/Pandoc/Writers/HTML.hs+1−1 src/Text/Pandoc/Writers/Man.hs+39−39 src/Text/Pandoc/Writers/Markdown.hs+20−20 src/Text/Pandoc/Writers/MediaWiki.hs+23−23 src/Text/Pandoc/Writers/Native.hs+4−4 src/Text/Pandoc/Writers/Org.hs+26−26 src/Text/Pandoc/Writers/RST.hs+24−24 src/Text/Pandoc/Writers/RTF.hs+40−40 src/Text/Pandoc/Writers/Texinfo.hs+9−9 src/Text/Pandoc/Writers/Textile.hs+15−15
src/Text/Pandoc/MIME.hs+1−1
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919{- |
2020 Module : Text.Pandoc.MIME
2121 Copyright : Copyright (C) 2011 John MacFarlane
22− License : GNU GPL, version 2 or above
22+ License : GNU GPL, version 2 or above
2323
2424 Maintainer : John MacFarlane <jgm@berkeley.edu>
2525 Stability : alpha
src/Text/Pandoc/Parsing.hs+25−25
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919{- |
2020 Module : Text.Pandoc.Parsing
2121 Copyright : Copyright (C) 2006-2010 John MacFarlane
22− License : GNU GPL, version 2 or above
22+ License : GNU GPL, version 2 or above
2323
2424 Maintainer : John MacFarlane <jgm@berkeley.edu>
2525 Stability : alpha
@@ -167,7 +167,7 @@ many1Till p end = do
167167 rest <- manyTill p end
168168 return (first:rest)
169169
170−-- | A more general form of @notFollowedBy@. This one allows any
170+-- | A more general form of @notFollowedBy@. This one allows any
171171-- type of parser to be specified, and succeeds only if that parser fails.
172172-- It does not consume any input.
173173notFollowedBy' :: Show b => Parsec [a] st b -> Parsec [a] st ()
@@ -213,7 +213,7 @@ enclosed :: Parsec [Char] st t -- ^ start parser
213213 -> Parsec [Char] st end -- ^ end parser
214214 -> Parsec [Char] st a -- ^ content parser (to be used repeatedly)
215215 -> Parsec [Char] st [a]
216−enclosed start end parser = try $
216+enclosed start end parser = try $
217217 start >> notFollowedBy space >> many1Till parser end
218218
219219-- | Parse string, case insensitive.
@@ -237,7 +237,7 @@ parseFromString parser str = do
237237
238238-- | Parse raw line block up to and including blank lines.
239239lineClump :: Parsec [Char] st String
240−lineClump = blanklines
240+lineClump = blanklines
241241 <|> (many1 (notFollowedBy blankline >> anyLine) >>= return . unlines)
242242
243243-- | Parse a string of characters between an open character
@@ -273,11 +273,11 @@ uppercaseRomanDigits = map toUpper lowercaseRomanDigits
273273romanNumeral :: Bool -- ^ Uppercase if true
274274 -> Parsec [Char] st Int
275275romanNumeral upperCase = do
276− let romanDigits = if upperCase
277− then uppercaseRomanDigits
276+ let romanDigits = if upperCase
277+ then uppercaseRomanDigits
278278 else lowercaseRomanDigits
279279 lookAhead $ oneOf romanDigits
280− let [one, five, ten, fifty, hundred, fivehundred, thousand] =
280+ let [one, five, ten, fifty, hundred, fivehundred, thousand] =
281281 map char romanDigits
282282 thousands <- many thousand >>= (return . (1000 *) . length)
283283 ninehundreds <- option 0 $ try $ hundred >> thousand >> return 900
@@ -468,15 +468,15 @@ romanOne = (char 'i' >> return (LowerRoman, 1)) <|>
468468 (char 'I' >> return (UpperRoman, 1))
469469
470470-- | Parses an ordered list marker and returns list attributes.
471−anyOrderedListMarker :: Parsec [Char] ParserState ListAttributes
472−anyOrderedListMarker = choice $
471+anyOrderedListMarker :: Parsec [Char] ParserState ListAttributes
472+anyOrderedListMarker = choice $
473473 [delimParser numParser | delimParser <- [inPeriod, inOneParen, inTwoParens],
474474 numParser <- [decimal, exampleNum, defaultNum, romanOne,
475475 lowerAlpha, lowerRoman, upperAlpha, upperRoman]]
476476
477477-- | Parses a list number (num) followed by a period, returns list attributes.
478478inPeriod :: Parsec [Char] st (ListNumberStyle, Int)
479− -> Parsec [Char] st ListAttributes
479+ -> Parsec [Char] st ListAttributes
480480inPeriod num = try $ do
481481 (style, start) <- num
482482 char '.'
@@ -484,10 +484,10 @@ inPeriod num = try $ do
484484 then DefaultDelim
485485 else Period
486486 return (start, style, delim)
487−
487+
488488-- | Parses a list number (num) followed by a paren, returns list attributes.
489489inOneParen :: Parsec [Char] st (ListNumberStyle, Int)
490− -> Parsec [Char] st ListAttributes
490+ -> Parsec [Char] st ListAttributes
491491inOneParen num = try $ do
492492 (style, start) <- num
493493 char ')'
@@ -495,7 +495,7 @@ inOneParen num = try $ do
495495
496496-- | Parses a list number (num) enclosed in parens, returns list attributes.
497497inTwoParens :: Parsec [Char] st (ListNumberStyle, Int)
498− -> Parsec [Char] st ListAttributes
498+ -> Parsec [Char] st ListAttributes
499499inTwoParens num = try $ do
500500 char '('
501501 (style, start) <- num
@@ -504,8 +504,8 @@ inTwoParens num = try $ do
504504
505505-- | Parses an ordered list marker with a given style and delimiter,
506506-- returns number.
507−orderedListMarker :: ListNumberStyle
508− -> ListNumberDelim
507+orderedListMarker :: ListNumberStyle
508+ -> ListNumberDelim
509509 -> Parsec [Char] ParserState Int
510510orderedListMarker style delim = do
511511 let num = defaultNum <|> -- # can continue any kind of list
@@ -552,8 +552,8 @@ tableWith headerParser rowParser lineParser footerParser = try $ do
552552widthsFromIndices :: Int -- Number of columns on terminal
553553 -> [Int] -- Indices
554554 -> [Double] -- Fractional relative sizes of columns
555−widthsFromIndices _ [] = []
556−widthsFromIndices numColumns' indices =
555+widthsFromIndices _ [] = []
556+widthsFromIndices numColumns' indices =
557557 let numColumns = max numColumns' (if null indices then 0 else last indices)
558558 lengths' = zipWith (-) indices (0:indices)
559559 lengths = reverse $
@@ -614,7 +614,7 @@ gridTableHeader headless block = try $ do
614614 optional blanklines
615615 dashes <- gridDashedLines '-'
616616 rawContent <- if headless
617− then return $ repeat ""
617+ then return $ repeat ""
618618 else many1
619619 (notFollowedBy (gridTableSep '=') >> char '|' >>
620620 many1Till anyChar newline)
@@ -671,7 +671,7 @@ readWith :: Parsec [t] ParserState a -- ^ parser
671671 -> ParserState -- ^ initial state
672672 -> [t] -- ^ input
673673 -> a
674−readWith parser state input =
674+readWith parser state input =
675675 case runParser parser state "source" input of
676676 Left err' -> error $ "\nError:\n" ++ show err'
677677 Right result -> result
@@ -697,7 +697,7 @@ data ParserState = ParserState
697697 stateDate :: [Inline], -- ^ Date of document
698698 stateHeaderTable :: [HeaderType], -- ^ Ordered list of header types used
699699 stateNextExample :: Int, -- ^ Number of next example
700− stateExamples :: M.Map String Int, -- ^ Map from example labels to numbers
700+ stateExamples :: M.Map String Int, -- ^ Map from example labels to numbers
701701 stateHasChapters :: Bool, -- ^ True if \chapter encountered
702702 stateMacros :: [Macro], -- ^ List of macros defined so far
703703 stateRstDefaultRole :: String -- ^ Current rST default interpreted text role
@@ -708,7 +708,7 @@ instance Default ParserState where
708708 def = defaultParserState
709709
710710defaultParserState :: ParserState
711−defaultParserState =
711+defaultParserState =
712712 ParserState { stateOptions = def,
713713 stateParserContext = NullState,
714714 stateQuoteContext = NoQuote,
@@ -737,12 +737,12 @@ guardEnabled ext = getOption readerExtensions >>= guard . Set.member ext
737737guardDisabled :: Extension -> Parser s ParserState ()
738738guardDisabled ext = getOption readerExtensions >>= guard . not . Set.member ext
739739
740−data HeaderType
740+data HeaderType
741741 = SingleHeader Char -- ^ Single line of characters underneath
742742 | DoubleHeader Char -- ^ Lines of characters above and below
743743 deriving (Eq, Show)
744744
745−data ParserContext
745+data ParserContext
746746 = ListItemState -- ^ Used when running parser on list item contents
747747 | NullState -- ^ Default state
748748 deriving (Eq, Show)
@@ -838,7 +838,7 @@ charOrRef cs =
838838 return c)
839839
840840updateLastStrPos :: Parsec [Char] ParserState ()
841−updateLastStrPos = getPosition >>= \p ->
841+updateLastStrPos = getPosition >>= \p ->
842842 updateState $ \s -> s{ stateLastStrPos = Just p }
843843
844844singleQuoteStart :: Parsec [Char] ParserState ()
@@ -852,7 +852,7 @@ singleQuoteStart = do
852852 notFollowedBy (oneOf ")!],;:-? \t\n")
853853 notFollowedBy (char '.') <|> lookAhead (string "..." >> return ())
854854 notFollowedBy (try (oneOfStrings ["s","t","m","ve","ll","re"] >>
855− satisfy (not . isAlphaNum)))
855+ satisfy (not . isAlphaNum)))
856856 -- possess/contraction
857857 return ()
858858
src/Text/Pandoc/Pretty.hs+1−1
@@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111(-1)307 USA
2020{- |
2121 Module : Text.Pandoc.Pretty
2222 Copyright : Copyright (C) 2010 John MacFarlane
23− License : GNU GPL, version 2 or above
23+ License : GNU GPL, version 2 or above
2424
2525 Maintainer : John MacFarlane <jgm@berkeley.edu>
2626 Stability : alpha
src/Text/Pandoc/Readers/DocBook.hs+5−5
@@ -455,13 +455,13 @@ List of all DocBook tags, with [x] indicating implemented,
455455[x] tocfront - An entry in a table of contents for a front matter component
456456[x] toclevel1 - A top-level entry within a table of contents entry for a
457457 chapter-like component
458−[x] toclevel2 - A second-level entry within a table of contents entry for a
458+[x] toclevel2 - A second-level entry within a table of contents entry for a
459459 chapter-like component
460−[x] toclevel3 - A third-level entry within a table of contents entry for a
460+[x] toclevel3 - A third-level entry within a table of contents entry for a
461461 chapter-like component
462−[x] toclevel4 - A fourth-level entry within a table of contents entry for a
462+[x] toclevel4 - A fourth-level entry within a table of contents entry for a
463463 chapter-like component
464−[x] toclevel5 - A fifth-level entry within a table of contents entry for a
464+[x] toclevel5 - A fifth-level entry within a table of contents entry for a
465465 chapter-like component
466466[x] tocpart - An entry in a table of contents for a part of a book
467467[ ] token - A unit of information
@@ -574,7 +574,7 @@ addToStart toadd bs =
574574 (Para xs : rest) -> para (toadd <> fromList xs) <> fromList rest
575575 _ -> bs
576576
577−-- function that is used by both mediaobject (in parseBlock)
577+-- function that is used by both mediaobject (in parseBlock)
578578-- and inlinemediaobject (in parseInline)
579579getImage :: Element -> DB Inlines
580580getImage e = do
src/Text/Pandoc/Readers/HTML.hs+5−5
@@ -19,10 +19,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919{- |
2020 Module : Text.Pandoc.Readers.HTML
2121 Copyright : Copyright (C) 2006-2010 John MacFarlane
22− License : GNU GPL, version 2 or above
22+ License : GNU GPL, version 2 or above
2323
2424 Maintainer : John MacFarlane <jgm@berkeley.edu>
25− Stability : alpha
25+ Stability : alpha
2626 Portability : portable
2727
2828Conversion of HTML to 'Pandoc' document.
@@ -231,7 +231,7 @@ pSimpleTable = try $ do
231231 rows <- pOptInTag "tbody"
232232 $ many1 $ try $ skipMany pBlank >> pInTags "tr" (pCell "td")
233233 skipMany pBlank
234− TagClose _ <- pSatisfy (~== TagClose "table")
234+ TagClose _ <- pSatisfy (~== TagClose "table")
235235 let cols = maximum $ map length rows
236236 let aligns = replicate cols AlignLeft
237237 let widths = replicate cols 0
@@ -303,7 +303,7 @@ pLocation = do
303303pSat :: (Tag String -> Bool) -> TagParser (Tag String)
304304pSat f = do
305305 pos <- getPosition
306− token show (const pos) (\x -> if f x then Just x else Nothing)
306+ token show (const pos) (\x -> if f x then Just x else Nothing)
307307
308308pSatisfy :: (Tag String -> Bool) -> TagParser (Tag String)
309309pSatisfy f = try $ optional pLocation >> pSat f
@@ -608,7 +608,7 @@ htmlTag f = try $ do
608608 count (length s + 4) anyChar
609609 skipMany (satisfy (/='>'))
610610 char '>'
611− return (next, "<!--" ++ s ++ "-->")
611+ return (next, "<!--" ++ s ++ "-->")
612612 _ -> do
613613 rendered <- manyTill anyChar (char '>')
614614 return (next, rendered ++ ">")
src/Text/Pandoc/Readers/Markdown.hs+31−31
@@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2020{- |
2121 Module : Text.Pandoc.Readers.Markdown
2222 Copyright : Copyright (C) 2006-2010 John MacFarlane
23− License : GNU GPL, version 2 or above
23+ License : GNU GPL, version 2 or above
2424
2525 Maintainer : John MacFarlane <jgm@berkeley.edu>
2626 Stability : alpha
@@ -94,7 +94,7 @@ nonindentSpaces :: Parser [Char] ParserState [Char]
9494nonindentSpaces = do
9595 tabStop <- getOption readerTabStop
9696 sps <- many (char ' ')
97− if length sps < tabStop
97+ if length sps < tabStop
9898 then return sps
9999 else unexpected "indented line"
100100
@@ -140,7 +140,7 @@ titleLine = try $ do
140140 return $ normalizeSpaces res
141141
142142authorsLine :: Parser [Char] ParserState [[Inline]]
143−authorsLine = try $ do
143+authorsLine = try $ do
144144 char '%'
145145 skipSpaces
146146 authors <- sepEndBy (many (notFollowedBy (satisfy $ \c ->
@@ -166,7 +166,7 @@ titleBlock = try $ do
166166 optional blanklines
167167 return (title, author, date)
168168
169−parseMarkdown :: Parser [Char] ParserState Pandoc
169+parseMarkdown :: Parser [Char] ParserState Pandoc
170170parseMarkdown = do
171171 -- markdown allows raw HTML
172172 updateState $ \state -> state { stateOptions =
@@ -202,7 +202,7 @@ parseMarkdown = do
202202 then return doc
203203 else return $ bottomUp handleExampleRef doc
204204
205−--
205+--
206206-- initial pass for references and notes
207207--
208208
@@ -422,7 +422,7 @@ codeBlockDelimited = try $ do
422422
423423codeBlockIndented :: Parser [Char] ParserState Block
424424codeBlockIndented = do
425− contents <- many1 (indentedLine <|>
425+ contents <- many1 (indentedLine <|>
426426 try (do b <- blanklines
427427 l <- indentedLine
428428 return $ b ++ l))
@@ -483,7 +483,7 @@ emailBlockQuoteStart = try $ skipNonindentSpaces >> char '>' >>~ optional (char
483483emailBlockQuote :: Parser [Char] ParserState [[Char]]
484484emailBlockQuote = try $ do
485485 emailBlockQuoteStart
486− raw <- sepBy (many (nonEndline <|>
486+ raw <- sepBy (many (nonEndline <|>
487487 (try (endline >> notFollowedBy emailBlockQuoteStart >>
488488 return '\n'))))
489489 (try (newline >> emailBlockQuoteStart))
@@ -492,12 +492,12 @@ emailBlockQuote = try $ do
492492 return raw
493493
494494blockQuote :: Parser [Char] ParserState Block
495−blockQuote = do
495+blockQuote = do
496496 raw <- emailBlockQuote
497497 -- parse the extracted block, which may contain various block elements:
498498 contents <- parseFromString parseBlocks $ (intercalate "\n" raw) ++ "\n\n"
499499 return $ BlockQuote contents
500−
500+
501501--
502502-- list blocks
503503--
@@ -511,7 +511,7 @@ bulletListStart = try $ do
511511 spaceChar
512512 skipSpaces
513513
514−anyOrderedListStart :: Parser [Char] ParserState (Int, ListNumberStyle, ListNumberDelim)
514+anyOrderedListStart :: Parser [Char] ParserState (Int, ListNumberStyle, ListNumberDelim)
515515anyOrderedListStart = try $ do
516516 optional newline -- if preceded by a Plain block in a list context
517517 skipNonindentSpaces
@@ -554,7 +554,7 @@ rawListItem start = try $ do
554554 blanks <- many blankline
555555 return $ concat (first:rest) ++ blanks
556556
557−-- continuation of a list item - indented and separated by blankline
557+-- continuation of a list item - indented and separated by blankline
558558-- or (in compact lists) endline.
559559-- note: nested lists are parsed as continuations
560560listContinuation :: Parser [Char] ParserState [Char]
@@ -672,7 +672,7 @@ isHtmlOrBlank (LineBreak) = True
672672isHtmlOrBlank _ = False
673673
674674para :: Parser [Char] ParserState Block
675−para = try $ do
675+para = try $ do
676676 result <- liftM normalizeSpaces $ many1 inline
677677 guard $ not . all isHtmlOrBlank $ result
678678 option (Plain result) $ try $ do
@@ -685,7 +685,7 @@ para = try $ do
685685plain :: Parser [Char] ParserState Block
686686plain = many1 inline >>~ spaces >>= return . Plain . normalizeSpaces
687687
688−--
688+--
689689-- raw html
690690--
691691
@@ -741,20 +741,20 @@ rawHtmlBlocks = do
741741
742742--
743743-- Tables
744−--
744+--
745745
746746-- Parse a dashed line with optional trailing spaces; return its length
747747-- and the length including trailing space.
748−dashedLine :: Char
748+dashedLine :: Char
749749 -> Parser [Char] st (Int, Int)
750750dashedLine ch = do
751751 dashes <- many1 (char ch)
752752 sp <- many spaceChar
753753 return $ (length dashes, length $ dashes ++ sp)
754754
755−-- Parse a table header with dashed lines of '-' preceded by
755+-- Parse a table header with dashed lines of '-' preceded by
756756-- one (or zero) line of text.
757−simpleTableHeader :: Bool -- ^ Headerless table
757+simpleTableHeader :: Bool -- ^ Headerless table
758758 -> Parser [Char] ParserState ([[Block]], [Alignment], [Int])
759759simpleTableHeader headless = try $ do
760760 rawContent <- if headless
@@ -768,12 +768,12 @@ simpleTableHeader headless = try $ do
768768 -- If no header, calculate alignment on basis of first row of text
769769 rawHeads <- liftM (tail . splitStringByIndices (init indices)) $
770770 if headless
771− then lookAhead anyLine
771+ then lookAhead anyLine
772772 else return rawContent
773773 let aligns = zipWith alignType (map (\a -> [a]) rawHeads) lengths
774774 let rawHeads' = if headless
775775 then replicate (length dashes) ""
776− else rawHeads
776+ else rawHeads
777777 heads <- mapM (parseFromString (many plain)) $
778778 map removeLeadingTrailingSpace rawHeads'
779779 return (heads, aligns, indices)
@@ -792,7 +792,7 @@ rawTableLine :: [Int]
792792rawTableLine indices = do
793793 notFollowedBy' (blanklines <|> tableFooter)
794794 line <- many1Till anyChar newline
795− return $ map removeLeadingTrailingSpace $ tail $
795+ return $ map removeLeadingTrailingSpace $ tail $
796796 splitStringByIndices (init indices) line
797797
798798-- Parse a table line and return a list of lists of blocks (columns).
@@ -845,7 +845,7 @@ multilineTableHeader headless = try $ do
845845 then return '\n'
846846 else tableSep >>~ notFollowedBy blankline
847847 rawContent <- if headless
848− then return $ repeat ""
848+ then return $ repeat ""
849849 else many1
850850 (notFollowedBy tableSep >> many1Till anyChar newline)
851851 initSp <- nonindentSpaces
@@ -856,7 +856,7 @@ multilineTableHeader headless = try $ do
856856 rawHeadsList <- if headless
857857 then liftM (map (:[]) . tail .
858858 splitStringByIndices (init indices)) $ lookAhead anyLine
859− else return $ transpose $ map
859+ else return $ transpose $ map
860860 (\ln -> tail $ splitStringByIndices (init indices) ln)
861861 rawContent
862862 let aligns = zipWith alignType rawHeadsList lengths
@@ -1026,7 +1026,7 @@ exampleRef = try $ do
10261026 return $ Str $ '@' : lab
10271027
10281028symbol :: Parser [Char] ParserState Inline
1029−symbol = do
1029+symbol = do
10301030 result <- noneOf "<\\\n\t "
10311031 <|> try (do lookAhead $ char '\\'
10321032 notFollowedBy' rawTeXBlock
@@ -1035,12 +1035,12 @@ symbol = do
10351035
10361036-- parses inline code, between n `s and n `s
10371037code :: Parser [Char] ParserState Inline
1038−code = try $ do
1038+code = try $ do
10391039 starts <- many1 (char '`')
10401040 skipSpaces
10411041 result <- many1Till (many1 (noneOf "`\n") <|> many1 (char '`') <|>
10421042 (char '\n' >> notFollowedBy' blankline >> return " "))
1043− (try (skipSpaces >> count (length starts) (char '`') >>
1043+ (try (skipSpaces >> count (length starts) (char '`') >>
10441044 notFollowedBy (char '`')))
10451045 attr <- option ([],[],[]) (try $ optional whitespace >> attributes)
10461046 return $ Code attr $ removeLeadingTrailingSpace $ concat result
@@ -1058,7 +1058,7 @@ math :: Parser [Char] ParserState Inline
10581058math = (mathDisplay >>= applyMacros' >>= return . Math DisplayMath)
10591059 <|> (mathInline >>= applyMacros' >>= return . Math InlineMath)
10601060
1061−mathDisplay :: Parser [Char] ParserState String
1061+mathDisplay :: Parser [Char] ParserState String
10621062mathDisplay = try $ do
10631063 guardEnabled Ext_tex_math
10641064 string "$$"
@@ -1129,14 +1129,14 @@ strikeout = Strikeout `liftM`
11291129 strikeEnd = try $ string "~~"
11301130
11311131superscript :: Parser [Char] ParserState Inline
1132−superscript = guardEnabled Ext_superscript >> enclosed (char '^') (char '^')
1132+superscript = guardEnabled Ext_superscript >> enclosed (char '^') (char '^')
11331133 (notFollowedBy spaceChar >> inline) >>= -- may not contain Space
11341134 return . Superscript
11351135
11361136subscript :: Parser [Char] ParserState Inline
11371137subscript = guardEnabled Ext_subscript >> enclosed (char '~') (char '~')
11381138 (notFollowedBy spaceChar >> inline) >>= -- may not contain Space
1139− return . Subscript
1139+ return . Subscript
11401140
11411141whitespace :: Parser [Char] ParserState Inline
11421142whitespace = spaceChar >>
@@ -1257,13 +1257,13 @@ delinkify = bottomUp $ concatMap go
12571257referenceLink :: [Inline]
12581258 -> Parser [Char] ParserState (String, [Char])
12591259referenceLink lab = do
1260− ref <- option [] (try (optional (char ' ') >>
1260+ ref <- option [] (try (optional (char ' ') >>
12611261 optional (newline >> skipSpaces) >> reference))
12621262 let ref' = if null ref then lab else ref
12631263 state <- getState
12641264 case lookupKeySrc (stateKeys state) (toKey ref') of
1265− Nothing -> fail "no corresponding key"
1266− Just target -> return target
1265+ Nothing -> fail "no corresponding key"
1266+ Just target -> return target
12671267
12681268autoLink :: Parser [Char] ParserState Inline
12691269autoLink = try $ do
src/Text/Pandoc/Readers/Native.hs+1−1
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919{- |
2020 Module : Text.Pandoc.Readers.Native
2121 Copyright : Copyright (C) 2011 John MacFarlane
22− License : GNU GPL, version 2 or above
22+ License : GNU GPL, version 2 or above
2323
2424 Maintainer : John MacFarlane <jgm@berkeley.edu>
2525 Stability : alpha
src/Text/Pandoc/Readers/RST.hs+26−26
@@ -17,9 +17,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1717-}
1818
1919{- |
20− Module : Text.Pandoc.Readers.RST
20+ Module : Text.Pandoc.Readers.RST
2121 Copyright : Copyright (C) 2006-2010 John MacFarlane
22− License : GNU GPL, version 2 or above
22+ License : GNU GPL, version 2 or above
2323
2424 Maintainer : John MacFarlane <jgm@berkeley.edu>
2525 Stability : alpha
@@ -71,14 +71,14 @@ isHeader _ _ = False
7171-- | Promote all headers in a list of blocks. (Part of
7272-- title transformation for RST.)
7373promoteHeaders :: Int -> [Block] -> [Block]
74−promoteHeaders num ((Header level text):rest) =
74+promoteHeaders num ((Header level text):rest) =
7575 (Header (level - num) text):(promoteHeaders num rest)
7676promoteHeaders num (other:rest) = other:(promoteHeaders num rest)
7777promoteHeaders _ [] = []
7878
7979-- | If list of blocks starts with a header (or a header and subheader)
8080-- of level that are not found elsewhere, return it as a title and
81−-- promote all the other headers.
81+-- promote all the other headers.
8282titleTransform :: [Block] -- ^ list of blocks
8383 -> ([Block], [Inline]) -- ^ modified list of blocks, title
8484titleTransform ((Header 1 head1):(Header 2 head2):rest) |
@@ -238,14 +238,14 @@ paraBeforeCodeBlock = try $ do
238238
239239-- regular paragraph
240240paraNormal :: Parser [Char] ParserState Block
241−paraNormal = try $ do
241+paraNormal = try $ do
242242 result <- many1 inline
243243 newline
244244 blanklines
245245 return $ Para $ normalizeSpaces result
246246
247247plain :: Parser [Char] ParserState Block
248−plain = many1 inline >>= return . Plain . normalizeSpaces
248+plain = many1 inline >>= return . Plain . normalizeSpaces
249249
250250--
251251-- image block
@@ -284,7 +284,7 @@ doubleHeader = try $ do
284284 blankline -- spaces and newline
285285 count lenTop (char c) -- the bottom line
286286 blanklines
287− -- check to see if we've had this kind of header before.
287+ -- check to see if we've had this kind of header before.
288288 -- if so, get appropriate level. if not, add to list.
289289 state <- getState
290290 let headerTable = stateHeaderTable state
@@ -296,7 +296,7 @@ doubleHeader = try $ do
296296
297297-- a header with line on the bottom only
298298singleHeader :: Parser [Char] ParserState Block
299−singleHeader = try $ do
299+singleHeader = try $ do
300300 notFollowedBy' whitespace
301301 txt <- many1 (do {notFollowedBy blankline; inline})
302302 pos <- getPosition
@@ -498,8 +498,8 @@ indentWith num = do
498498 tabStop <- getOption readerTabStop
499499 if (num < tabStop)
500500 then count num (char ' ')
501− else choice [ try (count num (char ' ')),
502− (try (char '\t' >> count (num - tabStop) (char ' '))) ]
501+ else choice [ try (count num (char ' ')),
502+ (try (char '\t' >> count (num - tabStop) (char ' '))) ]
503503
504504-- parse raw text for one list item, excluding start marker and continuations
505505rawListItem :: Parser [Char] ParserState Int
@@ -510,8 +510,8 @@ rawListItem start = try $ do
510510 restLines <- many (listLine markerLength)
511511 return (markerLength, (firstLine ++ "\n" ++ (concat restLines)))
512512
513−-- continuation of a list item - indented and separated by blankline or
514−-- (in compact lists) endline.
513+-- continuation of a list item - indented and separated by blankline or
514+-- (in compact lists) endline.
515515-- Note: nested lists are parsed as continuations.
516516listContinuation :: Int -> Parser [Char] ParserState [Char]
517517listContinuation markerLength = try $ do
@@ -521,7 +521,7 @@ listContinuation markerLength = try $ do
521521
522522listItem :: Parser [Char] ParserState Int
523523 -> Parser [Char] ParserState [Block]
524−listItem start = try $ do
524+listItem start = try $ do
525525 (markerLength, first) <- rawListItem start
526526 rest <- many (listContinuation markerLength)
527527 blanks <- choice [ try (many blankline >>~ lookAhead start),
@@ -545,7 +545,7 @@ orderedList = try $ do
545545 return $ OrderedList (start, style, delim) items'
546546
547547bulletList :: Parser [Char] ParserState Block
548−bulletList = many1 (listItem bulletListStart) >>=
548+bulletList = many1 (listItem bulletListStart) >>=
549549 return . BulletList . compactify
550550
551551--
@@ -617,7 +617,7 @@ noteMarker = do
617617quotedReferenceName :: Parser [Char] ParserState [Inline]
618618quotedReferenceName = try $ do
619619 char '`' >> notFollowedBy (char '`') -- `` means inline code!
620− label' <- many1Till inline (char '`')
620+ label' <- many1Till inline (char '`')
621621 return label'
622622
623623unquotedReferenceName :: Parser [Char] ParserState [Inline]
@@ -662,7 +662,7 @@ targetURI :: Parser [Char] st [Char]
662662targetURI = do
663663 skipSpaces
664664 optional newline
665− contents <- many1 (try (many spaceChar >> newline >>
665+ contents <- many1 (try (many spaceChar >> newline >>
666666 many1 spaceChar >> noneOf " \t\n") <|> noneOf "\n")
667667 blanklines
668668 return $ escapeURI $ removeLeadingTrailingSpace $ contents
@@ -702,7 +702,7 @@ regularKey = try $ do
702702-- Simple tables TODO:
703703-- - column spans
704704-- - multiline support
705−-- - ensure that rightmost column span does not need to reach end
705+-- - ensure that rightmost column span does not need to reach end
706706-- - require at least 2 columns
707707--
708708-- Grid tables TODO:
@@ -745,7 +745,7 @@ simpleTableSplitLine indices line =
745745 map removeLeadingTrailingSpace
746746 $ tail $ splitByIndices (init indices) line
747747
748−simpleTableHeader :: Bool -- ^ Headerless table
748+simpleTableHeader :: Bool -- ^ Headerless table
749749 -> Parser [Char] ParserState ([[Block]], [Alignment], [Int])
750750simpleTableHeader headless = try $ do
751751 optional blanklines
@@ -783,7 +783,7 @@ table = gridTable False <|> simpleTable False <|>
783783 gridTable True <|> simpleTable True <?> "table"
784784
785785
786− --
786+ --
787787 -- inline
788788 --
789789
@@ -808,7 +808,7 @@ inline = choice [ whitespace
808808hyphens :: Parser [Char] ParserState Inline
809809hyphens = do
810810 result <- many1 (char '-')
811− option Space endline
811+ option Space endline
812812 -- don't want to treat endline after hyphen or dash as a space
813813 return $ Str result
814814
@@ -819,13 +819,13 @@ escapedChar = do c <- escaped anyChar
819819 else Str [c]
820820
821821symbol :: Parser [Char] ParserState Inline
822−symbol = do
822+symbol = do
823823 result <- oneOf specialChars
824824 return $ Str [result]
825825
826826-- parses inline code, between codeStart and codeEnd
827827code :: Parser [Char] ParserState Inline
828−code = try $ do
828+code = try $ do
829829 string "``"
830830 result <- manyTill anyChar (try (string "``"))
831831 return $ Code nullAttr
@@ -841,11 +841,11 @@ atStart p = do
841841 p
842842
843843emph :: Parser [Char] ParserState Inline
844−emph = enclosed (atStart $ char '*') (char '*') inline >>=
844+emph = enclosed (atStart $ char '*') (char '*') inline >>=
845845 return . Emph . normalizeSpaces
846846
847847strong :: Parser [Char] ParserState Inline
848−strong = enclosed (atStart $ string "**") (try $ string "**") inline >>=
848+strong = enclosed (atStart $ string "**") (try $ string "**") inline >>=
849849 return . Strong . normalizeSpaces
850850
851851-- Parses inline interpreted text which is required to have the given role.
@@ -911,7 +911,7 @@ explicitLink :: Parser [Char] ParserState Inline
911911explicitLink = try $ do
912912 char '`'
913913 notFollowedBy (char '`') -- `` marks start of inline code
914− label' <- manyTill (notFollowedBy (char '`') >> inline)
914+ label' <- manyTill (notFollowedBy (char '`') >> inline)
915915 (try (spaces >> char '<'))
916916 src <- manyTill (noneOf ">\n") (char '>')
917917 skipSpaces
@@ -938,7 +938,7 @@ referenceLink = try $ do
938938 Just target -> return target
939939 -- if anonymous link, remove key so it won't be used again
940940 when (isAnonKey key) $ updateState $ \s -> s{ stateKeys = M.delete key keyTable }
941− return $ Link (normalizeSpaces label') (src, tit)
941+ return $ Link (normalizeSpaces label') (src, tit)
942942
943943autoURI :: Parser [Char] ParserState Inline
944944autoURI = do
src/Text/Pandoc/Readers/TeXMath.hs+1−1
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919{- |
2020 Module : Text.Pandoc.Readers.TeXMath
2121 Copyright : Copyright (C) 2007-2010 John MacFarlane
22− License : GNU GPL, version 2 or above
22+ License : GNU GPL, version 2 or above
2323
2424 Maintainer : John MacFarlane <jgm@berkeley.edu>
2525 Stability : alpha
src/Text/Pandoc/Readers/Textile.hs+12−12
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919{- |
2020 Module : Text.Pandoc.Readers.Textile
2121 Copyright : Copyright (C) 2010-2012 Paul Rivier and John MacFarlane
22− License : GNU GPL, version 2 or above
22+ License : GNU GPL, version 2 or above
2323
2424 Maintainer : Paul Rivier <paul*rivier#demotera*com>
2525 Stability : alpha
@@ -232,9 +232,9 @@ genericListItemAtDepth c depth = try $ do
232232 return ((Plain p):sublist)
233233
234234-- | A definition list is a set of consecutive definition items
235−definitionList :: Parser [Char] ParserState Block
235+definitionList :: Parser [Char] ParserState Block
236236definitionList = try $ DefinitionList <$> many1 definitionListItem
237−
237+
238238-- | A definition list item in textile begins with '- ', followed by
239239-- the term defined, then spaces and ":=". The definition follows, on
240240-- the same single line, or spaned on multiple line, after a line
@@ -283,7 +283,7 @@ para = try $ Para . normalizeSpaces <$> manyTill inline blockBreak
283283
284284
285285-- Tables
286−
286+
287287-- | A table cell spans until a pipe |
288288tableCell :: Parser [Char] ParserState TableCell
289289tableCell = do
@@ -303,7 +303,7 @@ tableRows = many1 tableRow
303303tableHeaders :: Parser [Char] ParserState [TableCell]
304304tableHeaders = let separator = (try $ string "|_.") in
305305 try $ ( separator *> (sepBy1 tableCell separator) <* char '|' <* newline )
306−
306+
307307-- | A table with an optional header. Current implementation can
308308-- handle tables with and without header, but will parse cells
309309-- alignment attributes as content.
@@ -313,12 +313,12 @@ table = try $ do
313313 rows <- tableRows
314314 blanklines
315315 let nbOfCols = max (length headers) (length $ head rows)
316− return $ Table []
316+ return $ Table []
317317 (replicate nbOfCols AlignDefault)
318318 (replicate nbOfCols 0.0)
319319 headers
320320 rows
321−
321+
322322
323323-- | Blocks like 'p' and 'table' do not need explicit block tag.
324324-- However, they can be used to set HTML/CSS attributes when needed.
@@ -326,7 +326,7 @@ maybeExplicitBlock :: String -- ^ block tag name
326326 -> Parser [Char] ParserState Block -- ^ implicit block
327327 -> Parser [Char] ParserState Block
328328maybeExplicitBlock name blk = try $ do
329− optional $ try $ string name >> optional attributes >> char '.' >>
329+ optional $ try $ string name >> optional attributes >> char '.' >>
330330 ((try whitespace) <|> endline)
331331 blk
332332
@@ -410,7 +410,7 @@ note = try $ do
410410 Nothing -> fail "note not found"
411411 Just raw -> liftM Note $ parseFromString parseBlocks raw
412412
413−-- | Special chars
413+-- | Special chars
414414markupChars :: [Char]
415415markupChars = "\\[]*#_@~-+^|%="
416416
@@ -429,10 +429,10 @@ wordBoundaries = markupChars ++ stringBreakers
429429hyphenedWords :: Parser [Char] ParserState String
430430hyphenedWords = try $ do
431431 hd <- noneOf wordBoundaries
432− tl <- many ( (noneOf wordBoundaries) <|>
432+ tl <- many ( (noneOf wordBoundaries) <|>
433433 try (oneOf markupChars <* lookAhead (noneOf wordBoundaries) ) )
434434 let wd = hd:tl
435− option wd $ try $
435+ option wd $ try $
436436 (\r -> concat [wd, "-", r]) <$> (char '-' *> hyphenedWords)
437437
438438-- | Any string
@@ -465,7 +465,7 @@ endline = try $ do
465465rawHtmlInline :: Parser [Char] ParserState Inline
466466rawHtmlInline = RawInline "html" . snd <$> htmlTag isInlineTag
467467
468−-- | Raw LaTeX Inline
468+-- | Raw LaTeX Inline
469469rawLaTeXInline' :: Parser [Char] ParserState Inline
470470rawLaTeXInline' = try $ do
471471 guardEnabled Ext_raw_tex
src/Text/Pandoc/SelfContained.hs+2−2
@@ -102,14 +102,14 @@ convertTag userdata t@(TagOpen "script" as) =
102102 src -> do
103103 (raw, mime) <- getRaw userdata (fromAttrib "type" t) src
104104 let enc = "data:" ++ mime ++ "," ++ escapeURIString isOk (toString raw)
105− return $ TagOpen "script" (("src",enc) : [(x,y) | (x,y) <- as, x /= "src"])
105+ return $ TagOpen "script" (("src",enc) : [(x,y) | (x,y) <- as, x /= "src"])
106106convertTag userdata t@(TagOpen "link" as) =
107107 case fromAttrib "href" t of
108108 [] -> return t
109109 src -> do
110110 (raw, mime) <- getRaw userdata (fromAttrib "type" t) src
111111 let enc = "data:" ++ mime ++ "," ++ escapeURIString isOk (toString raw)
112− return $ TagOpen "link" (("href",enc) : [(x,y) | (x,y) <- as, x /= "href"])
112+ return $ TagOpen "link" (("href",enc) : [(x,y) | (x,y) <- as, x /= "href"])
113113convertTag _ t = return t
114114
115115cssURLs :: Maybe FilePath -> FilePath -> ByteString -> IO ByteString
src/Text/Pandoc/Shared.hs+9−9
@@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2020{- |
2121 Module : Text.Pandoc.Shared
2222 Copyright : Copyright (C) 2006-2010 John MacFarlane
23− License : GNU GPL, version 2 or above
23+ License : GNU GPL, version 2 or above
2424
2525 Maintainer : John MacFarlane <jgm@berkeley.edu>
2626 Stability : alpha
@@ -150,7 +150,7 @@ backslashEscapes = map (\ch -> (ch, ['\\',ch]))
150150-- characters and strings.
151151escapeStringUsing :: [(Char, String)] -> String -> String
152152escapeStringUsing _ [] = ""
153−escapeStringUsing escapeTable (x:xs) =
153+escapeStringUsing escapeTable (x:xs) =
154154 case (lookup x escapeTable) of
155155 Just str -> str ++ rest
156156 Nothing -> x:rest
@@ -177,7 +177,7 @@ stripFirstAndLast :: String -> String
177177stripFirstAndLast str =
178178 drop 1 $ take ((length str) - 1) str
179179
180−-- | Change CamelCase word to hyphenated lowercase (e.g., camel-case).
180+-- | Change CamelCase word to hyphenated lowercase (e.g., camel-case).
181181camelCaseToHyphenated :: String -> String
182182camelCaseToHyphenated [] = ""
183183camelCaseToHyphenated (a:b:rest) | isLower a && isUpper b =
@@ -248,13 +248,13 @@ normalizeDate s = fmap (formatTime defaultTimeLocale "%F")
248248-- | Generate infinite lazy list of markers for an ordered list,
249249-- depending on list attributes.
250250orderedListMarkers :: (Int, ListNumberStyle, ListNumberDelim) -> [String]
251−orderedListMarkers (start, numstyle, numdelim) =
251+orderedListMarkers (start, numstyle, numdelim) =
252252 let singleton c = [c]
253253 nums = case numstyle of
254254 DefaultStyle -> map show [start..]
255255 Example -> map show [start..]
256256 Decimal -> map show [start..]
257− UpperAlpha -> drop (start - 1) $ cycle $
257+ UpperAlpha -> drop (start - 1) $ cycle $
258258 map singleton ['A'..'Z']
259259 LowerAlpha -> drop (start - 1) $ cycle $
260260 map singleton ['a'..'z']
@@ -386,7 +386,7 @@ isPara (Para _) = True
386386isPara _ = False
387387
388388-- | Data structure for defining hierarchical Pandoc documents
389−data Element = Blk Block
389+data Element = Blk Block
390390 | Sec Int [Int] String [Inline] [Element]
391391 -- lvl num ident label contents
392392 deriving (Eq, Read, Show, Typeable, Data)
@@ -414,7 +414,7 @@ hierarchicalizeWithIds ((Header level title'):xs) = do
414414 let ident = uniqueIdent title' usedIdents
415415 let lastnum' = take level lastnum
416416 let newnum = if length lastnum' >= level
417− then init lastnum' ++ [last lastnum' + 1]
417+ then init lastnum' ++ [last lastnum' + 1]
418418 else lastnum ++ replicate (level - length lastnum - 1) 0 ++ [1]
419419 S.put (newnum, (ident : usedIdents))
420420 let (sectionContents, rest) = break (headerLtEq level) xs
@@ -459,7 +459,7 @@ headerShift n = bottomUp shift
459459-- Writer options
460460--
461461
462−data HTMLMathMethod = PlainMath
462+data HTMLMathMethod = PlainMath
463463 | LaTeXMathML (Maybe String) -- url of LaTeXMathML.js
464464 | JsMath (Maybe String) -- url of jsMath load script
465465 | GladTeX
@@ -534,7 +534,7 @@ instance Default WriterOptions where
534534{-# DEPRECATED writerXeTeX "writerXeTeX no longer does anything" #-}
535535-- | Default writer options.
536536defaultWriterOptions :: WriterOptions
537−defaultWriterOptions =
537+defaultWriterOptions =
538538 WriterOptions { writerStandalone = False
539539 , writerTemplate = ""
540540 , writerVariables = []
src/Text/Pandoc/Templates.hs+8−8
@@ -30,7 +30,7 @@ A simple templating system with variable substitution and conditionals.
3030Example:
3131
3232> renderTemplate [("name","Sam"),("salary","50,000")] $
33−> "Hi, $name$. $if(salary)$You make $$$salary$.$else$No salary data.$endif$"
33+> "Hi, $name$. $if(salary)$You make $$$salary$.$else$No salary data.$endif$"
3434> "Hi, John. You make $50,000."
3535
3636A slot for an interpolated variable is a variable name surrounded
@@ -83,8 +83,8 @@ import Text.Pandoc.Shared (readDataFile)
8383import qualified Control.Exception.Extensible as E (try, IOException)
8484
8585-- | Get default template for the specified writer.
86−getDefaultTemplate :: (Maybe FilePath) -- ^ User data directory to search first
87− -> String -- ^ Name of writer
86+getDefaultTemplate :: (Maybe FilePath) -- ^ User data directory to search first
87+ -> String -- ^ Name of writer
8888 -> IO (Either E.IOException String)
8989getDefaultTemplate _ "native" = return $ Right ""
9090getDefaultTemplate _ "json" = return $ Right ""
@@ -108,18 +108,18 @@ adjustPosition str = do
108108 return str
109109
110110class TemplateTarget a where
111− toTarget :: String -> a
111+ toTarget :: String -> a
112112
113113instance TemplateTarget String where
114114 toTarget = id
115115
116−instance TemplateTarget ByteString where
116+instance TemplateTarget ByteString where
117117 toTarget = fromString
118118
119119instance TemplateTarget Html where
120120 toTarget = preEscapedString
121121
122−-- | Renders a template
122+-- | Renders a template
123123renderTemplate :: TemplateTarget a
124124 => [(String,String)] -- ^ Assoc. list of values for variables
125125 -> String -- ^ Template
@@ -178,14 +178,14 @@ for = try $ do
178178 string ")$"
179179 -- if newline after the "for", then a newline after "endfor" will be swallowed
180180 multiline <- option False $ try $ skipEndline >> return True
181− let matches = filter (\(k,_) -> k == id') vars
181+ let matches = filter (\(k,_) -> k == id') vars
182182 let indent = replicate pos ' '
183183 contents <- forM matches $ \m -> do
184184 updateState $ \(TemplateState p v) -> TemplateState p (m:v)
185185 raw <- liftM concat $ lookAhead parseTemplate
186186 return $ intercalate ('\n':indent) $ lines $ raw ++ "\n"
187187 parseTemplate
188− sep <- option "" $ do try (string "$sep$")
188+ sep <- option "" $ do try (string "$sep$")
189189 when multiline $ optional skipEndline
190190 liftM concat parseTemplate
191191 string "$endfor$"
src/Text/Pandoc/UTF8.hs+1−1
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919{- |
2020 Module : Text.Pandoc.UTF8
2121 Copyright : Copyright (C) 2010 John MacFarlane
22− License : GNU GPL, version 2 or above
22+ License : GNU GPL, version 2 or above
2323
2424 Maintainer : John MacFarlane <jgm@berkeley.edu>
2525 Stability : alpha
src/Text/Pandoc/Writers/ConTeXt.hs+23−23
@@ -20,10 +20,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2020{- |
2121 Module : Text.Pandoc.Writers.ConTeXt
2222 Copyright : Copyright (C) 2007-2010 John MacFarlane
23− License : GNU GPL, version 2 or above
23+ License : GNU GPL, version 2 or above
2424
2525 Maintainer : John MacFarlane <jgm@berkeley.edu>
26− Stability : alpha
26+ Stability : alpha
2727 Portability : portable
2828
2929Conversion of 'Pandoc' format into ConTeXt.
@@ -39,23 +39,23 @@ import Text.Pandoc.Pretty
3939import Text.Pandoc.Templates ( renderTemplate )
4040import Network.URI ( isURI, unEscapeString )
4141
42−data WriterState =
42+data WriterState =
4343 WriterState { stNextRef :: Int -- number of next URL reference
4444 , stOrderedListLevel :: Int -- level of ordered list
4545 , stOptions :: WriterOptions -- writer options
4646 }
4747
4848orderedListStyles :: [[Char]]
49−orderedListStyles = cycle ["[n]","[a]", "[r]", "[g]"]
49+orderedListStyles = cycle ["[n]","[a]", "[r]", "[g]"]
5050
5151-- | Convert Pandoc to ConTeXt.
5252writeConTeXt :: WriterOptions -> Pandoc -> String
53−writeConTeXt options document =
53+writeConTeXt options document =
5454 let defaultWriterState = WriterState { stNextRef = 1
5555 , stOrderedListLevel = 0
5656 , stOptions = options
57− }
58− in evalState (pandocToConTeXt options document) defaultWriterState
57+ }
58+ in evalState (pandocToConTeXt options document) defaultWriterState
5959
6060pandocToConTeXt :: WriterOptions -> Pandoc -> State WriterState String
6161pandocToConTeXt options (Pandoc (Meta title authors date) blocks) = do
@@ -120,7 +120,7 @@ elementToConTeXt opts (Sec level _ id' title' elements) = do
120120 return $ vcat (header' : innerContents)
121121
122122-- | Convert Pandoc block element to ConTeXt.
123−blockToConTeXt :: Block
123+blockToConTeXt :: Block
124124 -> State WriterState Doc
125125blockToConTeXt Null = return empty
126126blockToConTeXt (Plain lst) = inlineListToConTeXt lst
@@ -128,7 +128,7 @@ blockToConTeXt (Para [Image txt (src,_)]) = do
128128 capt <- inlineListToConTeXt txt
129129 return $ blankline $$ "\\placefigure[here,nonumber]" <> braces capt <>
130130 braces ("\\externalfigure" <> brackets (text src)) <> blankline
131−blockToConTeXt (Para lst) = do
131+blockToConTeXt (Para lst) = do
132132 contents <- inlineListToConTeXt lst
133133 return $ contents <> blankline
134134blockToConTeXt (BlockQuote lst) = do
@@ -147,18 +147,18 @@ blockToConTeXt (OrderedList (start, style', delim) lst) = do
147147 let level = stOrderedListLevel st
148148 put $ st {stOrderedListLevel = level + 1}
149149 contents <- mapM listItemToConTeXt lst
150− put $ st {stOrderedListLevel = level}
150+ put $ st {stOrderedListLevel = level}
151151 let start' = if start == 1 then "" else "start=" ++ show start
152152 let delim' = case delim of
153153 DefaultDelim -> ""
154− Period -> "stopper=."
155− OneParen -> "stopper=)"
154+ Period -> "stopper=."
155+ OneParen -> "stopper=)"
156156 TwoParens -> "left=(,stopper=)"
157− let width = maximum $ map length $ take (length contents)
157+ let width = maximum $ map length $ take (length contents)
158158 (orderedListMarkers (start, style', delim))
159159 let width' = (toEnum width + 1) / 2
160− let width'' = if width' > (1.5 :: Double)
161− then "width=" ++ show width' ++ "em"
160+ let width'' = if width' > (1.5 :: Double)
161+ then "width=" ++ show width' ++ "em"
162162 else ""
163163 let specs2Items = filter (not . null) [start', delim', width'']
164164 let specs2 = if null specs2Items
@@ -166,8 +166,8 @@ blockToConTeXt (OrderedList (start, style', delim) lst) = do
166166 else "[" ++ intercalate "," specs2Items ++ "]"
167167 let style'' = case style' of
168168 DefaultStyle -> orderedListStyles !! level
169− Decimal -> "[n]"
170− Example -> "[n]"
169+ Decimal -> "[n]"
170+ Example -> "[n]"
171171 LowerRoman -> "[r]"
172172 UpperRoman -> "[R]"
173173 LowerAlpha -> "[a]"
@@ -182,21 +182,21 @@ blockToConTeXt HorizontalRule = return $ "\\thinrule" <> blankline
182182blockToConTeXt (Header level lst) = sectionHeader "" level lst
183183blockToConTeXt (Table caption aligns widths heads rows) = do
184184 let colDescriptor colWidth alignment = (case alignment of
185− AlignLeft -> 'l'
185+ AlignLeft -> 'l'
186186 AlignRight -> 'r'
187187 AlignCenter -> 'c'
188188 AlignDefault -> 'l'):
189189 if colWidth == 0
190190 then "|"
191191 else ("p(" ++ printf "%.2f" colWidth ++ "\\textwidth)|")
192− let colDescriptors = "|" ++ (concat $
192+ let colDescriptors = "|" ++ (concat $
193193 zipWith colDescriptor widths aligns)
194194 headers <- if all null heads
195195 then return empty
196− else liftM ($$ "\\HL") $ tableRowToConTeXt heads
197− captionText <- inlineListToConTeXt caption
196+ else liftM ($$ "\\HL") $ tableRowToConTeXt heads
197+ captionText <- inlineListToConTeXt caption
198198 let captionText' = if null caption then text "none" else captionText
199− rows' <- mapM tableRowToConTeXt rows
199+ rows' <- mapM tableRowToConTeXt rows
200200 return $ "\\placetable[here]" <> braces captionText' $$
201201 "\\starttable" <> brackets (text colDescriptors) $$
202202 "\\HL" $$ headers $$
@@ -230,7 +230,7 @@ inlineListToConTeXt lst = liftM hcat $ mapM inlineToConTeXt lst
230230-- | Convert inline element to ConTeXt
231231inlineToConTeXt :: Inline -- ^ Inline to convert
232232 -> State WriterState Doc
233−inlineToConTeXt (Emph lst) = do
233+inlineToConTeXt (Emph lst) = do
234234 contents <- inlineListToConTeXt lst
235235 return $ braces $ "\\em " <> contents
236236inlineToConTeXt (Strong lst) = do
src/Text/Pandoc/Writers/Docbook.hs+33−33
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919{- |
2020 Module : Text.Pandoc.Writers.Docbook
2121 Copyright : Copyright (C) 2006-2010 John MacFarlane
22− License : GNU GPL, version 2 or above
22+ License : GNU GPL, version 2 or above
2323
2424 Maintainer : John MacFarlane <jgm@berkeley.edu>
2525 Stability : alpha
@@ -47,23 +47,23 @@ authorToDocbook opts name' =
4747 let name = render Nothing $ inlinesToDocbook opts name'
4848 in if ',' `elem` name
4949 then -- last name first
50− let (lastname, rest) = break (==',') name
50+ let (lastname, rest) = break (==',') name
5151 firstname = removeLeadingSpace rest in
52− inTagsSimple "firstname" (text $ escapeStringForXML firstname) <>
53− inTagsSimple "surname" (text $ escapeStringForXML lastname)
52+ inTagsSimple "firstname" (text $ escapeStringForXML firstname) <>
53+ inTagsSimple "surname" (text $ escapeStringForXML lastname)
5454 else -- last name last
5555 let namewords = words name
56− lengthname = length namewords
56+ lengthname = length namewords
5757 (firstname, lastname) = case lengthname of
58− 0 -> ("","")
58+ 0 -> ("","")
5959 1 -> ("", name)
6060 n -> (intercalate " " (take (n-1) namewords), last namewords)
61− in inTagsSimple "firstname" (text $ escapeStringForXML firstname) $$
62− inTagsSimple "surname" (text $ escapeStringForXML lastname)
61+ in inTagsSimple "firstname" (text $ escapeStringForXML firstname) $$
62+ inTagsSimple "surname" (text $ escapeStringForXML lastname)
6363
6464-- | Convert Pandoc document to string in Docbook format.
6565writeDocbook :: WriterOptions -> Pandoc -> String
66−writeDocbook opts (Pandoc (Meta tit auths dat) blocks) =
66+writeDocbook opts (Pandoc (Meta tit auths dat) blocks) =
6767 let title = inlinesToDocbook opts tit
6868 authors = map (authorToDocbook opts) auths
6969 date = inlinesToDocbook opts dat
@@ -92,7 +92,7 @@ writeDocbook opts (Pandoc (Meta tit auths dat) blocks) =
9292
9393-- | Convert an Element to Docbook.
9494elementToDocbook :: WriterOptions -> Int -> Element -> Doc
95−elementToDocbook opts _ (Blk block) = blockToDocbook opts block
95+elementToDocbook opts _ (Blk block) = blockToDocbook opts block
9696elementToDocbook opts lvl (Sec _ _num id' title elements) =
9797 -- Docbook doesn't allow sections with no content, so insert some if needed
9898 let elements' = if null elements
@@ -115,10 +115,10 @@ plainToPara :: Block -> Block
115115plainToPara (Plain x) = Para x
116116plainToPara x = x
117117
118−-- | Convert a list of pairs of terms and definitions into a list of
118+-- | Convert a list of pairs of terms and definitions into a list of
119119-- Docbook varlistentrys.
120120deflistItemsToDocbook :: WriterOptions -> [([Inline],[[Block]])] -> Doc
121−deflistItemsToDocbook opts items =
121+deflistItemsToDocbook opts items =
122122 vcat $ map (\(term, defs) -> deflistItemToDocbook opts term defs) items
123123
124124-- | Convert a term and a list of blocks into a Docbook varlistentry.
@@ -167,9 +167,9 @@ blockToDocbook _ (CodeBlock (_,classes,_) str) =
167167 then [s]
168168 else languagesByExtension . map toLower $ s
169169 langs = concatMap langsFrom classes
170−blockToDocbook opts (BulletList lst) =
171− inTagsIndented "itemizedlist" $ listItemsToDocbook opts lst
172−blockToDocbook _ (OrderedList _ []) = empty
170+blockToDocbook opts (BulletList lst) =
171+ inTagsIndented "itemizedlist" $ listItemsToDocbook opts lst
172+blockToDocbook _ (OrderedList _ []) = empty
173173blockToDocbook opts (OrderedList (start, numstyle, _) (first:rest)) =
174174 let attribs = case numstyle of
175175 DefaultStyle -> []
@@ -182,12 +182,12 @@ blockToDocbook opts (OrderedList (start, numstyle, _) (first:rest)) =
182182 items = if start == 1
183183 then listItemsToDocbook opts (first:rest)
184184 else (inTags True "listitem" [("override",show start)]
185− (blocksToDocbook opts $ map plainToPara first)) $$
186− listItemsToDocbook opts rest
185+ (blocksToDocbook opts $ map plainToPara first)) $$
186+ listItemsToDocbook opts rest
187187 in inTags True "orderedlist" attribs items
188−blockToDocbook opts (DefinitionList lst) =
189− inTagsIndented "variablelist" $ deflistItemsToDocbook opts lst
190−blockToDocbook _ (RawBlock "docbook" str) = text str -- raw XML block
188+blockToDocbook opts (DefinitionList lst) =
189+ inTagsIndented "variablelist" $ deflistItemsToDocbook opts lst
190+blockToDocbook _ (RawBlock "docbook" str) = text str -- raw XML block
191191-- we allow html for compatibility with earlier versions of pandoc
192192blockToDocbook _ (RawBlock "html" str) = text str -- raw XML block
193193blockToDocbook _ (RawBlock _ _) = empty
@@ -237,26 +237,26 @@ inlinesToDocbook opts lst = hcat $ map (inlineToDocbook opts) lst
237237
238238-- | Convert an inline element to Docbook.
239239inlineToDocbook :: WriterOptions -> Inline -> Doc
240−inlineToDocbook _ (Str str) = text $ escapeStringForXML str
241−inlineToDocbook opts (Emph lst) =
240+inlineToDocbook _ (Str str) = text $ escapeStringForXML str
241+inlineToDocbook opts (Emph lst) =
242242 inTagsSimple "emphasis" $ inlinesToDocbook opts lst
243−inlineToDocbook opts (Strong lst) =
243+inlineToDocbook opts (Strong lst) =
244244 inTags False "emphasis" [("role", "strong")] $ inlinesToDocbook opts lst
245−inlineToDocbook opts (Strikeout lst) =
245+inlineToDocbook opts (Strikeout lst) =
246246 inTags False "emphasis" [("role", "strikethrough")] $
247247 inlinesToDocbook opts lst
248−inlineToDocbook opts (Superscript lst) =
248+inlineToDocbook opts (Superscript lst) =
249249 inTagsSimple "superscript" $ inlinesToDocbook opts lst
250−inlineToDocbook opts (Subscript lst) =
250+inlineToDocbook opts (Subscript lst) =
251251 inTagsSimple "subscript" $ inlinesToDocbook opts lst
252−inlineToDocbook opts (SmallCaps lst) =
252+inlineToDocbook opts (SmallCaps lst) =
253253 inTags False "emphasis" [("role", "smallcaps")] $
254254 inlinesToDocbook opts lst
255−inlineToDocbook opts (Quoted _ lst) =
255+inlineToDocbook opts (Quoted _ lst) =
256256 inTagsSimple "quote" $ inlinesToDocbook opts lst
257257inlineToDocbook opts (Cite _ lst) =
258− inlinesToDocbook opts lst
259−inlineToDocbook _ (Code _ str) =
258+ inlinesToDocbook opts lst
259+inlineToDocbook _ (Code _ str) =
260260 inTagsSimple "literal" $ text (escapeStringForXML str)
261261inlineToDocbook opts (Math t str)
262262 | isMathML (writerHTMLMathMethod opts) =
@@ -282,7 +282,7 @@ inlineToDocbook _ Space = space
282282inlineToDocbook opts (Link txt (src, _)) =
283283 if isPrefixOf "mailto:" src
284284 then let src' = drop 7 src
285− emailLink = inTagsSimple "email" $ text $
285+ emailLink = inTagsSimple "email" $ text $
286286 escapeStringForXML $ src'
287287 in case txt of
288288 [Code _ s] | s == src' -> emailLink
@@ -292,14 +292,14 @@ inlineToDocbook opts (Link txt (src, _)) =
292292 then inTags False "link" [("linkend", drop 1 src)]
293293 else inTags False "ulink" [("url", src)]) $
294294 inlinesToDocbook opts txt
295−inlineToDocbook _ (Image _ (src, tit)) =
295+inlineToDocbook _ (Image _ (src, tit)) =
296296 let titleDoc = if null tit
297297 then empty
298298 else inTagsIndented "objectinfo" $
299299 inTagsIndented "title" (text $ escapeStringForXML tit)
300300 in inTagsIndented "inlinemediaobject" $ inTagsIndented "imageobject" $
301301 titleDoc $$ selfClosingTag "imagedata" [("fileref", src)]
302−inlineToDocbook opts (Note contents) =
302+inlineToDocbook opts (Note contents) =
303303 inTagsIndented "footnote" $ blocksToDocbook opts contents
304304
305305isMathML :: HTMLMathMethod -> Bool
src/Text/Pandoc/Writers/HTML.hs+1−1
@@ -618,7 +618,7 @@ inlineToHtml opts inline =
618618 ! A.src (toValue $ url ++ urlEncode str)
619619 ! A.alt (toValue str)
620620 ! A.title (toValue str)
621− let brtag = if writerHtml5 opts then H5.br else H.br
621+ let brtag = if writerHtml5 opts then H5.br else H.br
622622 return $ case t of
623623 InlineMath -> m
624624 DisplayMath -> brtag >> m >> brtag
src/Text/Pandoc/Writers/Man.hs+39−39
@@ -17,9 +17,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1717-}
1818
1919{- |
20− Module : Text.Pandoc.Writers.Man
20+ Module : Text.Pandoc.Writers.Man
2121 Copyright : Copyright (C) 2007-2010 John MacFarlane
22− License : GNU GPL, version 2 or above
22+ License : GNU GPL, version 2 or above
2323
2424 Maintainer : John MacFarlane <jgm@berkeley.edu>
2525 Stability : alpha
@@ -44,21 +44,21 @@ data WriterState = WriterState { stNotes :: Notes
4444
4545-- | Convert Pandoc to Man.
4646writeMan :: WriterOptions -> Pandoc -> String
47−writeMan opts document = evalState (pandocToMan opts document) (WriterState [] False)
47+writeMan opts document = evalState (pandocToMan opts document) (WriterState [] False)
4848
4949-- | Return groff man representation of document.
5050pandocToMan :: WriterOptions -> Pandoc -> State WriterState String
5151pandocToMan opts (Pandoc (Meta title authors date) blocks) = do
5252 titleText <- inlineListToMan opts title
5353 authors' <- mapM (inlineListToMan opts) authors
54− date' <- inlineListToMan opts date
54+ date' <- inlineListToMan opts date
5555 let colwidth = if writerWrapText opts
5656 then Just $ writerColumns opts
5757 else Nothing
5858 let render' = render colwidth
5959 let (cmdName, rest) = break (== ' ') $ render' titleText
6060 let (title', section) = case reverse cmdName of
61− (')':d:'(':xs) | d `elem` ['0'..'9'] ->
61+ (')':d:'(':xs) | d `elem` ['0'..'9'] ->
6262 (text (reverse xs), char d)
6363 xs -> (text (reverse xs), doubleQuotes empty)
6464 let description = hsep $
@@ -86,7 +86,7 @@ notesToMan :: WriterOptions -> [[Block]] -> State WriterState Doc
8686notesToMan opts notes =
8787 if null notes
8888 then return empty
89− else mapM (\(num, note) -> noteToMan opts num note) (zip [1..] notes) >>=
89+ else mapM (\(num, note) -> noteToMan opts num note) (zip [1..] notes) >>=
9090 return . (text ".SH NOTES" $$) . vcat
9191
9292-- | Return man representation of a note.
@@ -94,7 +94,7 @@ noteToMan :: WriterOptions -> Int -> [Block] -> State WriterState Doc
9494noteToMan opts num note = do
9595 contents <- blockListToMan opts note
9696 let marker = cr <> text ".SS " <> brackets (text (show num))
97− return $ marker $$ contents
97+ return $ marker $$ contents
9898
9999-- | Association list of characters to escape.
100100manEscapes :: [(Char, String)]
@@ -113,7 +113,7 @@ escapeString = escapeStringUsing manEscapes
113113-- | Escape a literal (code) section for Man.
114114escapeCode :: String -> String
115115escapeCode = concat . intersperse "\n" . map escapeLine . lines where
116− escapeLine codeline =
116+ escapeLine codeline =
117117 case escapeStringUsing (manEscapes ++ backslashEscapes "\t ") codeline of
118118 a@('.':_) -> "\\&" ++ a
119119 b -> b
@@ -150,14 +150,14 @@ splitSentences xs =
150150-- | Convert Pandoc block element to man.
151151blockToMan :: WriterOptions -- ^ Options
152152 -> Block -- ^ Block element
153− -> State WriterState Doc
153+ -> State WriterState Doc
154154blockToMan _ Null = return empty
155−blockToMan opts (Plain inlines) =
155+blockToMan opts (Plain inlines) =
156156 liftM vcat $ mapM (inlineListToMan opts) $ splitSentences inlines
157157blockToMan opts (Para inlines) = do
158158 contents <- liftM vcat $ mapM (inlineListToMan opts) $
159159 splitSentences inlines
160− return $ text ".PP" $$ contents
160+ return $ text ".PP" $$ contents
161161blockToMan _ (RawBlock "man" str) = return $ text str
162162blockToMan _ (RawBlock _ _) = return empty
163163blockToMan _ HorizontalRule = return $ text ".PP" $$ text " * * * * *"
@@ -166,7 +166,7 @@ blockToMan opts (Header level inlines) = do
166166 let heading = case level of
167167 1 -> ".SH "
168168 _ -> ".SS "
169− return $ text heading <> contents
169+ return $ text heading <> contents
170170blockToMan _ (CodeBlock _ str) = return $
171171 text ".IP" $$
172172 text ".nf" $$
@@ -174,10 +174,10 @@ blockToMan _ (CodeBlock _ str) = return $
174174 text (escapeCode str) $$
175175 text "\\f[]" $$
176176 text ".fi"
177−blockToMan opts (BlockQuote blocks) = do
177+blockToMan opts (BlockQuote blocks) = do
178178 contents <- blockListToMan opts blocks
179179 return $ text ".RS" $$ contents $$ text ".RE"
180−blockToMan opts (Table caption alignments widths headers rows) =
180+blockToMan opts (Table caption alignments widths headers rows) =
181181 let aligncode AlignLeft = "l"
182182 aligncode AlignRight = "r"
183183 aligncode AlignCenter = "c"
@@ -190,53 +190,53 @@ blockToMan opts (Table caption alignments widths headers rows) =
190190 else map (printf "w(%0.2fn)" . (70 *)) widths
191191 -- 78n default width - 8n indent = 70n
192192 let coldescriptions = text $ intercalate " "
193− (zipWith (\align width -> aligncode align ++ width)
193+ (zipWith (\align width -> aligncode align ++ width)
194194 alignments iwidths) ++ "."
195195 colheadings <- mapM (blockListToMan opts) headers
196− let makeRow cols = text "T{" $$
197− (vcat $ intersperse (text "T}@T{") cols) $$
196+ let makeRow cols = text "T{" $$
197+ (vcat $ intersperse (text "T}@T{") cols) $$
198198 text "T}"
199199 let colheadings' = if all null headers
200200 then empty
201201 else makeRow colheadings $$ char '_'
202− body <- mapM (\row -> do
202+ body <- mapM (\row -> do
203203 cols <- mapM (blockListToMan opts) row
204204 return $ makeRow cols) rows
205− return $ text ".PP" $$ caption' $$
206− text ".TS" $$ text "tab(@);" $$ coldescriptions $$
205+ return $ text ".PP" $$ caption' $$
206+ text ".TS" $$ text "tab(@);" $$ coldescriptions $$
207207 colheadings' $$ vcat body $$ text ".TE"
208208
209209blockToMan opts (BulletList items) = do
210210 contents <- mapM (bulletListItemToMan opts) items
211− return (vcat contents)
211+ return (vcat contents)
212212blockToMan opts (OrderedList attribs items) = do
213− let markers = take (length items) $ orderedListMarkers attribs
213+ let markers = take (length items) $ orderedListMarkers attribs
214214 let indent = 1 + (maximum $ map length markers)
215215 contents <- mapM (\(num, item) -> orderedListItemToMan opts num indent item) $
216− zip markers items
216+ zip markers items
217217 return (vcat contents)
218−blockToMan opts (DefinitionList items) = do
218+blockToMan opts (DefinitionList items) = do
219219 contents <- mapM (definitionListItemToMan opts) items
220220 return (vcat contents)
221221
222222-- | Convert bullet list item (list of blocks) to man.
223223bulletListItemToMan :: WriterOptions -> [Block] -> State WriterState Doc
224224bulletListItemToMan _ [] = return empty
225−bulletListItemToMan opts ((Para first):rest) =
225+bulletListItemToMan opts ((Para first):rest) =
226226 bulletListItemToMan opts ((Plain first):rest)
227227bulletListItemToMan opts ((Plain first):rest) = do
228− first' <- blockToMan opts (Plain first)
228+ first' <- blockToMan opts (Plain first)
229229 rest' <- blockListToMan opts rest
230230 let first'' = text ".IP \\[bu] 2" $$ first'
231231 let rest'' = if null rest
232232 then empty
233233 else text ".RS 2" $$ rest' $$ text ".RE"
234− return (first'' $$ rest'')
234+ return (first'' $$ rest'')
235235bulletListItemToMan opts (first:rest) = do
236236 first' <- blockToMan opts first
237237 rest' <- blockListToMan opts rest
238238 return $ text "\\[bu] .RS 2" $$ first' $$ rest' $$ text ".RE"
239−
239+
240240-- | Convert ordered list item (a list of blocks) to man.
241241orderedListItemToMan :: WriterOptions -- ^ options
242242 -> String -- ^ order marker for list item
@@ -244,7 +244,7 @@ orderedListItemToMan :: WriterOptions -- ^ options
244244 -> [Block] -- ^ list item (list of blocks)
245245 -> State WriterState Doc
246246orderedListItemToMan _ _ _ [] = return empty
247−orderedListItemToMan opts num indent ((Para first):rest) =
247+orderedListItemToMan opts num indent ((Para first):rest) =
248248 orderedListItemToMan opts num indent ((Plain first):rest)
249249orderedListItemToMan opts num indent (first:rest) = do
250250 first' <- blockToMan opts first
@@ -254,17 +254,17 @@ orderedListItemToMan opts num indent (first:rest) = do
254254 let rest'' = if null rest
255255 then empty
256256 else text ".RS 4" $$ rest' $$ text ".RE"
257− return $ first'' $$ rest''
257+ return $ first'' $$ rest''
258258
259259-- | Convert definition list item (label, list of blocks) to man.
260260definitionListItemToMan :: WriterOptions
261− -> ([Inline],[[Block]])
261+ -> ([Inline],[[Block]])
262262 -> State WriterState Doc
263263definitionListItemToMan opts (label, defs) = do
264264 labelText <- inlineListToMan opts label
265− contents <- if null defs
265+ contents <- if null defs
266266 then return empty
267− else liftM vcat $ forM defs $ \blocks -> do
267+ else liftM vcat $ forM defs $ \blocks -> do
268268 let (first, rest) = case blocks of
269269 ((Para x):y) -> (Plain x,y)
270270 (x:y) -> (x,y)
@@ -278,7 +278,7 @@ definitionListItemToMan opts (label, defs) = do
278278-- | Convert list of Pandoc block elements to man.
279279blockListToMan :: WriterOptions -- ^ Options
280280 -> [Block] -- ^ List of block elements
281− -> State WriterState Doc
281+ -> State WriterState Doc
282282blockListToMan opts blocks =
283283 mapM (blockToMan opts) blocks >>= (return . vcat)
284284
@@ -292,7 +292,7 @@ inlineListToMan opts lst = mapM (inlineToMan opts) lst >>= (return . hcat)
292292
293293-- | Convert Pandoc inline element to man.
294294inlineToMan :: WriterOptions -> Inline -> State WriterState Doc
295−inlineToMan opts (Emph lst) = do
295+inlineToMan opts (Emph lst) = do
296296 contents <- inlineListToMan opts lst
297297 return $ text "\\f[I]" <> contents <> text "\\f[]"
298298inlineToMan opts (Strong lst) = do
@@ -333,16 +333,16 @@ inlineToMan opts (Link txt (src, _)) = do
333333 let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src
334334 return $ case txt of
335335 [Code _ s]
336− | s == srcSuffix -> char '<' <> text srcSuffix <> char '>'
336+ | s == srcSuffix -> char '<' <> text srcSuffix <> char '>'
337337 _ -> linktext <> text " (" <> text src <> char ')'
338338inlineToMan opts (Image alternate (source, tit)) = do
339− let txt = if (null alternate) || (alternate == [Str ""]) ||
339+ let txt = if (null alternate) || (alternate == [Str ""]) ||
340340 (alternate == [Str source]) -- to prevent autolinks
341341 then [Str "image"]
342342 else alternate
343− linkPart <- inlineToMan opts (Link txt (source, tit))
343+ linkPart <- inlineToMan opts (Link txt (source, tit))
344344 return $ char '[' <> text "IMAGE: " <> linkPart <> char ']'
345−inlineToMan _ (Note contents) = do
345+inlineToMan _ (Note contents) = do
346346 -- add to notes in state
347347 modify $ \st -> st{ stNotes = contents : stNotes st }
348348 notes <- liftM stNotes get
src/Text/Pandoc/Writers/Markdown.hs+20−20
@@ -18,9 +18,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1818-}
1919
2020{- |
21− Module : Text.Pandoc.Writers.Markdown
21+ Module : Text.Pandoc.Writers.Markdown
2222 Copyright : Copyright (C) 2006-2010 John MacFarlane
23− License : GNU GPL, version 2 or above
23+ License : GNU GPL, version 2 or above
2424
2525 Maintainer : John MacFarlane <jgm@berkeley.edu>
2626 Stability : alpha
@@ -48,7 +48,7 @@ data WriterState = WriterState { stNotes :: Notes
4848
4949-- | Convert Pandoc to Markdown.
5050writeMarkdown :: WriterOptions -> Pandoc -> String
51−writeMarkdown opts document =
51+writeMarkdown opts document =
5252 evalState (pandocToMarkdown opts document) WriterState{ stNotes = []
5353 , stRefs = []
5454 , stPlain = False }
@@ -88,7 +88,7 @@ pandocToMarkdown opts (Pandoc (Meta title authors date) blocks) = do
8888 date' <- inlineListToMarkdown opts date
8989 let titleblock = not $ null title && null authors && null date
9090 let headerBlocks = filter isHeaderBlock blocks
91− let toc = if writerTableOfContents opts
91+ let toc = if writerTableOfContents opts
9292 then tableOfContents opts headerBlocks
9393 else empty
9494 body <- blockListToMarkdown opts blocks
@@ -118,9 +118,9 @@ pandocToMarkdown opts (Pandoc (Meta title authors date) blocks) = do
118118refsToMarkdown :: WriterOptions -> Refs -> State WriterState Doc
119119refsToMarkdown opts refs = mapM (keyToMarkdown opts) refs >>= return . vcat
120120
121−-- | Return markdown representation of a reference key.
122−keyToMarkdown :: WriterOptions
123− -> ([Inline], (String, String))
121+-- | Return markdown representation of a reference key.
122+keyToMarkdown :: WriterOptions
123+ -> ([Inline], (String, String))
124124 -> State WriterState Doc
125125keyToMarkdown opts (label, (src, tit)) = do
126126 label' <- inlineListToMarkdown opts label
@@ -132,7 +132,7 @@ keyToMarkdown opts (label, (src, tit)) = do
132132
133133-- | Return markdown representation of notes.
134134notesToMarkdown :: WriterOptions -> [[Block]] -> State WriterState Doc
135−notesToMarkdown opts notes =
135+notesToMarkdown opts notes =
136136 mapM (\(num, note) -> noteToMarkdown opts num note) (zip [1..] notes) >>=
137137 return . vsep
138138
@@ -154,7 +154,7 @@ escapeString = escapeStringUsing markdownEscapes
154154 where markdownEscapes = backslashEscapes "\\`*_$<>#~^"
155155
156156-- | Construct table of contents from list of header blocks.
157−tableOfContents :: WriterOptions -> [Block] -> Doc
157+tableOfContents :: WriterOptions -> [Block] -> Doc
158158tableOfContents opts headers =
159159 let opts' = opts { writerIgnoreNotes = True }
160160 contents = BulletList $ map elementToListItem $ hierarchicalize headers
@@ -165,7 +165,7 @@ tableOfContents opts headers =
165165-- | Converts an Element to a list item for a table of contents,
166166elementToListItem :: Element -> [Block]
167167elementToListItem (Blk _) = []
168−elementToListItem (Sec _ _ _ headerText subsecs) = [Plain headerText] ++
168+elementToListItem (Sec _ _ _ headerText subsecs) = [Plain headerText] ++
169169 if null subsecs
170170 then []
171171 else [BulletList $ map elementToListItem subsecs]
@@ -189,7 +189,7 @@ attrsToMarkdown attribs = braces $ hsep [attribId, attribClasses, attribKeys]
189189-- | Ordered list start parser for use in Para below.
190190olMarker :: Parser [Char] ParserState Char
191191olMarker = do (start, style', delim) <- anyOrderedListMarker
192− if delim == Period &&
192+ if delim == Period &&
193193 (style' == UpperAlpha || (style' == UpperRoman &&
194194 start `elem` [1, 5, 10, 50, 100, 500, 1000]))
195195 then spaceChar >> spaceChar
@@ -205,7 +205,7 @@ beginsWithOrderedListMarker str =
205205-- | Convert Pandoc block element to markdown.
206206blockToMarkdown :: WriterOptions -- ^ Options
207207 -> Block -- ^ Block element
208− -> State WriterState Doc
208+ -> State WriterState Doc
209209blockToMarkdown _ Null = return empty
210210blockToMarkdown opts (Plain inlines) = do
211211 contents <- inlineListToMarkdown opts inlines
@@ -348,7 +348,7 @@ orderedListItemToMarkdown opts marker items = do
348348
349349-- | Convert definition list item (label, list of blocks) to markdown.
350350definitionListItemToMarkdown :: WriterOptions
351− -> ([Inline],[[Block]])
351+ -> ([Inline],[[Block]])
352352 -> State WriterState Doc
353353definitionListItemToMarkdown opts (label, defs) = do
354354 labelText <- inlineListToMarkdown opts label
@@ -365,7 +365,7 @@ definitionListItemToMarkdown opts (label, defs) = do
365365-- | Convert list of Pandoc block elements to markdown.
366366blockListToMarkdown :: WriterOptions -- ^ Options
367367 -> [Block] -- ^ List of block elements
368− -> State WriterState Doc
368+ -> State WriterState Doc
369369blockListToMarkdown opts blocks =
370370 mapM (blockToMarkdown opts) (fixBlocks blocks) >>= return . cat
371371 -- insert comment between list and indented code block, or the
@@ -411,7 +411,7 @@ escapeSpaces x = x
411411
412412-- | Convert Pandoc inline element to markdown.
413413inlineToMarkdown :: WriterOptions -> Inline -> State WriterState Doc
414−inlineToMarkdown opts (Emph lst) = do
414+inlineToMarkdown opts (Emph lst) = do
415415 contents <- inlineListToMarkdown opts lst
416416 return $ "*" <> contents <> "*"
417417inlineToMarkdown opts (Strong lst) = do
@@ -436,11 +436,11 @@ inlineToMarkdown opts (Quoted DoubleQuote lst) = do
436436 contents <- inlineListToMarkdown opts lst
437437 return $ "“" <> contents <> "”"
438438inlineToMarkdown opts (Code attr str) =
439− let tickGroups = filter (\s -> '`' `elem` s) $ group str
439+ let tickGroups = filter (\s -> '`' `elem` s) $ group str
440440 longest = if null tickGroups
441441 then 0
442− else maximum $ map length tickGroups
443− marker = replicate (longest + 1) '`'
442+ else maximum $ map length tickGroups
443+ marker = replicate (longest + 1) '`'
444444 spacer = if (longest == 0) then "" else " "
445445 attrs = if writerStrictMarkdown opts || attr == nullAttr
446446 then empty
@@ -512,7 +512,7 @@ inlineToMarkdown opts (Link txt (src, tit)) = do
512512 then "[]"
513513 else "[" <> reftext <> "]"
514514 in first <> second
515− else "[" <> linktext <> "](" <>
515+ else "[" <> linktext <> "](" <>
516516 text src <> linktitle <> ")"
517517inlineToMarkdown opts (Image alternate (source, tit)) = do
518518 let txt = if null alternate || alternate == [Str source]
@@ -521,7 +521,7 @@ inlineToMarkdown opts (Image alternate (source, tit)) = do
521521 else alternate
522522 linkPart <- inlineToMarkdown opts (Link txt (source, tit))
523523 return $ "!" <> linkPart
524−inlineToMarkdown _ (Note contents) = do
524+inlineToMarkdown _ (Note contents) = do
525525 modify (\st -> st{ stNotes = contents : stNotes st })
526526 st <- get
527527 let ref = show $ (length $ stNotes st)
src/Text/Pandoc/Writers/MediaWiki.hs+23−23
@@ -17,9 +17,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1717-}
1818
1919{- |
20− Module : Text.Pandoc.Writers.MediaWiki
20+ Module : Text.Pandoc.Writers.MediaWiki
2121 Copyright : Copyright (C) 2008-2010 John MacFarlane
22− License : GNU GPL, version 2 or above
22+ License : GNU GPL, version 2 or above
2323
2424 Maintainer : John MacFarlane <jgm@berkeley.edu>
2525 Stability : alpha
@@ -31,7 +31,7 @@ MediaWiki: <http://www.mediawiki.org/wiki/MediaWiki>
3131-}
3232module Text.Pandoc.Writers.MediaWiki ( writeMediaWiki ) where
3333import Text.Pandoc.Definition
34−import Text.Pandoc.Shared
34+import Text.Pandoc.Shared
3535import Text.Pandoc.Templates (renderTemplate)
3636import Text.Pandoc.XML ( escapeStringForXML )
3737import Data.List ( intersect, intercalate )
@@ -46,9 +46,9 @@ data WriterState = WriterState {
4646
4747-- | Convert Pandoc to MediaWiki.
4848writeMediaWiki :: WriterOptions -> Pandoc -> String
49−writeMediaWiki opts document =
50− evalState (pandocToMediaWiki opts document)
51− (WriterState { stNotes = False, stListLevel = [], stUseTags = False })
49+writeMediaWiki opts document =
50+ evalState (pandocToMediaWiki opts document)
51+ (WriterState { stNotes = False, stListLevel = [], stUseTags = False })
5252
5353-- | Return MediaWiki representation of document.
5454pandocToMediaWiki :: WriterOptions -> Pandoc -> State WriterState String
@@ -57,7 +57,7 @@ pandocToMediaWiki opts (Pandoc _ blocks) = do
5757 notesExist <- get >>= return . stNotes
5858 let notes = if notesExist
5959 then "\n<references />"
60− else ""
60+ else ""
6161 let main = body ++ notes
6262 let context = writerVariables opts ++
6363 [ ("body", main) ] ++
@@ -70,18 +70,18 @@ pandocToMediaWiki opts (Pandoc _ blocks) = do
7070escapeString :: String -> String
7171escapeString = escapeStringForXML
7272
73−-- | Convert Pandoc block element to MediaWiki.
73+-- | Convert Pandoc block element to MediaWiki.
7474blockToMediaWiki :: WriterOptions -- ^ Options
7575 -> Block -- ^ Block element
76− -> State WriterState String
76+ -> State WriterState String
7777
7878blockToMediaWiki _ Null = return ""
7979
80−blockToMediaWiki opts (Plain inlines) =
80+blockToMediaWiki opts (Plain inlines) =
8181 inlineListToMediaWiki opts inlines
8282
8383blockToMediaWiki opts (Para [Image txt (src,tit)]) = do
84− capt <- inlineListToMediaWiki opts txt
84+ capt <- inlineListToMediaWiki opts txt
8585 let opt = if null txt
8686 then ""
8787 else "|alt=" ++ if null tit then capt else tit ++
@@ -115,7 +115,7 @@ blockToMediaWiki _ (CodeBlock (_,classes,_) str) = do
115115 "javascript", "latex", "lisp", "lua", "matlab", "mirc", "mpasm", "mysql", "nsis", "objc",
116116 "ocaml", "ocaml-brief", "oobas", "oracle8", "pascal", "perl", "php", "php-brief", "plsql",
117117 "python", "qbasic", "rails", "reg", "robots", "ruby", "sas", "scheme", "sdlbasic",
118− "smalltalk", "smarty", "sql", "tcl", "", "thinbasic", "tsql", "vb", "vbnet", "vhdl",
118+ "smalltalk", "smarty", "sql", "tcl", "", "thinbasic", "tsql", "vb", "vbnet", "vhdl",
119119 "visualfoxpro", "winbatch", "xml", "xpp", "z80"]
120120 let (beg, end) = if null at
121121 then ("<pre" ++ if null classes then ">" else " class=\"" ++ unwords classes ++ "\">", "</pre>")
@@ -124,7 +124,7 @@ blockToMediaWiki _ (CodeBlock (_,classes,_) str) = do
124124
125125blockToMediaWiki opts (BlockQuote blocks) = do
126126 contents <- blockListToMediaWiki opts blocks
127− return $ "<blockquote>" ++ contents ++ "</blockquote>"
127+ return $ "<blockquote>" ++ contents ++ "</blockquote>"
128128
129129blockToMediaWiki opts (Table capt aligns widths headers rows') = do
130130 let alignStrings = map alignmentToString aligns
@@ -221,7 +221,7 @@ listItemToMediaWiki opts items = do
221221
222222-- | Convert definition list item (label, list of blocks) to MediaWiki.
223223definitionListItemToMediaWiki :: WriterOptions
224− -> ([Inline],[[Block]])
224+ -> ([Inline],[[Block]])
225225 -> State WriterState String
226226definitionListItemToMediaWiki opts (label, items) = do
227227 labelText <- inlineListToMediaWiki opts label
@@ -242,7 +242,7 @@ isSimpleList x =
242242 BulletList items -> all isSimpleListItem items
243243 OrderedList (num, sty, _) items -> all isSimpleListItem items &&
244244 num == 1 && sty `elem` [DefaultStyle, Decimal]
245− DefinitionList items -> all isSimpleListItem $ concatMap snd items
245+ DefinitionList items -> all isSimpleListItem $ concatMap snd items
246246 _ -> False
247247
248248-- | True if list item can be handled with the simple wiki syntax. False if
@@ -287,8 +287,8 @@ tableRowToMediaWiki opts alignStrings rownum cols' = do
287287 0 -> "header"
288288 x | x `rem` 2 == 1 -> "odd"
289289 _ -> "even"
290− cols'' <- sequence $ zipWith
291− (\alignment item -> tableItemToMediaWiki opts celltype alignment item)
290+ cols'' <- sequence $ zipWith
291+ (\alignment item -> tableItemToMediaWiki opts celltype alignment item)
292292 alignStrings cols'
293293 return $ "<tr class=\"" ++ rowclass ++ "\">\n" ++ unlines cols'' ++ "</tr>"
294294
@@ -313,7 +313,7 @@ tableItemToMediaWiki opts celltype align' item = do
313313-- | Convert list of Pandoc block elements to MediaWiki.
314314blockListToMediaWiki :: WriterOptions -- ^ Options
315315 -> [Block] -- ^ List of block elements
316− -> State WriterState String
316+ -> State WriterState String
317317blockListToMediaWiki opts blocks =
318318 mapM (blockToMediaWiki opts) blocks >>= return . vcat
319319
@@ -325,9 +325,9 @@ inlineListToMediaWiki opts lst =
325325-- | Convert Pandoc inline element to MediaWiki.
326326inlineToMediaWiki :: WriterOptions -> Inline -> State WriterState String
327327
328−inlineToMediaWiki opts (Emph lst) = do
328+inlineToMediaWiki opts (Emph lst) = do
329329 contents <- inlineListToMediaWiki opts lst
330− return $ "''" ++ contents ++ "''"
330+ return $ "''" ++ contents ++ "''"
331331
332332inlineToMediaWiki opts (Strong lst) = do
333333 contents <- inlineListToMediaWiki opts lst
@@ -365,8 +365,8 @@ inlineToMediaWiki _ (Str str) = return $ escapeString str
365365inlineToMediaWiki _ (Math _ str) = return $ "<math>" ++ str ++ "</math>"
366366 -- note: str should NOT be escaped
367367
368−inlineToMediaWiki _ (RawInline "mediawiki" str) = return str
369−inlineToMediaWiki _ (RawInline "html" str) = return str
368+inlineToMediaWiki _ (RawInline "mediawiki" str) = return str
369+inlineToMediaWiki _ (RawInline "html" str) = return str
370370inlineToMediaWiki _ (RawInline _ _) = return ""
371371
372372inlineToMediaWiki _ (LineBreak) = return "<br />\n"
@@ -392,7 +392,7 @@ inlineToMediaWiki opts (Image alt (source, tit)) = do
392392 else "|" ++ tit
393393 return $ "[[Image:" ++ source ++ txt ++ "]]"
394394
395−inlineToMediaWiki opts (Note contents) = do
395+inlineToMediaWiki opts (Note contents) = do
396396 contents' <- blockListToMediaWiki opts contents
397397 modify (\s -> s { stNotes = True })
398398 return $ "<ref>" ++ contents' ++ "</ref>"
src/Text/Pandoc/Writers/Native.hs+4−4
@@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2020{- |
2121 Module : Text.Pandoc.Writers.Native
2222 Copyright : Copyright (C) 2006-2010 John MacFarlane
23− License : GNU GPL, version 2 or above
23+ License : GNU GPL, version 2 or above
2424
2525 Maintainer : John MacFarlane <jgm@berkeley.edu>
2626 Stability : alpha
@@ -47,17 +47,17 @@ prettyList ds =
4747prettyBlock :: Block -> Doc
4848prettyBlock (BlockQuote blocks) =
4949 "BlockQuote" $$ prettyList (map prettyBlock blocks)
50−prettyBlock (OrderedList attribs blockLists) =
50+prettyBlock (OrderedList attribs blockLists) =
5151 "OrderedList" <> space <> text (show attribs) $$
5252 (prettyList $ map (prettyList . map prettyBlock) blockLists)
53−prettyBlock (BulletList blockLists) =
53+prettyBlock (BulletList blockLists) =
5454 "BulletList" $$
5555 (prettyList $ map (prettyList . map prettyBlock) blockLists)
5656prettyBlock (DefinitionList items) = "DefinitionList" $$
5757 (prettyList $ map deflistitem items)
5858 where deflistitem (term, defs) = "(" <> text (show term) <> "," <> cr <>
5959 nest 1 (prettyList $ map (prettyList . map prettyBlock) defs) <> ")"
60−prettyBlock (Table caption aligns widths header rows) =
60+prettyBlock (Table caption aligns widths header rows) =
6161 "Table " <> text (show caption) <> " " <> text (show aligns) <> " " <>
6262 text (show widths) $$
6363 prettyRow header $$
src/Text/Pandoc/Writers/Org.hs+26−26
@@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2020{- |
2121 Module : Text.Pandoc.Writers.Org
2222 Copyright : Copyright (C) 2010 Puneeth Chaganti
23− License : GNU GPL, version 2 or above
23+ License : GNU GPL, version 2 or above
2424
2525 Maintainer : Puneeth Chaganti <punchagan@gmail.com>
2626 Stability : alpha
@@ -32,14 +32,14 @@ Org-Mode: <http://orgmode.org>
3232-}
3333module Text.Pandoc.Writers.Org ( writeOrg) where
3434import Text.Pandoc.Definition
35−import Text.Pandoc.Shared
35+import Text.Pandoc.Shared
3636import Text.Pandoc.Pretty
3737import Text.Pandoc.Templates (renderTemplate)
3838import Data.List ( intersect, intersperse, transpose )
3939import Control.Monad.State
4040import Control.Applicative ( (<$>) )
4141
42−data WriterState =
42+data WriterState =
4343 WriterState { stNotes :: [[Block]]
4444 , stLinks :: Bool
4545 , stImages :: Bool
@@ -49,7 +49,7 @@ data WriterState =
4949
5050-- | Convert Pandoc to Org.
5151writeOrg :: WriterOptions -> Pandoc -> String
52−writeOrg opts document =
52+writeOrg opts document =
5353 let st = WriterState { stNotes = [], stLinks = False,
5454 stImages = False, stHasMath = False,
5555 stOptions = opts }
@@ -82,8 +82,8 @@ pandocToOrg (Pandoc (Meta tit auth dat) blocks) = do
8282
8383-- | Return Org representation of notes.
8484notesToOrg :: [[Block]] -> State WriterState Doc
85−notesToOrg notes =
86− mapM (\(num, note) -> noteToOrg num note) (zip [1..] notes) >>=
85+notesToOrg notes =
86+ mapM (\(num, note) -> noteToOrg num note) (zip [1..] notes) >>=
8787 return . vsep
8888
8989-- | Return Org representation of a note.
@@ -106,11 +106,11 @@ titleToOrg :: [Inline] -> State WriterState Doc
106106titleToOrg [] = return empty
107107titleToOrg lst = do
108108 contents <- inlineListToOrg lst
109− return $ "#+TITLE: " <> contents
109+ return $ "#+TITLE: " <> contents
110110
111−-- | Convert Pandoc block element to Org.
111+-- | Convert Pandoc block element to Org.
112112blockToOrg :: Block -- ^ Block element
113− -> State WriterState Doc
113+ -> State WriterState Doc
114114blockToOrg Null = return empty
115115blockToOrg (Plain inlines) = inlineListToOrg inlines
116116blockToOrg (Para [Image txt (src,tit)]) = do
@@ -120,7 +120,7 @@ blockToOrg (Para [Image txt (src,tit)]) = do
120120blockToOrg (Para inlines) = do
121121 contents <- inlineListToOrg inlines
122122 return $ contents <> blankline
123−blockToOrg (RawBlock "html" str) =
123+blockToOrg (RawBlock "html" str) =
124124 return $ blankline $$ "#+BEGIN_HTML" $$
125125 nest 2 (text str) $$ "#+END_HTML" $$ blankline
126126blockToOrg (RawBlock f str) | f == "org" || f == "latex" || f == "tex" =
@@ -134,17 +134,17 @@ blockToOrg (Header level inlines) = do
134134blockToOrg (CodeBlock (_,classes,_) str) = do
135135 opts <- stOptions <$> get
136136 let tabstop = writerTabStop opts
137− let at = classes `intersect` ["asymptote", "C", "clojure", "css", "ditaa",
138− "dot", "emacs-lisp", "gnuplot", "haskell", "js", "latex",
139− "ledger", "lisp", "matlab", "mscgen", "ocaml", "octave",
140− "oz", "perl", "plantuml", "python", "R", "ruby", "sass",
137+ let at = classes `intersect` ["asymptote", "C", "clojure", "css", "ditaa",
138+ "dot", "emacs-lisp", "gnuplot", "haskell", "js", "latex",
139+ "ledger", "lisp", "matlab", "mscgen", "ocaml", "octave",
140+ "oz", "perl", "plantuml", "python", "R", "ruby", "sass",
141141 "scheme", "screen", "sh", "sql", "sqlite"]
142142 let (beg, end) = case at of
143143 [] -> ("#+BEGIN_EXAMPLE", "#+END_EXAMPLE")
144144 (x:_) -> ("#+BEGIN_SRC " ++ x, "#+END_SRC")
145145 return $ text beg $$ nest tabstop (text str) $$ text end $$ blankline
146146blockToOrg (BlockQuote blocks) = do
147− contents <- blockListToOrg blocks
147+ contents <- blockListToOrg blocks
148148 return $ blankline $$ "#+BEGIN_QUOTE" $$
149149 nest 2 contents $$ "#+END_QUOTE" $$ blankline
150150blockToOrg (Table caption' _ _ headers rows) = do
@@ -155,11 +155,11 @@ blockToOrg (Table caption' _ _ headers rows) = do
155155 headers' <- mapM blockListToOrg headers
156156 rawRows <- mapM (mapM blockListToOrg) rows
157157 let numChars = maximum . map offset
158− -- FIXME: width is not being used.
158+ -- FIXME: width is not being used.
159159 let widthsInChars =
160160 map ((+2) . numChars) $ transpose (headers' : rawRows)
161− -- FIXME: Org doesn't allow blocks with height more than 1.
162− let hpipeBlocks blocks = hcat [beg, middle, end]
161+ -- FIXME: Org doesn't allow blocks with height more than 1.
162+ let hpipeBlocks blocks = hcat [beg, middle, end]
163163 where h = maximum (map height blocks)
164164 sep' = lblock 3 $ vcat (map text $ replicate h " | ")
165165 beg = lblock 2 $ vcat (map text $ replicate h "| ")
@@ -170,7 +170,7 @@ blockToOrg (Table caption' _ _ headers rows) = do
170170 rows' <- mapM (\row -> do cols <- mapM blockListToOrg row
171171 return $ makeRow cols) rows
172172 let border ch = char '|' <> char ch <>
173− (hcat $ intersperse (char ch <> char '+' <> char ch) $
173+ (hcat $ intersperse (char ch <> char '+' <> char ch) $
174174 map (\l -> text $ replicate l ch) widthsInChars) <>
175175 char ch <> char '|'
176176 let body = vcat rows'
@@ -186,7 +186,7 @@ blockToOrg (OrderedList (start, _, delim) items) = do
186186 let delim' = case delim of
187187 TwoParens -> OneParen
188188 x -> x
189− let markers = take (length items) $ orderedListMarkers
189+ let markers = take (length items) $ orderedListMarkers
190190 (start, Decimal, delim')
191191 let maxMarkerLength = maximum $ map length markers
192192 let markers' = map (\m -> let s = maxMarkerLength - length m
@@ -222,7 +222,7 @@ definitionListItemToOrg (label, defs) = do
222222
223223-- | Convert list of Pandoc block elements to Org.
224224blockListToOrg :: [Block] -- ^ List of block elements
225− -> State WriterState Doc
225+ -> State WriterState Doc
226226blockListToOrg blocks = mapM blockToOrg blocks >>= return . vcat
227227
228228-- | Convert list of Pandoc inline elements to Org.
@@ -231,19 +231,19 @@ inlineListToOrg lst = mapM inlineToOrg lst >>= return . hcat
231231
232232-- | Convert Pandoc inline element to Org.
233233inlineToOrg :: Inline -> State WriterState Doc
234−inlineToOrg (Emph lst) = do
234+inlineToOrg (Emph lst) = do
235235 contents <- inlineListToOrg lst
236236 return $ "/" <> contents <> "/"
237237inlineToOrg (Strong lst) = do
238238 contents <- inlineListToOrg lst
239239 return $ "*" <> contents <> "*"
240−inlineToOrg (Strikeout lst) = do
240+inlineToOrg (Strikeout lst) = do
241241 contents <- inlineListToOrg lst
242242 return $ "+" <> contents <> "+"
243−inlineToOrg (Superscript lst) = do
243+inlineToOrg (Superscript lst) = do
244244 contents <- inlineListToOrg lst
245245 return $ "^{" <> contents <> "}"
246−inlineToOrg (Subscript lst) = do
246+inlineToOrg (Subscript lst) = do
247247 contents <- inlineListToOrg lst
248248 return $ "_{" <> contents <> "}"
249249inlineToOrg (SmallCaps lst) = inlineListToOrg lst
@@ -276,7 +276,7 @@ inlineToOrg (Link txt (src, _)) = do
276276inlineToOrg (Image _ (source, _)) = do
277277 modify $ \s -> s{ stImages = True }
278278 return $ "[[" <> text source <> "]]"
279−inlineToOrg (Note contents) = do
279+inlineToOrg (Note contents) = do
280280 -- add to notes in state
281281 notes <- get >>= (return . stNotes)
282282 modify $ \st -> st { stNotes = contents:notes }
src/Text/Pandoc/Writers/RST.hs+24−24
@@ -18,9 +18,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1818-}
1919
2020{- |
21− Module : Text.Pandoc.Writers.RST
21+ Module : Text.Pandoc.Writers.RST
2222 Copyright : Copyright (C) 2006-2010 John MacFarlane
23− License : GNU GPL, version 2 or above
23+ License : GNU GPL, version 2 or above
2424
2525 Maintainer : John MacFarlane <jgm@berkeley.edu>
2626 Stability : alpha
@@ -32,7 +32,7 @@ reStructuredText: <http://docutils.sourceforge.net/rst.html>
3232-}
3333module Text.Pandoc.Writers.RST ( writeRST) where
3434import Text.Pandoc.Definition
35−import Text.Pandoc.Shared
35+import Text.Pandoc.Shared
3636import Text.Pandoc.Templates (renderTemplate)
3737import Data.List ( isPrefixOf, intersperse, transpose )
3838import Text.Pandoc.Pretty
@@ -42,7 +42,7 @@ import Data.Char (isSpace)
4242
4343type Refs = [([Inline], Target)]
4444
45−data WriterState =
45+data WriterState =
4646 WriterState { stNotes :: [[Block]]
4747 , stLinks :: Refs
4848 , stImages :: Refs
@@ -52,7 +52,7 @@ data WriterState =
5252
5353-- | Convert Pandoc to RST.
5454writeRST :: WriterOptions -> Pandoc -> String
55−writeRST opts document =
55+writeRST opts document =
5656 let st = WriterState { stNotes = [], stLinks = [],
5757 stImages = [], stHasMath = False,
5858 stOptions = opts }
@@ -89,8 +89,8 @@ pandocToRST (Pandoc (Meta tit auth dat) blocks) = do
8989refsToRST :: Refs -> State WriterState Doc
9090refsToRST refs = mapM keyToRST refs >>= return . vcat
9191
92−-- | Return RST representation of a reference key.
93−keyToRST :: ([Inline], (String, String))
92+-- | Return RST representation of a reference key.
93+keyToRST :: ([Inline], (String, String))
9494 -> State WriterState Doc
9595keyToRST (label, (src, _)) = do
9696 label' <- inlineListToRST label
@@ -101,7 +101,7 @@ keyToRST (label, (src, _)) = do
101101
102102-- | Return RST representation of notes.
103103notesToRST :: [[Block]] -> State WriterState Doc
104−notesToRST notes =
104+notesToRST notes =
105105 mapM (\(num, note) -> noteToRST num note) (zip [1..] notes) >>=
106106 return . vsep
107107
@@ -116,8 +116,8 @@ noteToRST num note = do
116116pictRefsToRST :: Refs -> State WriterState Doc
117117pictRefsToRST refs = mapM pictToRST refs >>= return . vcat
118118
119−-- | Return RST representation of a picture substitution reference.
120−pictToRST :: ([Inline], (String, String))
119+-- | Return RST representation of a picture substitution reference.
120+pictToRST :: ([Inline], (String, String))
121121 -> State WriterState Doc
122122pictToRST (label, (src, _)) = do
123123 label' <- inlineListToRST label
@@ -135,9 +135,9 @@ titleToRST lst = do
135135 let border = text (replicate titleLength '=')
136136 return $ border $$ contents $$ border
137137
138−-- | Convert Pandoc block element to RST.
138+-- | Convert Pandoc block element to RST.
139139blockToRST :: Block -- ^ Block element
140− -> State WriterState Doc
140+ -> State WriterState Doc
141141blockToRST Null = return empty
142142blockToRST (Plain inlines) = inlineListToRST inlines
143143blockToRST (Para [Image txt (src,tit)]) = do
@@ -168,7 +168,7 @@ blockToRST (CodeBlock (_,classes,_) str) = do
168168 else return $ "::" $+$ nest tabstop (text str) $$ blankline
169169blockToRST (BlockQuote blocks) = do
170170 tabstop <- get >>= (return . writerTabStop . stOptions)
171− contents <- blockListToRST blocks
171+ contents <- blockListToRST blocks
172172 return $ (nest tabstop contents) <> blankline
173173blockToRST (Table caption _ widths headers rows) = do
174174 caption' <- inlineListToRST caption
@@ -184,7 +184,7 @@ blockToRST (Table caption _ widths headers rows) = do
184184 if isSimple
185185 then map ((+2) . numChars) $ transpose (headers' : rawRows)
186186 else map (floor . (fromIntegral (writerColumns opts) *)) widths
187− let hpipeBlocks blocks = hcat [beg, middle, end]
187+ let hpipeBlocks blocks = hcat [beg, middle, end]
188188 where h = maximum (map height blocks)
189189 sep' = lblock 3 $ vcat (map text $ replicate h " | ")
190190 beg = lblock 2 $ vcat (map text $ replicate h "| ")
@@ -195,7 +195,7 @@ blockToRST (Table caption _ widths headers rows) = do
195195 rows' <- mapM (\row -> do cols <- mapM blockListToRST row
196196 return $ makeRow cols) rows
197197 let border ch = char '+' <> char ch <>
198− (hcat $ intersperse (char ch <> char '+' <> char ch) $
198+ (hcat $ intersperse (char ch <> char '+' <> char ch) $
199199 map (\l -> text $ replicate l ch) widthsInChars) <>
200200 char ch <> char '+'
201201 let body = vcat $ intersperse (border '-') rows'
@@ -208,9 +208,9 @@ blockToRST (BulletList items) = do
208208 -- ensure that sublists have preceding blank line
209209 return $ blankline $$ vcat contents $$ blankline
210210blockToRST (OrderedList (start, style', delim) items) = do
211− let markers = if start == 1 && style' == DefaultStyle && delim == DefaultDelim
211+ let markers = if start == 1 && style' == DefaultStyle && delim == DefaultDelim
212212 then take (length items) $ repeat "#."
213− else take (length items) $ orderedListMarkers
213+ else take (length items) $ orderedListMarkers
214214 (start, style', delim)
215215 let maxMarkerLength = maximum $ map length markers
216216 let markers' = map (\m -> let s = maxMarkerLength - length m
@@ -249,7 +249,7 @@ definitionListItemToRST (label, defs) = do
249249
250250-- | Convert list of Pandoc block elements to RST.
251251blockListToRST :: [Block] -- ^ List of block elements
252− -> State WriterState Doc
252+ -> State WriterState Doc
253253blockListToRST blocks = mapM blockToRST blocks >>= return . vcat
254254
255255-- | Convert list of Pandoc inline elements to RST.
@@ -303,19 +303,19 @@ inlineListToRST lst = mapM inlineToRST (insertBS lst) >>= return . hcat
303303
304304-- | Convert Pandoc inline element to RST.
305305inlineToRST :: Inline -> State WriterState Doc
306−inlineToRST (Emph lst) = do
306+inlineToRST (Emph lst) = do
307307 contents <- inlineListToRST lst
308308 return $ "*" <> contents <> "*"
309309inlineToRST (Strong lst) = do
310310 contents <- inlineListToRST lst
311311 return $ "**" <> contents <> "**"
312−inlineToRST (Strikeout lst) = do
312+inlineToRST (Strikeout lst) = do
313313 contents <- inlineListToRST lst
314314 return $ "[STRIKEOUT:" <> contents <> "]"
315−inlineToRST (Superscript lst) = do
315+inlineToRST (Superscript lst) = do
316316 contents <- inlineListToRST lst
317317 return $ ":sup:`" <> contents <> "`"
318−inlineToRST (Subscript lst) = do
318+inlineToRST (Subscript lst) = do
319319 contents <- inlineListToRST lst
320320 return $ ":sub:`" <> contents <> "`"
321321inlineToRST (SmallCaps lst) = inlineListToRST lst
@@ -358,7 +358,7 @@ inlineToRST (Link txt (src, tit)) = do
358358 else return $ "`" <> linktext <> " <" <> text src <> ">`_"
359359inlineToRST (Image alternate (source, tit)) = do
360360 pics <- get >>= return . stImages
361− let labelsUsed = map fst pics
361+ let labelsUsed = map fst pics
362362 let txt = if null alternate || alternate == [Str ""] ||
363363 alternate `elem` labelsUsed
364364 then [Str $ "image" ++ show (length pics)]
@@ -369,7 +369,7 @@ inlineToRST (Image alternate (source, tit)) = do
369369 modify $ \st -> st { stImages = pics' }
370370 label <- inlineListToRST txt
371371 return $ "|" <> label <> "|"
372−inlineToRST (Note contents) = do
372+inlineToRST (Note contents) = do
373373 -- add to notes in state
374374 notes <- get >>= return . stNotes
375375 modify $ \st -> st { stNotes = contents:notes }
src/Text/Pandoc/Writers/RTF.hs+40−40
@@ -19,10 +19,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919{- |
2020 Module : Text.Pandoc.Writers.RTF
2121 Copyright : Copyright (C) 2006-2010 John MacFarlane
22− License : GNU GPL, version 2 or above
22+ License : GNU GPL, version 2 or above
2323
2424 Maintainer : John MacFarlane <jgm@berkeley.edu>
25− Stability : alpha
25+ Stability : alpha
2626 Portability : portable
2727
2828Conversion of 'Pandoc' documents to RTF (rich text format).
@@ -65,7 +65,7 @@ rtfEmbedImage x = return x
6565
6666-- | Convert Pandoc to a string in rich text format.
6767writeRTF :: WriterOptions -> Pandoc -> String
68−writeRTF options (Pandoc (Meta title authors date) blocks) =
68+writeRTF options (Pandoc (Meta title authors date) blocks) =
6969 let titletext = inlineListToRTF title
7070 authorstext = map inlineListToRTF authors
7171 datetext = inlineListToRTF date
@@ -84,11 +84,11 @@ writeRTF options (Pandoc (Meta title authors date) blocks) =
8484 else body
8585
8686-- | Construct table of contents from list of header blocks.
87−tableOfContents :: [Block] -> String
87+tableOfContents :: [Block] -> String
8888tableOfContents headers =
8989 let contentsTree = hierarchicalize headers
90− in concatMap (blockToRTF 0 AlignDefault) $
91− [Header 1 [Str "Contents"],
90+ in concatMap (blockToRTF 0 AlignDefault) $
91+ [Header 1 [Str "Contents"],
9292 BulletList (map elementToListItem contentsTree)]
9393
9494elementToListItem :: Element -> [Block]
@@ -102,7 +102,7 @@ elementToListItem (Sec _ _ _ sectext subsecs) = [Plain sectext] ++
102102handleUnicode :: String -> String
103103handleUnicode [] = []
104104handleUnicode (c:cs) =
105− if ord c > 127
105+ if ord c > 127
106106 then '\\':'u':(show (ord c)) ++ "?" ++ handleUnicode cs
107107 else c:(handleUnicode cs)
108108
@@ -132,32 +132,32 @@ rtfParSpaced :: Int -- ^ space after (in twips)
132132 -> Int -- ^ first line indent (relative to block) (in twips)
133133 -> Alignment -- ^ alignment
134134 -> String -- ^ string with content
135− -> String
136−rtfParSpaced spaceAfter indent firstLineIndent alignment content =
135+ -> String
136+rtfParSpaced spaceAfter indent firstLineIndent alignment content =
137137 let alignString = case alignment of
138138 AlignLeft -> "\\ql "
139139 AlignRight -> "\\qr "
140140 AlignCenter -> "\\qc "
141141 AlignDefault -> "\\ql "
142142 in "{\\pard " ++ alignString ++
143− "\\f0 \\sa" ++ (show spaceAfter) ++ " \\li" ++ (show indent) ++
143+ "\\f0 \\sa" ++ (show spaceAfter) ++ " \\li" ++ (show indent) ++
144144 " \\fi" ++ (show firstLineIndent) ++ " " ++ content ++ "\\par}\n"
145145
146−-- | Default paragraph.
146+-- | Default paragraph.
147147rtfPar :: Int -- ^ block indent (in twips)
148148 -> Int -- ^ first line indent (relative to block) (in twips)
149149 -> Alignment -- ^ alignment
150150 -> String -- ^ string with content
151− -> String
152−rtfPar = rtfParSpaced 180
151+ -> String
152+rtfPar = rtfParSpaced 180
153153
154154-- | Compact paragraph (e.g. for compact list items).
155155rtfCompact :: Int -- ^ block indent (in twips)
156156 -> Int -- ^ first line indent (relative to block) (in twips)
157157 -> Alignment -- ^ alignment
158158 -> String -- ^ string with content
159− -> String
160−rtfCompact = rtfParSpaced 0
159+ -> String
160+rtfCompact = rtfParSpaced 0
161161
162162-- number of twips to indent
163163indentIncrement :: Int
@@ -174,7 +174,7 @@ bulletMarker indent = case indent `mod` 720 of
174174
175175-- | Returns appropriate (list of) ordered list markers for indent level.
176176orderedMarkers :: Int -> ListAttributes -> [String]
177−orderedMarkers indent (start, style, delim) =
177+orderedMarkers indent (start, style, delim) =
178178 if style == DefaultStyle && delim == DefaultDelim
179179 then case indent `mod` 720 of
180180 0 -> orderedListMarkers (start, Decimal, Period)
@@ -187,30 +187,30 @@ blockToRTF :: Int -- ^ indent level
187187 -> Block -- ^ block to convert
188188 -> String
189189blockToRTF _ _ Null = ""
190−blockToRTF indent alignment (Plain lst) =
190+blockToRTF indent alignment (Plain lst) =
191191 rtfCompact indent 0 alignment $ inlineListToRTF lst
192−blockToRTF indent alignment (Para lst) =
192+blockToRTF indent alignment (Para lst) =
193193 rtfPar indent 0 alignment $ inlineListToRTF lst
194−blockToRTF indent alignment (BlockQuote lst) =
195− concatMap (blockToRTF (indent + indentIncrement) alignment) lst
194+blockToRTF indent alignment (BlockQuote lst) =
195+ concatMap (blockToRTF (indent + indentIncrement) alignment) lst
196196blockToRTF indent _ (CodeBlock _ str) =
197197 rtfPar indent 0 AlignLeft ("\\f1 " ++ (codeStringToRTF str))
198198blockToRTF _ _ (RawBlock "rtf" str) = str
199199blockToRTF _ _ (RawBlock _ _) = ""
200−blockToRTF indent alignment (BulletList lst) = spaceAtEnd $
200+blockToRTF indent alignment (BulletList lst) = spaceAtEnd $
201201 concatMap (listItemToRTF alignment indent (bulletMarker indent)) lst
202−blockToRTF indent alignment (OrderedList attribs lst) = spaceAtEnd $ concat $
202+blockToRTF indent alignment (OrderedList attribs lst) = spaceAtEnd $ concat $
203203 zipWith (listItemToRTF alignment indent) (orderedMarkers indent attribs) lst
204−blockToRTF indent alignment (DefinitionList lst) = spaceAtEnd $
204+blockToRTF indent alignment (DefinitionList lst) = spaceAtEnd $
205205 concatMap (definitionListItemToRTF alignment indent) lst
206−blockToRTF indent _ HorizontalRule =
206+blockToRTF indent _ HorizontalRule =
207207 rtfPar indent 0 AlignCenter "\\emdash\\emdash\\emdash\\emdash\\emdash"
208208blockToRTF indent alignment (Header level lst) = rtfPar indent 0 alignment $
209209 "\\b \\fs" ++ (show (40 - (level * 4))) ++ " " ++ inlineListToRTF lst
210−blockToRTF indent alignment (Table caption aligns sizes headers rows) =
210+blockToRTF indent alignment (Table caption aligns sizes headers rows) =
211211 (if all null headers
212212 then ""
213− else tableRowToRTF True indent aligns sizes headers) ++
213+ else tableRowToRTF True indent aligns sizes headers) ++
214214 concatMap (tableRowToRTF False indent aligns sizes) rows ++
215215 rtfPar indent 0 alignment (inlineListToRTF caption)
216216
@@ -232,7 +232,7 @@ tableRowToRTF header indent aligns sizes' cols =
232232 end = "}\n\\intbl\\row}\n"
233233 in start ++ columns ++ end
234234
235−tableItemToRTF :: Int -> Alignment -> [Block] -> String
235+tableItemToRTF :: Int -> Alignment -> [Block] -> String
236236tableItemToRTF indent alignment item =
237237 let contents = concatMap (blockToRTF indent alignment) item
238238 in "{\\intbl " ++ contents ++ "\\cell}\n"
@@ -240,7 +240,7 @@ tableItemToRTF indent alignment item =
240240-- | Ensure that there's the same amount of space after compact
241241-- lists as after regular lists.
242242spaceAtEnd :: String -> String
243−spaceAtEnd str =
243+spaceAtEnd str =
244244 if isSuffixOf "\\par}\n" str
245245 then (take ((length str) - 6) str) ++ "\\sa180\\par}\n"
246246 else str
@@ -251,10 +251,10 @@ listItemToRTF :: Alignment -- ^ alignment
251251 -> String -- ^ list start marker
252252 -> [Block] -- ^ list item (list of blocks)
253253 -> [Char]
254−listItemToRTF alignment indent marker [] =
255− rtfCompact (indent + listIncrement) (0 - listIncrement) alignment
256− (marker ++ "\\tx" ++ (show listIncrement) ++ "\\tab ")
257−listItemToRTF alignment indent marker list =
254+listItemToRTF alignment indent marker [] =
255+ rtfCompact (indent + listIncrement) (0 - listIncrement) alignment
256+ (marker ++ "\\tx" ++ (show listIncrement) ++ "\\tab ")
257+listItemToRTF alignment indent marker list =
258258 let (first:rest) = map (blockToRTF (indent + listIncrement) alignment) list
259259 listMarker = "\\fi" ++ show (0 - listIncrement) ++ " " ++ marker ++ "\\tx" ++
260260 show listIncrement ++ "\\tab"
@@ -277,7 +277,7 @@ definitionListItemToRTF alignment indent (label, defs) =
277277 let labelText = blockToRTF indent alignment (Plain label)
278278 itemsText = concatMap (blockToRTF (indent + listIncrement) alignment) $
279279 concat defs
280− in labelText ++ itemsText
280+ in labelText ++ itemsText
281281
282282-- | Convert list of inline items to RTF.
283283inlineListToRTF :: [Inline] -- ^ list of inlines to convert
@@ -293,9 +293,9 @@ inlineToRTF (Strikeout lst) = "{\\strike " ++ (inlineListToRTF lst) ++ "}"
293293inlineToRTF (Superscript lst) = "{\\super " ++ (inlineListToRTF lst) ++ "}"
294294inlineToRTF (Subscript lst) = "{\\sub " ++ (inlineListToRTF lst) ++ "}"
295295inlineToRTF (SmallCaps lst) = "{\\scaps " ++ (inlineListToRTF lst) ++ "}"
296−inlineToRTF (Quoted SingleQuote lst) =
296+inlineToRTF (Quoted SingleQuote lst) =
297297 "\\u8216'" ++ (inlineListToRTF lst) ++ "\\u8217'"
298−inlineToRTF (Quoted DoubleQuote lst) =
298+inlineToRTF (Quoted DoubleQuote lst) =
299299 "\\u8220\"" ++ (inlineListToRTF lst) ++ "\\u8221\""
300300inlineToRTF (Code _ str) = "{\\f1 " ++ (codeStringToRTF str) ++ "}"
301301inlineToRTF (Str str) = stringToRTF str
@@ -305,11 +305,11 @@ inlineToRTF (RawInline "rtf" str) = str
305305inlineToRTF (RawInline _ _) = ""
306306inlineToRTF (LineBreak) = "\\line "
307307inlineToRTF Space = " "
308−inlineToRTF (Link text (src, _)) =
309− "{\\field{\\*\\fldinst{HYPERLINK \"" ++ (codeStringToRTF src) ++
308+inlineToRTF (Link text (src, _)) =
309+ "{\\field{\\*\\fldinst{HYPERLINK \"" ++ (codeStringToRTF src) ++
310310 "\"}}{\\fldrslt{\\ul\n" ++ (inlineListToRTF text) ++ "\n}}}\n"
311−inlineToRTF (Image _ (source, _)) =
312− "{\\cf1 [image: " ++ source ++ "]\\cf0}"
311+inlineToRTF (Image _ (source, _)) =
312+ "{\\cf1 [image: " ++ source ++ "]\\cf0}"
313313inlineToRTF (Note contents) =
314− "{\\super\\chftn}{\\*\\footnote\\chftn\\~\\plain\\pard " ++
314+ "{\\super\\chftn}{\\*\\footnote\\chftn\\~\\plain\\pard " ++
315315 (concatMap (blockToRTF 0 AlignDefault) contents) ++ "}"
src/Text/Pandoc/Writers/Texinfo.hs+9−9
@@ -19,10 +19,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919{- |
2020 Module : Text.Pandoc.Writers.Texinfo
2121 Copyright : Copyright (C) 2008-2010 John MacFarlane and Peter Wang
22− License : GNU GPL, version 2 or above
22+ License : GNU GPL, version 2 or above
2323
2424 Maintainer : John MacFarlane <jgm@berkeley.edu>
25− Stability : alpha
25+ Stability : alpha
2626 Portability : portable
2727
2828Conversion of 'Pandoc' format into Texinfo.
@@ -40,7 +40,7 @@ import Text.Pandoc.Pretty
4040import Network.URI ( isAbsoluteURI, unEscapeString )
4141import System.FilePath
4242
43−data WriterState =
43+data WriterState =
4444 WriterState { stStrikeout :: Bool -- document contains strikeout
4545 , stSuperscript :: Bool -- document contains superscript
4646 , stSubscript :: Bool -- document contains subscript
@@ -53,8 +53,8 @@ data WriterState =
5353
5454-- | Convert Pandoc to Texinfo.
5555writeTexinfo :: WriterOptions -> Pandoc -> String
56−writeTexinfo options document =
57− evalState (pandocToTexinfo options $ wrapTop document) $
56+writeTexinfo options document =
57+ evalState (pandocToTexinfo options $ wrapTop document) $
5858 WriterState { stStrikeout = False, stSuperscript = False, stSubscript = False }
5959
6060-- | Add a "Top" node around the document, needed by Texinfo.
@@ -217,7 +217,7 @@ blockToTexinfo (Table caption aligns widths heads rows) = do
217217 else return $ "@columnfractions " ++ concatMap (printf "%.2f ") widths
218218 let tableBody = text ("@multitable " ++ colDescriptors) $$
219219 headers $$
220− vcat rowsText $$
220+ vcat rowsText $$
221221 text "@end multitable"
222222 return $ if isEmpty captionText
223223 then tableBody <> blankline
@@ -241,7 +241,7 @@ tableAnyRowToTexinfo :: String
241241 -> [[Block]]
242242 -> State WriterState Doc
243243tableAnyRowToTexinfo itemtype aligns cols =
244− zipWithM alignedBlock aligns cols >>=
244+ zipWithM alignedBlock aligns cols >>=
245245 return . (text itemtype $$) . foldl (\row item -> row $$
246246 (if isEmpty row then empty else text " @tab ") <> item) empty
247247
@@ -358,8 +358,8 @@ inlineToTexinfo :: Inline -- ^ Inline to convert
358358inlineToTexinfo (Emph lst) =
359359 inlineListToTexinfo lst >>= return . inCmd "emph"
360360
361−inlineToTexinfo (Strong lst) =
362− inlineListToTexinfo lst >>= return . inCmd "strong"
361+inlineToTexinfo (Strong lst) =
362+ inlineListToTexinfo lst >>= return . inCmd "strong"
363363
364364inlineToTexinfo (Strikeout lst) = do
365365 modify $ \st -> st{ stStrikeout = True }
src/Text/Pandoc/Writers/Textile.hs+15−15
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919{- |
2020 Module : Text.Pandoc.Writers.Textile
2121 Copyright : Copyright (C) 2010 John MacFarlane
22− License : GNU GPL, version 2 or above
22+ License : GNU GPL, version 2 or above
2323
2424 Maintainer : John MacFarlane <jgm@berkeley.edu>
2525 Stability : alpha
@@ -31,7 +31,7 @@ Textile: <http://thresholdstate.com/articles/4312/the-textile-reference-manual>
3131-}
3232module Text.Pandoc.Writers.Textile ( writeTextile ) where
3333import Text.Pandoc.Definition
34−import Text.Pandoc.Shared
34+import Text.Pandoc.Shared
3535import Text.Pandoc.Templates (renderTemplate)
3636import Text.Pandoc.XML ( escapeStringForXML )
3737import Data.List ( intercalate )
@@ -46,9 +46,9 @@ data WriterState = WriterState {
4646
4747-- | Convert Pandoc to Textile.
4848writeTextile :: WriterOptions -> Pandoc -> String
49−writeTextile opts document =
50− evalState (pandocToTextile opts document)
51− (WriterState { stNotes = [], stListLevel = [], stUseTags = False })
49+writeTextile opts document =
50+ evalState (pandocToTextile opts document)
51+ (WriterState { stNotes = [], stListLevel = [], stUseTags = False })
5252
5353-- | Return Textile representation of document.
5454pandocToTextile :: WriterOptions -> Pandoc -> State WriterState String
@@ -90,14 +90,14 @@ escapeCharForTextile x = case x of
9090escapeStringForTextile :: String -> String
9191escapeStringForTextile = concatMap escapeCharForTextile
9292
93−-- | Convert Pandoc block element to Textile.
93+-- | Convert Pandoc block element to Textile.
9494blockToTextile :: WriterOptions -- ^ Options
9595 -> Block -- ^ Block element
96− -> State WriterState String
96+ -> State WriterState String
9797
9898blockToTextile _ Null = return ""
9999
100−blockToTextile opts (Plain inlines) =
100+blockToTextile opts (Plain inlines) =
101101 inlineListToTextile opts inlines
102102
103103blockToTextile opts (Para [Image txt (src,tit)]) = do
@@ -236,7 +236,7 @@ listItemToTextile opts items = do
236236
237237-- | Convert definition list item (label, list of blocks) to Textile.
238238definitionListItemToTextile :: WriterOptions
239− -> ([Inline],[[Block]])
239+ -> ([Inline],[[Block]])
240240 -> State WriterState String
241241definitionListItemToTextile opts (label, items) = do
242242 labelText <- inlineListToTextile opts label
@@ -294,8 +294,8 @@ tableRowToTextile opts alignStrings rownum cols' = do
294294 0 -> "header"
295295 x | x `rem` 2 == 1 -> "odd"
296296 _ -> "even"
297− cols'' <- sequence $ zipWith
298− (\alignment item -> tableItemToTextile opts celltype alignment item)
297+ cols'' <- sequence $ zipWith
298+ (\alignment item -> tableItemToTextile opts celltype alignment item)
299299 alignStrings cols'
300300 return $ "<tr class=\"" ++ rowclass ++ "\">\n" ++ unlines cols'' ++ "</tr>"
301301
@@ -320,7 +320,7 @@ tableItemToTextile opts celltype align' item = do
320320-- | Convert list of Pandoc block elements to Textile.
321321blockListToTextile :: WriterOptions -- ^ Options
322322 -> [Block] -- ^ List of block elements
323− -> State WriterState String
323+ -> State WriterState String
324324blockListToTextile opts blocks =
325325 mapM (blockToTextile opts) blocks >>= return . vcat
326326
@@ -332,11 +332,11 @@ inlineListToTextile opts lst =
332332-- | Convert Pandoc inline element to Textile.
333333inlineToTextile :: WriterOptions -> Inline -> State WriterState String
334334
335−inlineToTextile opts (Emph lst) = do
335+inlineToTextile opts (Emph lst) = do
336336 contents <- inlineListToTextile opts lst
337337 return $ if '_' `elem` contents
338338 then "<em>" ++ contents ++ "</em>"
339− else "_" ++ contents ++ "_"
339+ else "_" ++ contents ++ "_"
340340
341341inlineToTextile opts (Strong lst) = do
342342 contents <- inlineListToTextile opts lst
@@ -377,7 +377,7 @@ inlineToTextile opts (Cite _ lst) = inlineListToTextile opts lst
377377inlineToTextile _ (Code _ str) =
378378 return $ if '@' `elem` str
379379 then "<tt>" ++ escapeStringForXML str ++ "</tt>"
380− else "@" ++ str ++ "@"
380+ else "@" ++ str ++ "@"
381381
382382inlineToTextile _ (Str str) = return $ escapeStringForTextile str
383383