@@ -869,6 +869,7 @@ inline :: OrgParser (F Inlines)
870 choice [ whitespace
870 choice [ whitespace
871 , linebreak
871 , linebreak
872 , footnote
873 , footnote
873 , linkOrImage
874 , linkOrImage
@@ -933,6 +934,51 @@ endline = try $ do
933 updateLastPreCharPos
934 updateLastPreCharPos
934 return . return $ B.space
935 return . return $ B.space
937+cite :: OrgParser (F Inlines)
939+ guardEnabled Ext_citations
940+ (cs, raw) <- withRaw normalCite
941+ return $ (flip B.cite (B.text raw)) <$> cs
943+normalCite :: OrgParser (F [Citation])
944+normalCite = try $ char '['
950+citeList :: OrgParser (F [Citation])
951+citeList = sequence <$> sepBy1 citation (try $ char ';' *> skipSpaces)
953+citation :: OrgParser (F Citation)
956+ (suppress_author, key) <- citeKey
961+ return $ Citation{ citationId = key
962+ , citationPrefix = B.toList x
963+ , citationSuffix = B.toList y
964+ , citationMode = if suppress_author
967+ , citationNoteNum = 0
971+ prefix = trimInlinesF . mconcat <$>
972+ manyTill inline (char ']' <|> (']' <$ lookAhead citeKey))
974+ hasSpace <- option False (notFollowedBy nonspaceChar >> return True)
976+ rest <- trimInlinesF . mconcat <$>
977+ many (notFollowedBy (oneOf ";]") *> inline)
978+ return $ if hasSpace
979+ then (B.space <>) <$> rest
936footnote :: OrgParser (F Inlines)
982footnote :: OrgParser (F Inlines)
937footnote = try $ inlineNote <|> referencedNote
983footnote = try $ inlineNote <|> referencedNote
@@ -1007,7 +1053,7 @@ selfTarget :: OrgParser String
1007selfTarget = try $ char '[' *> linkTarget <* char ']'
1053selfTarget = try $ char '[' *> linkTarget <* char ']'
1009linkTarget :: OrgParser String
1055linkTarget :: OrgParser String
1010−linkTarget = enclosed (char '[') (char ']') (noneOf "\n\r[]")
1056+linkTarget = enclosedByPair '[' ']' (noneOf "\n\r[]")
1012applyCustomLinkFormat :: String -> OrgParser (F String)
1058applyCustomLinkFormat :: String -> OrgParser (F String)
1013applyCustomLinkFormat link = do
1059applyCustomLinkFormat link = do
@@ -1083,7 +1129,12 @@ inlineCodeBlock = try $ do
1083 let attrClasses = [translateLang lang, rundocBlockClass]
1129 let attrClasses = [translateLang lang, rundocBlockClass]
1084 let attrKeyVal = map toRundocAttrib (("language", lang) : opts)
1130 let attrKeyVal = map toRundocAttrib (("language", lang) : opts)
1085 returnF $ B.codeWith ("", attrClasses, attrKeyVal) inlineCode
1131 returnF $ B.codeWith ("", attrClasses, attrKeyVal) inlineCode
1133+enclosedByPair :: Char -- ^ opening char
1134+ -> Char -- ^ closing char
1135+ -> OrgParser a -- ^ parser
1086− where enclosedByPair s e p = char s *> many1Till p (char e)
1137+enclosedByPair s e p = char s *> many1Till p (char e)
1088emph :: OrgParser (F Inlines)
1139emph :: OrgParser (F Inlines)
1089emph = fmap B.emph <$> emphasisBetween '/'
1140emph = fmap B.emph <$> emphasisBetween '/'