-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lstinline with braces can be used (verb cannot be used with braces) #3535
Conversation
…t be used with braces)
Great! I think we can make this better, though. Some thoughts:
or simplify that using |
I think it is not supported. In this case, you would just use different characters than braces.
I will give it a try. |
I'm happy to help if you get stuck.
+++ schrieveslaach [Mar 28 17 05:02 ]:
… I will give it a try.
|
@jgm, I need some help. My changes won't compile: diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index d632eb2d..142f2c04 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -601,7 +601,8 @@ inlineCommands = M.fromList $
, ("thanks", note <$> grouped block)
, ("footnote", note <$> grouped block)
, ("verb", doverb)
- , ("lstinline", skipopts *> dolstinline)
+ , ("lstinline", do options <- option [] keyvals
+ dolstinline options)
, ("Verb", doverb)
, ("url", (unescapeURL <$> braced) >>= \url ->
pure (link url "" (str url)))
@@ -716,10 +717,14 @@ doverb = do
marker <- anyChar
code <$> manyTill (satisfy (/='\n')) (char marker)
-dolstinline :: PandocMonad m => LP m Inlines
-dolstinline = do
+dolstinline :: PandocMonad m => [(String, String)] -> LP m Inlines
+dolstinline opts = do
marker <- char '{' <|> anyChar
code <$> manyTill (satisfy (/='\n')) (char '}' <|> char marker)
+ return $ codeWith ("",classes,[]) code
+ where classes = case lookup "language" opts >>= fromListingsLanguage of
+ Just l -> [l]
+ Nothing -> []
doLHSverb :: PandocMonad m => LP m Inlines
doLHSverb = codeWith ("",["haskell"],[]) <$> manyTill (satisfy (/='\n')) (char '|') Here's the compiler error:
I'm pretty sure that I'm using your code snippet wrong. |
@jgm, nevermind. I've found the solution. |
src/Text/Pandoc/Readers/LaTeX.hs
Outdated
@@ -601,7 +601,8 @@ inlineCommands = M.fromList $ | |||
, ("thanks", note <$> grouped block) | |||
, ("footnote", note <$> grouped block) | |||
, ("verb", doverb) | |||
, ("lstinline", skipopts *> dolstinline) | |||
, ("lstinline", do options <- option [] keyvals |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make this cleaner, move options <- option [] keyvals
down into dolstinline
and remove the opts
parameter there (and here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to move, but I get an compiler error Variable not in scope: options :: [([Char], String)]
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 2e40e8eb..11d64340 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -601,8 +601,7 @@ inlineCommands = M.fromList $
, ("thanks", note <$> grouped block)
, ("footnote", note <$> grouped block)
, ("verb", doverb)
- , ("lstinline", do options <- option [] keyvals
- dolstinline options)
+ , ("lstinline", dolstinline)
, ("Verb", doverb)
, ("url", (unescapeURL <$> braced) >>= \url ->
pure (link url "" (str url)))
@@ -717,11 +716,12 @@ doverb = do
marker <- anyChar
code <$> manyTill (satisfy (/='\n')) (char marker)
-dolstinline :: PandocMonad m => [(String, String)] -> LP m Inlines
-dolstinline opts = do
+dolstinline :: PandocMonad m => LP m Inlines
+dolstinline = do
+ options <- option [] keyvals
marker <- char '{' <|> anyChar
codeWith ("",classes,[]) <$> manyTill (satisfy (/='\n')) (char '}' <|> char marker)
- where classes = case lookup "language" opts >>= fromListingsLanguage of
+ where classes = case lookup "language" options >>= fromListingsLanguage of
Just l -> [l]
Nothing -> []
Other function using options <- option [] keyvals
have LP m Blocks
in there signature. Does this matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there are some unexpected things about scope with where
.
Try this instead:
options <- option [] keyvals
let classes = maybeToList $ lookup "language" options >>= fromListingsLanguage
marker <- char '{' <|> anyChar
codeWith ...as before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 🥇 Done and PR has been updated.
Great, thanks! |
I want to resolve #3534