git.iko.soy/typeable/pandoc
on master help sign in
Org reader: support arbitrary raw inlines

Org mode allows arbitrary raw inlines ("export snippets" in Emacs parlance) to be included as `@@format:raw foreign format text@@`. Support for this features is added to the Org reader.

commit29552eff3e1c0a7eab8b114ac58ca83422a84fb0 authorAlbert Krewinkel <albert@zeitkraut.de> dateMon 13 Jun 2016, 23:53 (10 years ago) parentcf2502d
2 files changed+13−1
src/Text/Pandoc/Readers/Org/Inlines.hs+9−1 tests/Tests/Readers/Org.hs+4
src/Text/Pandoc/Readers/Org/Inlines.hs+9−1
@@ -118,6 +118,7 @@ inline =
118118 , subscript
119119 , superscript
120120 , inlineLaTeX
121+ , exportSnippet
121122 , smart
122123 , symbol
123124 ] <* (guard =<< newlinesCountWithinLimits)
@@ -129,7 +130,7 @@ inlines = trimInlinesF . mconcat <$> many1 inline
129130
130131-- treat these as potentially non-text when parsing inline:
131132specialChars :: [Char]
132−specialChars = "\"$'()*+-,./:;<=>[\\]^_{|}~"
133+specialChars = "\"$'()*+-,./:;<=>@[\\]^_{|}~"
133134
134135
135136whitespace :: OrgParser (F Inlines)
@@ -841,6 +842,13 @@ inlineLaTeXCommand = try $ do
841842dropWhileEnd :: (a -> Bool) -> [a] -> [a]
842843dropWhileEnd p = foldr (\x xs -> if p x && null xs then [] else x : xs) []
843844
845+exportSnippet :: OrgParser (F Inlines)
846+exportSnippet = try $ do
847+ string "@@"
848+ format <- many1Till (alphaNum <|> char '-') (char ':')
849+ snippet <- manyTill anyChar (try $ string "@@")
850+ returnF $ B.rawInline format snippet
851+
844852smart :: OrgParser (F Inlines)
845853smart = do
846854 getOption readerSmart >>= guard
tests/Tests/Readers/Org.hs+4
@@ -405,6 +405,10 @@ tests =
405405 "\\notacommand{foo}" =?>
406406 para (rawInline "latex" "\\notacommand{foo}")
407407
408+ , "Export snippet" =:
409+ "@@html:<kbd>M-x org-agenda</kbd>@@" =?>
410+ para (rawInline "html" "<kbd>M-x org-agenda</kbd>")
411+
408412 , "MathML symbol in LaTeX-style" =:
409413 "There is a hackerspace in Lübeck, Germany, called nbsp (unicode symbol: '\\nbsp')." =?>
410414 para ("There is a hackerspace in Lübeck, Germany, called nbsp (unicode symbol: ' ').")