Skip to content
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

Support highlighting minted listings #260

Open
YtvwlD opened this issue Oct 25, 2020 · 3 comments
Open

Support highlighting minted listings #260

YtvwlD opened this issue Oct 25, 2020 · 3 comments
Labels

Comments

@YtvwlD
Copy link

YtvwlD commented Oct 25, 2020

Code inside a lstlisting block is highlighted as code. It would be nice if this would work for minted as well.

@ashthespy
Copy link
Owner

ashthespy commented Oct 26, 2020

Could check if adding minted directly here works? (so replace lstlisting with minted in your local latex.cson)

begin: "(^\\s*)?(?=\\\\begin\\{lstlisting\\})"
beginCaptures:
"0":
name: "punctuation.whitespace.embedded.leading.latex"
end: "(?!\\G)(\\s*$\\n?)?"
endCaptures:
"0":
name: "punctuation.whitespace.embedded.trailing.latex"
patterns: [
{
begin: "(((\\\\)begin)(\\{)(lstlisting)(\\})(?:(\\[).*(\\]))?(\\s*%\\s*(?i:Java)\\n?))"
captures:
"1":
name: "meta.function.embedded.latex"
"2":
name: "support.function.be.latex"
"3":
name: "punctuation.definition.function.latex"
"4":
name: "punctuation.definition.arguments.begin.latex"
"5":
name: "variable.parameter.function.latex"
"6":
name: "punctuation.definition.arguments.end.latex"
"7":
name: "punctuation.definition.arguments.optional.begin.latex"
"8":
name: "punctuation.definition.arguments.optional.end.latex"
"9":
name: "comment.line.percentage.latex"
contentName: "meta.function.embedded.latex"
end: "(((\\\\)end)(\\{)(lstlisting)(\\}))"
name: "meta.embedded.block.java"
patterns: [
{
begin: "^(?!\\\\end\\{lstlisting\\})"
end: "(?=\\\\end\\{lstlisting\\})"
name: "source.java"
patterns: [
{
include: "source.java"
}
]
}
]
}
{

PS: You can directly edit your package files by going to settings>packages>Atom-Latex>View Code, and relaunch atom with ctrl+shift+f5

@YtvwlD
Copy link
Author

YtvwlD commented Oct 27, 2020

It works to some extend. But it requires me to write \begin{minted} % Python instead of \begin{minted}{Python}, so minted doesn't get the language anymore. (And it also only works for a few languages, but that's the same as with lstlistings.)

@ashthespy
Copy link
Owner

@YtvwlD if you are up to test and open up a PR, you could try porting (well copy pasting) yudai-nkt/language-tex#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants