@@ -459,6 +459,7 @@ inline = choice inlineParsers <?> "inline"
459459 , strikeout
460460 , underline
461461 , code
462+ , math
462463 , verbatim
463464 , subscript
464465 , superscript
@@ -530,10 +531,13 @@ underline = B.strong <$> inlinesEnclosedBy '_'
530531code :: OrgParser Inlines
531532code = B.code <$> rawEnclosedBy '='
532533
533−verbatim :: OrgParser Inlines
534+math :: OrgParser Inlines
535+math = B.math <$> rawEnclosedBy '$'
536+
537+verbatim :: OrgParser Inlines
534538verbatim = B.rawInline "" <$> rawEnclosedBy '~'
535539
536−subscript :: OrgParser Inlines
540+subscript :: OrgParser Inlines
537541subscript = B.subscript <$> (try $ char '_' *> maybeGroupedByBraces)
538542
539543superscript :: OrgParser Inlines
@@ -580,18 +584,24 @@ rawEnclosedBy c = enclosedRaw (atStart $ char c) (atEnd $ char c)
580584-- succeeds only if we're not right after a str (ie. in middle of word)
581585atStart :: OrgParser a -> OrgParser a
582586atStart p = do
583− pos <- getPosition
584− st <- getState
585− guard $ orgLastStrPos st /= Just pos
587+ guard =<< not <$> isRightAfterString
586588 p
587589
588590-- | succeeds only if we're at the end of a word
589591atEnd :: OrgParser a -> OrgParser a
590592atEnd p = try $ do
591− p <* lookingAtEndOfWord
593+ p <* lookingAtEndOfWord
592594 where lookingAtEndOfWord =
593595 eof <|> const (return ()) =<< lookAhead . oneOf =<< postWordChars
594596
597+isRightAfterString :: OrgParser Bool
598+isRightAfterString = do
599+ pos <- getPosition
600+ st <- getState
601+ -- the position `Nothing` isn't after a String, either, hence the double
602+ -- negation
603+ return $ not $ orgLastStrPos st /= Just pos
604+
595605postWordChars :: OrgParser [Char]
596606postWordChars = do
597607 st <- getState