diff options
m--------- | data/templates | 13 | ||||
-rw-r--r-- | src/Text/Pandoc/Parsing.hs | 7 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/HTML.hs | 2 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 3 | ||||
-rw-r--r-- | tests/Tests/Readers/Markdown.hs | 3 | ||||
-rw-r--r-- | tests/lhs-test.latex | 6 | ||||
-rw-r--r-- | tests/lhs-test.latex+lhs | 6 | ||||
-rw-r--r-- | tests/writer.latex | 6 |
8 files changed, 37 insertions, 9 deletions
diff --git a/data/templates b/data/templates -Subproject 12ba81ec9697e238c861ca6b7f8dc08f4e876e7 +Subproject e8aec53fad6b4d587a44af5ca76c4b809569f15 diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index c18aa331f..d30c74230 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -161,7 +161,8 @@ module Text.Pandoc.Parsing ( anyLine, setSourceColumn, setSourceLine, newPos, - addWarning + addWarning, + (<+?>) ) where @@ -1245,3 +1246,7 @@ addWarning mbpos msg = generalize :: (Monad m) => Parser s st a -> ParserT s st m a generalize m = mkPT (\ s -> (return $ (return . runIdentity) <$> runIdentity (runParsecT m s))) + +infixr 5 <+?> +(<+?>) :: (Monoid a, Monad m) => ParserT s st m a -> ParserT s st m a -> ParserT s st m a +a <+?> b = a >>= flip fmap (try b <|> return mempty) . (<>) diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index 59f71589e..52358e51e 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -887,7 +887,7 @@ htmlTag :: Monad m => (Tag String -> Bool) -> ParserT [Char] st m (Tag String, String) htmlTag f = try $ do - lookAhead $ char '<' >> (oneOf "/!?" <|> letter) + lookAhead $ char '<' >> ((oneOf "/!?" >> nonspaceChar) <|> letter) (next : _) <- getInput >>= return . canonicalizeTags . parseTags guard $ f next -- advance the parser diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index ccda83576..5e0cef4f8 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1487,7 +1487,8 @@ code = try $ do math :: MarkdownParser Inlines math = (B.displayMath <$> (mathDisplay >>= applyMacros')) - <|> (B.math <$> (mathInline >>= applyMacros')) + <|> ((B.math <$> (mathInline >>= applyMacros')) <+?> + ((getOption readerSmart >>= guard) *> apostrophe <* notFollowedBy space)) -- Parses material enclosed in *s, **s, _s, or __s. -- Designed to avoid backtracking. diff --git a/tests/Tests/Readers/Markdown.hs b/tests/Tests/Readers/Markdown.hs index 03884a8e5..6c8e9f306 100644 --- a/tests/Tests/Readers/Markdown.hs +++ b/tests/Tests/Readers/Markdown.hs @@ -208,6 +208,9 @@ tests = [ testGroup "inline code" , test markdownSmart "apostrophe in French" ("À l'arrivée de la guerre, le thème de l'«impossibilité du socialisme»" =?> para "À l’arrivée de la guerre, le thème de l’«impossibilité du socialisme»") + , test markdownSmart "apostrophe after math" $ -- issue #1909 + "The value of the $x$'s and the systems' condition." =?> + para (text "The value of the " <> math "x" <> text "\8217s and the systems\8217 condition.") ] , testGroup "footnotes" [ "indent followed by newline and flush-left text" =: diff --git a/tests/lhs-test.latex b/tests/lhs-test.latex index 6f2fdfb77..cf993af9b 100644 --- a/tests/lhs-test.latex +++ b/tests/lhs-test.latex @@ -68,6 +68,12 @@ \date{} +% Redefines (sub)paragraphs to behave more like sections +\let\oldparagraph\paragraph +\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}} +\let\oldsubparagraph\subparagraph +\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} + \begin{document} \section{lhs test}\label{lhs-test} diff --git a/tests/lhs-test.latex+lhs b/tests/lhs-test.latex+lhs index 77f0e08ff..746744cc8 100644 --- a/tests/lhs-test.latex+lhs +++ b/tests/lhs-test.latex+lhs @@ -49,6 +49,12 @@ \date{} +% Redefines (sub)paragraphs to behave more like sections +\let\oldparagraph\paragraph +\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}} +\let\oldsubparagraph\subparagraph +\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} + \begin{document} \section{lhs test}\label{lhs-test} diff --git a/tests/writer.latex b/tests/writer.latex index 94e8f779e..fab5c9325 100644 --- a/tests/writer.latex +++ b/tests/writer.latex @@ -64,6 +64,12 @@ \author{John MacFarlane \and Anonymous} \date{July 17, 2006} +% Redefines (sub)paragraphs to behave more like sections +\let\oldparagraph\paragraph +\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}} +\let\oldsubparagraph\subparagraph +\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} + \begin{document} \maketitle |