git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #1700 from tarleb/org-emphasis-fix

Org reader: fix rules for emphasis recognition

commit31713d572a606a487d36c4a4d673b9797cf4a0db authorJohn MacFarlane <jgm@berkeley.edu> dateSat 18 Oct 2014, 13:19 (12 years ago) parenta1b5997d571bec
2 files changed+13−5
src/Text/Pandoc/Readers/Org.hs+5−5 tests/Tests/Readers/Org.hs+8
src/Text/Pandoc/Readers/Org.hs+5−5
@@ -952,7 +952,7 @@ parseInlines = trimInlinesF . mconcat <$> many1 inline
952952
953953-- treat these as potentially non-text when parsing inline:
954954specialChars :: [Char]
955−specialChars = "\"$'()*+-./:<=>[\\]^_{|}~"
955+specialChars = "\"$'()*+-,./:<=>[\\]^_{|}~"
956956
957957
958958whitespace :: OrgParser (F Inlines)
@@ -1230,10 +1230,10 @@ displayMath = return . B.displayMath <$> choice [ rawMathBetween "\\[" "\\]"
12301230 ]
12311231symbol :: OrgParser (F Inlines)
12321232symbol = return . B.str . (: "") <$> (oneOf specialChars >>= updatePositions)
1233− where updatePositions c
1234− | c `elem` emphasisPreChars = c <$ updateLastPreCharPos
1235− | c `elem` emphasisForbiddenBorderChars = c <$ updateLastForbiddenCharPos
1236− | otherwise = return c
1233+ where updatePositions c = do
1234+ when (c `elem` emphasisPreChars) updateLastPreCharPos
1235+ when (c `elem` emphasisForbiddenBorderChars) updateLastForbiddenCharPos
1236+ return c
12371237
12381238emphasisBetween :: Char
12391239 -> OrgParser (F Inlines)
tests/Tests/Readers/Org.hs+8
@@ -126,6 +126,14 @@ tests =
126126 , (emph "b") <> "."
127127 ])
128128
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+
129137 , "Markup should work properly after a blank line" =:
130138 unlines ["foo", "", "/bar/"] =?>
131139 (para $ text "foo") <> (para $ emph $ text "bar")