git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: better handling of intraword _.
c66921fJohn MacFarlane
src/Text/Pandoc/Readers/Markdown.hs+5−3
@@ -47,7 +47,7 @@ import Text.Pandoc.Readers.HTML ( rawHtmlBlock, anyHtmlBlockTag,
47 htmlBlockElement, htmlComment, unsanitaryURI )
47 htmlBlockElement, htmlComment, unsanitaryURI )
48import Text.Pandoc.CharacterReferences ( decodeCharacterReferences )
48import Text.Pandoc.CharacterReferences ( decodeCharacterReferences )
49import Text.ParserCombinators.Parsec
49import Text.ParserCombinators.Parsec
50−import Control.Monad (when, liftM, unless, guard)
50+import Control.Monad (when, liftM, guard)
51import Text.TeXMath.Macros (applyMacros, Macro, pMacroDefinition)
51import Text.TeXMath.Macros (applyMacros, Macro, pMacroDefinition)
52
52
53-- | Read markdown from an input string and return a Pandoc document.
53-- | Read markdown from an input string and return a Pandoc document.
@@ -121,7 +121,7 @@ inlinesInBalancedBrackets :: GenParser Char ParserState Inline
121inlinesInBalancedBrackets parser = try $ do
121inlinesInBalancedBrackets parser = try $ do
122 char '['
122 char '['
123 result <- manyTill ( (do lookAhead $ try $ do (Str res) <- parser
123 result <- manyTill ( (do lookAhead $ try $ do (Str res) <- parser
124− unless (res == "[") pzero
124+ guard (res == "[")
125 bal <- inlinesInBalancedBrackets parser
125 bal <- inlinesInBalancedBrackets parser
126 return $ [Str "["] ++ bal ++ [Str "]"])
126 return $ [Str "["] ++ bal ++ [Str "]"])
127 <|> (count 1 parser))
127 <|> (count 1 parser))
@@ -1138,7 +1138,9 @@ strChar = noneOf (specialChars ++ " \t\n")
1138
1138
1139str :: GenParser Char ParserState Inline
1139str :: GenParser Char ParserState Inline
1140str = do
1140str = do
1141+ a <- strChar
1142+ as <- many (strChar <|> (try $ char '_' >>~ lookAhead strChar))
1141− result <- many1 strChar
1143+ let result = a:as
1142 state <- getState
1144 state <- getState
1143 let spacesToNbr = map (\c -> if c == ' ' then '\160' else c)
1145 let spacesToNbr = map (\c -> if c == ' ' then '\160' else c)
1144 if stateSmart state
1146 if stateSmart state