Merge pull request #1700 from tarleb/org-emphasis-fix
Org reader: fix rules for emphasis recognition
This commit is contained in:
commit
31713d572a
2 changed files with 13 additions and 5 deletions
|
@ -952,7 +952,7 @@ parseInlines = trimInlinesF . mconcat <$> many1 inline
|
|||
|
||||
-- treat these as potentially non-text when parsing inline:
|
||||
specialChars :: [Char]
|
||||
specialChars = "\"$'()*+-./:<=>[\\]^_{|}~"
|
||||
specialChars = "\"$'()*+-,./:<=>[\\]^_{|}~"
|
||||
|
||||
|
||||
whitespace :: OrgParser (F Inlines)
|
||||
|
@ -1230,10 +1230,10 @@ displayMath = return . B.displayMath <$> choice [ rawMathBetween "\\[" "\\]"
|
|||
]
|
||||
symbol :: OrgParser (F Inlines)
|
||||
symbol = return . B.str . (: "") <$> (oneOf specialChars >>= updatePositions)
|
||||
where updatePositions c
|
||||
| c `elem` emphasisPreChars = c <$ updateLastPreCharPos
|
||||
| c `elem` emphasisForbiddenBorderChars = c <$ updateLastForbiddenCharPos
|
||||
| otherwise = return c
|
||||
where updatePositions c = do
|
||||
when (c `elem` emphasisPreChars) updateLastPreCharPos
|
||||
when (c `elem` emphasisForbiddenBorderChars) updateLastForbiddenCharPos
|
||||
return c
|
||||
|
||||
emphasisBetween :: Char
|
||||
-> OrgParser (F Inlines)
|
||||
|
|
|
@ -126,6 +126,14 @@ tests =
|
|||
, (emph "b") <> "."
|
||||
])
|
||||
|
||||
, "Quotes are forbidden border chars" =:
|
||||
"/'nope/ *nope\"*" =?>
|
||||
para ("/'nope/" <> space <> "*nope\"*")
|
||||
|
||||
, "Commata are forbidden border chars" =:
|
||||
"/nada,/" =?>
|
||||
para "/nada,/"
|
||||
|
||||
, "Markup should work properly after a blank line" =:
|
||||
unlines ["foo", "", "/bar/"] =?>
|
||||
(para $ text "foo") <> (para $ emph $ text "bar")
|
||||
|
|
Loading…
Reference in a new issue