git.iko.soy/typeable/pandoc
on master help sign in
Org reader: fix rules for emphasis recognition
d571becAlbert Krewinkel
src/Text/Pandoc/Readers/Org.hs+5−5
@@ -927,7 +927,7 @@ parseInlines = trimInlinesF . mconcat <$> many1 inline
927
927
928-- treat these as potentially non-text when parsing inline:
928-- treat these as potentially non-text when parsing inline:
929specialChars :: [Char]
929specialChars :: [Char]
930−specialChars = "\"$'()*+-./:<=>[\\]^_{|}~"
930+specialChars = "\"$'()*+-,./:<=>[\\]^_{|}~"
931
931
932
932
933whitespace :: OrgParser (F Inlines)
933whitespace :: OrgParser (F Inlines)
@@ -1205,10 +1205,10 @@ displayMath = return . B.displayMath <$> choice [ rawMathBetween "\\[" "\\]"
1205 ]
1205 ]
1206symbol :: OrgParser (F Inlines)
1206symbol :: OrgParser (F Inlines)
1207symbol = return . B.str . (: "") <$> (oneOf specialChars >>= updatePositions)
1207symbol = return . B.str . (: "") <$> (oneOf specialChars >>= updatePositions)
1208− where updatePositions c
1208+ where updatePositions c = do
1209− | c `elem` emphasisPreChars = c <$ updateLastPreCharPos
1209+ when (c `elem` emphasisPreChars) updateLastPreCharPos
1210− | c `elem` emphasisForbiddenBorderChars = c <$ updateLastForbiddenCharPos
1210+ when (c `elem` emphasisForbiddenBorderChars) updateLastForbiddenCharPos
1211− | otherwise = return c
1211+ return c
1212
1212
1213emphasisBetween :: Char
1213emphasisBetween :: Char
1214 -> OrgParser (F Inlines)
1214 -> OrgParser (F Inlines)
tests/Tests/Readers/Org.hs+8
@@ -126,6 +126,14 @@ tests =
126 , (emph "b") <> "."
126 , (emph "b") <> "."
127 ])
127 ])
128
128
129+ , "Quotes are forbidden border chars" =:
130+ "/'nope/ *nope\"*" =?>
131+ para ("/'nope/" <> space <> "*nope\"*")
132+
133+ , "Commata are forbidden border chars" =:
134+ "/nada,/" =?>
135+ para "/nada,/"
136+
129 , "Markup should work properly after a blank line" =:
137 , "Markup should work properly after a blank line" =:
130 unlines ["foo", "", "/bar/"] =?>
138 unlines ["foo", "", "/bar/"] =?>
131 (para $ text "foo") <> (para $ emph $ text "bar")
139 (para $ text "foo") <> (para $ emph $ text "bar")