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
5a51a67Matthew Pickering
src/Text/Pandoc/Parsing.hs+21−22
@@ -997,17 +997,17 @@ registerHeader (ident,classes,kvs) header' = do
997failUnlessSmart :: HasReaderOptions st => Parser s st ()
997failUnlessSmart :: HasReaderOptions st => Parser s st ()
998failUnlessSmart = getOption readerSmart >>= guard
998failUnlessSmart = getOption readerSmart >>= guard
999
999
1000−smartPunctuation :: Parser [Char] ParserState Inline
1000+smartPunctuation :: Parser [Char] ParserState Inlines
1001− -> Parser [Char] ParserState Inline
1001+ -> Parser [Char] ParserState Inlines
1002smartPunctuation inlineParser = do
1002smartPunctuation inlineParser = do
1003 failUnlessSmart
1003 failUnlessSmart
1004 choice [ quoted inlineParser, apostrophe, dash, ellipses ]
1004 choice [ quoted inlineParser, apostrophe, dash, ellipses ]
1005
1005
1006−apostrophe :: Parser [Char] ParserState Inline
1006+apostrophe :: Parser [Char] ParserState Inlines
1007−apostrophe = (char '\'' <|> char '\8217') >> return (Str "\x2019")
1007+apostrophe = (char '\'' <|> char '\8217') >> return (B.str "\x2019")
1008
1008
1009−quoted :: Parser [Char] ParserState Inline
1009+quoted :: Parser [Char] ParserState Inlines
1010− -> Parser [Char] ParserState Inline
1010+ -> Parser [Char] ParserState Inlines
1011quoted inlineParser = doubleQuoted inlineParser <|> singleQuoted inlineParser
1011quoted inlineParser = doubleQuoted inlineParser <|> singleQuoted inlineParser
1012
1012
1013withQuoteContext :: QuoteContext
1013withQuoteContext :: QuoteContext
@@ -1022,20 +1022,19 @@ withQuoteContext context parser = do
1022 setState newState { stateQuoteContext = oldQuoteContext }
1022 setState newState { stateQuoteContext = oldQuoteContext }
1023 return result
1023 return result
1024
1024
1025−singleQuoted :: Parser [Char] ParserState Inline
1025+singleQuoted :: Parser [Char] ParserState Inlines
1026− -> Parser [Char] ParserState Inline
1026+ -> Parser [Char] ParserState Inlines
1027singleQuoted inlineParser = try $ do
1027singleQuoted inlineParser = try $ do
1028 singleQuoteStart
1028 singleQuoteStart
1029 withQuoteContext InSingleQuote $ many1Till inlineParser singleQuoteEnd >>=
1029 withQuoteContext InSingleQuote $ many1Till inlineParser singleQuoteEnd >>=
1030− return . Quoted SingleQuote . normalizeSpaces
1030+ return . B.singleQuoted . mconcat
1031
1031
1032−doubleQuoted :: Parser [Char] ParserState Inline
1032+doubleQuoted :: Parser [Char] ParserState Inlines
1033− -> Parser [Char] ParserState Inline
1033+ -> Parser [Char] ParserState Inlines
1034doubleQuoted inlineParser = try $ do
1034doubleQuoted inlineParser = try $ do
1035 doubleQuoteStart
1035 doubleQuoteStart
1036− withQuoteContext InDoubleQuote $ do
1037− contents <- manyTill inlineParser doubleQuoteEnd
1036+ withQuoteContext InDoubleQuote $ manyTill inlineParser doubleQuoteEnd >>=
1038− return . Quoted DoubleQuote . normalizeSpaces $ contents
1037+ return . B.doubleQuoted . mconcat
1039
1038
1040failIfInQuoteContext :: QuoteContext -> Parser [tok] ParserState ()
1039failIfInQuoteContext :: QuoteContext -> Parser [tok] ParserState ()
1041failIfInQuoteContext context = do
1040failIfInQuoteContext context = do
@@ -1079,17 +1078,17 @@ doubleQuoteEnd = do
1079 charOrRef "\"\8221\148"
1078 charOrRef "\"\8221\148"
1080 return ()
1079 return ()
1081
1080
1082−ellipses :: Parser [Char] st Inline
1081+ellipses :: Parser [Char] st Inlines
1083ellipses = do
1082ellipses = do
1084 try (charOrRef "\8230\133") <|> try (string "..." >> return '…')
1083 try (charOrRef "\8230\133") <|> try (string "..." >> return '…')
1085− return (Str "\8230")
1084+ return (B.str "\8230")
1086
1085
1087−dash :: Parser [Char] ParserState Inline
1086+dash :: Parser [Char] ParserState Inlines
1088dash = do
1087dash = do
1089 oldDashes <- getOption readerOldDashes
1088 oldDashes <- getOption readerOldDashes
1090 if oldDashes
1089 if oldDashes
1091 then emDashOld <|> enDashOld
1090 then emDashOld <|> enDashOld
1092− else Str `fmap` (hyphenDash <|> emDash <|> enDash)
1091+ else B.str `fmap` (hyphenDash <|> emDash <|> enDash)
1093
1092
1094-- Two hyphens = en-dash, three = em-dash
1093-- Two hyphens = en-dash, three = em-dash
1095hyphenDash :: Parser [Char] st String
1094hyphenDash :: Parser [Char] st String
@@ -1107,16 +1106,16 @@ enDash = do
1107 try (charOrRef "\8212\151")
1106 try (charOrRef "\8212\151")
1108 return "\8211"
1107 return "\8211"
1109
1108
1110−enDashOld :: Parser [Char] st Inline
1109+enDashOld :: Parser [Char] st Inlines
1111enDashOld = do
1110enDashOld = do
1112 try (charOrRef "\8211\150") <|>
1111 try (charOrRef "\8211\150") <|>
1113 try (char '-' >> lookAhead (satisfy isDigit) >> return '–')
1112 try (char '-' >> lookAhead (satisfy isDigit) >> return '–')
1114− return (Str "\8211")
1113+ return (B.str "\8211")
1115
1114
1116−emDashOld :: Parser [Char] st Inline
1115+emDashOld :: Parser [Char] st Inlines
1117emDashOld = do
1116emDashOld = do
1118 try (charOrRef "\8212\151") <|> (try $ string "--" >> optional (char '-') >> return '-')
1117 try (charOrRef "\8212\151") <|> (try $ string "--" >> optional (char '-') >> return '-')
1119− return (Str "\8212")
1118+ return (B.str "\8212")
1120
1119
1121-- This is used to prevent exponential blowups for things like:
1120-- This is used to prevent exponential blowups for things like:
1122-- a**a*a**a*a**a*a**a*a**a*a**a*a**
1121-- 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)
1873smart = do
1873smart = do
1874 getOption readerSmart >>= guard
1874 getOption readerSmart >>= guard
1875 doubleQuoted <|> singleQuoted <|>
1875 doubleQuoted <|> singleQuoted <|>
1876− choice (map (return . B.singleton <$>) [apostrophe, dash, ellipses])
1876+ choice (map (return <$>) [apostrophe, dash, ellipses])
1877
1877
1878singleQuoted :: MarkdownParser (F Inlines)
1878singleQuoted :: MarkdownParser (F Inlines)
1879singleQuoted = try $ do
1879singleQuoted = try $ do
src/Text/Pandoc/Readers/RST.hs+1−1
@@ -1140,7 +1140,7 @@ smart :: RSTParser Inlines
1140smart = do
1140smart = do
1141 getOption readerSmart >>= guard
1141 getOption readerSmart >>= guard
1142 doubleQuoted <|> singleQuoted <|>
1142 doubleQuoted <|> singleQuoted <|>
1143− choice (map (B.singleton <$>) [apostrophe, dash, ellipses])
1143+ choice [apostrophe, dash, ellipses]
1144
1144
1145singleQuoted :: RSTParser Inlines
1145singleQuoted :: RSTParser Inlines
1146singleQuoted = try $ do
1146singleQuoted = try $ do
src/Text/Pandoc/Readers/Textile.hs+1−3
@@ -306,9 +306,7 @@ rawLaTeXBlock' = do
306
306
307-- | In textile, paragraphs are separated by blank lines.
307-- | In textile, paragraphs are separated by blank lines.
308para :: Parser [Char] ParserState Blocks
308para :: 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
312
310
313-- Tables
311-- Tables
314
312