git.iko.soy/typeable/pandoc
on master help sign in
Changed the smart punctuation parser to return Inlines rather than an Inline element and updated files accordingly
commit5a51a67abda59c177f3a6d0f6cba59d41e866287 authorMatthew Pickering <matthewtpickering@gmail.com> dateThu 27 Mar 2014, 19:56 (13 years ago) parent9b5d474
4 files changed+24−27
src/Text/Pandoc/Parsing.hs+21−22 src/Text/Pandoc/Readers/Markdown.hs+1−1 src/Text/Pandoc/Readers/RST.hs+1−1 src/Text/Pandoc/Readers/Textile.hs+1−3
src/Text/Pandoc/Parsing.hs+21−22
@@ -997,17 +997,17 @@ registerHeader (ident,classes,kvs) header' = do
997997failUnlessSmart :: HasReaderOptions st => Parser s st ()
998998failUnlessSmart = getOption readerSmart >>= guard
999999
1000−smartPunctuation :: Parser [Char] ParserState Inline
1001− -> Parser [Char] ParserState Inline
1000+smartPunctuation :: Parser [Char] ParserState Inlines
1001+ -> Parser [Char] ParserState Inlines
10021002smartPunctuation inlineParser = do
10031003 failUnlessSmart
10041004 choice [ quoted inlineParser, apostrophe, dash, ellipses ]
10051005
1006−apostrophe :: Parser [Char] ParserState Inline
1007−apostrophe = (char '\'' <|> char '\8217') >> return (Str "\x2019")
1006+apostrophe :: Parser [Char] ParserState Inlines
1007+apostrophe = (char '\'' <|> char '\8217') >> return (B.str "\x2019")
10081008
1009−quoted :: Parser [Char] ParserState Inline
1010− -> Parser [Char] ParserState Inline
1009+quoted :: Parser [Char] ParserState Inlines
1010+ -> Parser [Char] ParserState Inlines
10111011quoted inlineParser = doubleQuoted inlineParser <|> singleQuoted inlineParser
10121012
10131013withQuoteContext :: QuoteContext
@@ -1022,20 +1022,19 @@ withQuoteContext context parser = do
10221022 setState newState { stateQuoteContext = oldQuoteContext }
10231023 return result
10241024
1025−singleQuoted :: Parser [Char] ParserState Inline
1026− -> Parser [Char] ParserState Inline
1025+singleQuoted :: Parser [Char] ParserState Inlines
1026+ -> Parser [Char] ParserState Inlines
10271027singleQuoted inlineParser = try $ do
10281028 singleQuoteStart
10291029 withQuoteContext InSingleQuote $ many1Till inlineParser singleQuoteEnd >>=
1030− return . Quoted SingleQuote . normalizeSpaces
1030+ return . B.singleQuoted . mconcat
10311031
1032−doubleQuoted :: Parser [Char] ParserState Inline
1033− -> Parser [Char] ParserState Inline
1032+doubleQuoted :: Parser [Char] ParserState Inlines
1033+ -> Parser [Char] ParserState Inlines
10341034doubleQuoted inlineParser = try $ do
10351035 doubleQuoteStart
1036− withQuoteContext InDoubleQuote $ do
1037− contents <- manyTill inlineParser doubleQuoteEnd
1038− return . Quoted DoubleQuote . normalizeSpaces $ contents
1036+ withQuoteContext InDoubleQuote $ manyTill inlineParser doubleQuoteEnd >>=
1037+ return . B.doubleQuoted . mconcat
10391038
10401039failIfInQuoteContext :: QuoteContext -> Parser [tok] ParserState ()
10411040failIfInQuoteContext context = do
@@ -1079,17 +1078,17 @@ doubleQuoteEnd = do
10791078 charOrRef "\"\8221\148"
10801079 return ()
10811080
1082−ellipses :: Parser [Char] st Inline
1081+ellipses :: Parser [Char] st Inlines
10831082ellipses = do
10841083 try (charOrRef "\8230\133") <|> try (string "..." >> return '…')
1085− return (Str "\8230")
1084+ return (B.str "\8230")
10861085
1087−dash :: Parser [Char] ParserState Inline
1086+dash :: Parser [Char] ParserState Inlines
10881087dash = do
10891088 oldDashes <- getOption readerOldDashes
10901089 if oldDashes
10911090 then emDashOld <|> enDashOld
1092− else Str `fmap` (hyphenDash <|> emDash <|> enDash)
1091+ else B.str `fmap` (hyphenDash <|> emDash <|> enDash)
10931092
10941093-- Two hyphens = en-dash, three = em-dash
10951094hyphenDash :: Parser [Char] st String
@@ -1107,16 +1106,16 @@ enDash = do
11071106 try (charOrRef "\8212\151")
11081107 return "\8211"
11091108
1110−enDashOld :: Parser [Char] st Inline
1109+enDashOld :: Parser [Char] st Inlines
11111110enDashOld = do
11121111 try (charOrRef "\8211\150") <|>
11131112 try (char '-' >> lookAhead (satisfy isDigit) >> return '–')
1114− return (Str "\8211")
1113+ return (B.str "\8211")
11151114
1116−emDashOld :: Parser [Char] st Inline
1115+emDashOld :: Parser [Char] st Inlines
11171116emDashOld = do
11181117 try (charOrRef "\8212\151") <|> (try $ string "--" >> optional (char '-') >> return '-')
1119− return (Str "\8212")
1118+ return (B.str "\8212")
11201119
11211120-- This is used to prevent exponential blowups for things like:
11221121-- a**a*a**a*a**a*a**a*a**a*a**a*a**
src/Text/Pandoc/Readers/Markdown.hs+1−1
@@ -1873,7 +1873,7 @@ smart :: MarkdownParser (F Inlines)
18731873smart = do
18741874 getOption readerSmart >>= guard
18751875 doubleQuoted <|> singleQuoted <|>
1876− choice (map (return . B.singleton <$>) [apostrophe, dash, ellipses])
1876+ choice (map (return <$>) [apostrophe, dash, ellipses])
18771877
18781878singleQuoted :: MarkdownParser (F Inlines)
18791879singleQuoted = try $ do
src/Text/Pandoc/Readers/RST.hs+1−1
@@ -1140,7 +1140,7 @@ smart :: RSTParser Inlines
11401140smart = do
11411141 getOption readerSmart >>= guard
11421142 doubleQuoted <|> singleQuoted <|>
1143− choice (map (B.singleton <$>) [apostrophe, dash, ellipses])
1143+ choice [apostrophe, dash, ellipses]
11441144
11451145singleQuoted :: RSTParser Inlines
11461146singleQuoted = try $ do
src/Text/Pandoc/Readers/Textile.hs+1−3
@@ -306,9 +306,7 @@ rawLaTeXBlock' = do
306306
307307-- | In textile, paragraphs are separated by blank lines.
308308para :: Parser [Char] ParserState Blocks
309−para = do
310− a <- manyTill inline blockBreak
311− return $ (B.para . trimInlines . mconcat) a
309+para = B.para . trimInlines . mconcat <$> manyTill inline blockBreak
312310
313311-- Tables
314312