git.iko.soy/typeable/pandoc
on master help sign in
lstinline with braces can be used (verb cannot be used with braces) (#3535)

* Fix lstinline handling: lstinline with braces can be used (verb cannot be used with braces) * Use codeWith and determine the language from lstinline * Improve code * Add another test: convert lstinline without language option

commit5fe734d452976ff66ede965984954c6d3755d5c2 authorschrieveslaach <schrieveslaach@online.de> dateWed 29 Mar 2017, 14:49 (10 years ago) parent5cb18e5
2 files changed+31−1
src/Text/Pandoc/Readers/LaTeX.hs+8−1 test/command/3534.md+23
src/Text/Pandoc/Readers/LaTeX.hs+8−1
@@ -601,7 +601,7 @@ inlineCommands = M.fromList $
601601 , ("thanks", note <$> grouped block)
602602 , ("footnote", note <$> grouped block)
603603 , ("verb", doverb)
604− , ("lstinline", skipopts *> doverb)
604+ , ("lstinline", dolstinline)
605605 , ("Verb", doverb)
606606 , ("url", (unescapeURL <$> braced) >>= \url ->
607607 pure (link url "" (str url)))
@@ -716,6 +716,13 @@ doverb = do
716716 marker <- anyChar
717717 code <$> manyTill (satisfy (/='\n')) (char marker)
718718
719+dolstinline :: PandocMonad m => LP m Inlines
720+dolstinline = do
721+ options <- option [] keyvals
722+ let classes = maybeToList $ lookup "language" options >>= fromListingsLanguage
723+ marker <- char '{' <|> anyChar
724+ codeWith ("",classes,[]) <$> manyTill (satisfy (/='\n')) (char '}' <|> char marker)
725+
719726doLHSverb :: PandocMonad m => LP m Inlines
720727doLHSverb = codeWith ("",["haskell"],[]) <$> manyTill (satisfy (/='\n')) (char '|')
721728
test/command/3534.mdnew file+23
@@ -0,0 +1,23 @@
1+```
2+% pandoc -f latex -t html
3+I want to explain the interface of \lstinline[language=Java]{public class MyClass}.
4+^D
5+<p>I want to explain the interface of <code class="sourceCode java"><span class="kw">public</span> <span class="kw">class</span> MyClass</code>.</p>
6+
7+```
8+
9+```
10+% pandoc -f latex -t html
11+I want to explain the interface of \lstinline{public class MyClass}.
12+^D
13+<p>I want to explain the interface of <code>public class MyClass</code>.</p>
14+
15+```
16+
17+```
18+% pandoc -f latex -t native
19+I want to explain the interface of \lstinline[language=Java]{public class MyClass}.
20+^D
21+[Para [Str "I",Space,Str "want",Space,Str "to",Space,Str "explain",Space,Str "the",Space,Str "interface",Space,Str "of",Space,Code ("",["java"],[]) "public class MyClass",Str "."]]
22+```
23+