git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #2092 from lierdakil/issue1909
fb143beJohn MacFarlane
src/Text/Pandoc/Parsing.hs+6−1
@@ -161,7 +161,8 @@ module Text.Pandoc.Parsing ( anyLine,
161 setSourceColumn,
161 setSourceColumn,
162 setSourceLine,
162 setSourceLine,
163 newPos,
163 newPos,
164− addWarning
164+ addWarning,
165+ (<+?>)
165 )
166 )
166where
167where
167
168
@@ -1245,3 +1246,7 @@ addWarning mbpos msg =
1245
1246
1246generalize :: (Monad m) => Parser s st a -> ParserT s st m a
1247generalize :: (Monad m) => Parser s st a -> ParserT s st m a
1247generalize m = mkPT (\ s -> (return $ (return . runIdentity) <$> runIdentity (runParsecT m s)))
1248generalize m = mkPT (\ s -> (return $ (return . runIdentity) <$> runIdentity (runParsecT m s)))
1249+
1250+infixr 5 <+?>
1251+(<+?>) :: (Monoid a, Monad m) => ParserT s st m a -> ParserT s st m a -> ParserT s st m a
1252+a <+?> b = a >>= flip fmap (try b <|> return mempty) . (<>)
src/Text/Pandoc/Readers/Markdown.hs+2−1
@@ -1487,7 +1487,8 @@ code = try $ do
1487
1487
1488math :: MarkdownParser Inlines
1488math :: MarkdownParser Inlines
1489math = (B.displayMath <$> (mathDisplay >>= applyMacros'))
1489math = (B.displayMath <$> (mathDisplay >>= applyMacros'))
1490− <|> (B.math <$> (mathInline >>= applyMacros'))
1490+ <|> ((B.math <$> (mathInline >>= applyMacros')) <+?>
1491+ ((getOption readerSmart >>= guard) *> apostrophe <* notFollowedBy space))
1491
1492
1492-- Parses material enclosed in *s, **s, _s, or __s.
1493-- Parses material enclosed in *s, **s, _s, or __s.
1493-- Designed to avoid backtracking.
1494-- Designed to avoid backtracking.
tests/Tests/Readers/Markdown.hs+3
@@ -208,6 +208,9 @@ tests = [ testGroup "inline code"
208 , test markdownSmart "apostrophe in French"
208 , test markdownSmart "apostrophe in French"
209 ("À l'arrivée de la guerre, le thème de l'«impossibilité du socialisme»"
209 ("À l'arrivée de la guerre, le thème de l'«impossibilité du socialisme»"
210 =?> para "À l’arrivée de la guerre, le thème de l’«impossibilité du socialisme»")
210 =?> para "À l’arrivée de la guerre, le thème de l’«impossibilité du socialisme»")
211+ , test markdownSmart "apostrophe after math" $ -- issue #1909
212+ "The value of the $x$'s and the systems' condition." =?>
213+ para (text "The value of the " <> math "x" <> text "\8217s and the systems\8217 condition.")
211 ]
214 ]
212 , testGroup "footnotes"
215 , testGroup "footnotes"
213 [ "indent followed by newline and flush-left text" =:
216 [ "indent followed by newline and flush-left text" =: