git.iko.soy/typeable/pandoc
on master help sign in
Org reader: support arbitrary raw inlines
29552efAlbert Krewinkel
src/Text/Pandoc/Readers/Org/Inlines.hs+9−1
@@ -118,6 +118,7 @@ inline =
118 , subscript
118 , subscript
119 , superscript
119 , superscript
120 , inlineLaTeX
120 , inlineLaTeX
121+ , exportSnippet
121 , smart
122 , smart
122 , symbol
123 , symbol
123 ] <* (guard =<< newlinesCountWithinLimits)
124 ] <* (guard =<< newlinesCountWithinLimits)
@@ -129,7 +130,7 @@ inlines = trimInlinesF . mconcat <$> many1 inline
129
130
130-- treat these as potentially non-text when parsing inline:
131-- treat these as potentially non-text when parsing inline:
131specialChars :: [Char]
132specialChars :: [Char]
132−specialChars = "\"$'()*+-,./:;<=>[\\]^_{|}~"
133+specialChars = "\"$'()*+-,./:;<=>@[\\]^_{|}~"
133
134
134
135
135whitespace :: OrgParser (F Inlines)
136whitespace :: OrgParser (F Inlines)
@@ -841,6 +842,13 @@ inlineLaTeXCommand = try $ do
841dropWhileEnd :: (a -> Bool) -> [a] -> [a]
842dropWhileEnd :: (a -> Bool) -> [a] -> [a]
842dropWhileEnd p = foldr (\x xs -> if p x && null xs then [] else x : xs) []
843dropWhileEnd p = foldr (\x xs -> if p x && null xs then [] else x : xs) []
843
844
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+
844smart :: OrgParser (F Inlines)
852smart :: OrgParser (F Inlines)
845smart = do
853smart = do
846 getOption readerSmart >>= guard
854 getOption readerSmart >>= guard
tests/Tests/Readers/Org.hs+4
@@ -405,6 +405,10 @@ tests =
405 "\\notacommand{foo}" =?>
405 "\\notacommand{foo}" =?>
406 para (rawInline "latex" "\\notacommand{foo}")
406 para (rawInline "latex" "\\notacommand{foo}")
407
407
408+ , "Export snippet" =:
409+ "@@html:<kbd>M-x org-agenda</kbd>@@" =?>
410+ para (rawInline "html" "<kbd>M-x org-agenda</kbd>")
411+
408 , "MathML symbol in LaTeX-style" =:
412 , "MathML symbol in LaTeX-style" =:
409 "There is a hackerspace in Lübeck, Germany, called nbsp (unicode symbol: '\\nbsp')." =?>
413 "There is a hackerspace in Lübeck, Germany, called nbsp (unicode symbol: '\\nbsp')." =?>
410 para ("There is a hackerspace in Lübeck, Germany, called nbsp (unicode symbol: ' ').")
414 para ("There is a hackerspace in Lübeck, Germany, called nbsp (unicode symbol: ' ').")