-
Notifications
You must be signed in to change notification settings - Fork 22
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
minted and lstlisting environment should be parsed as verbatim
#77
Comments
Hmm. That is very strange. Are you using a current version or are you using the playground (I don't recall when I last updated the playground...)?
|
Oh. I try to prepare a reproduction procedure. |
@siefkenj I can reproduce it in my environment by following procedures: mkdir repro-issue77
cd repro-issue77
cat << 'EOF' > package.json
{
"name": "unified-latex-issue77",
"version": "1.0.0",
"type": "module",
"scripts": {},
"bin": {
"tex2ast": "./tex2ast.js"
},
"dependencies": {
"@unified-latex/unified-latex-util-parse": "1.6.0"
}
}
EOF
cat << 'EOF' > tex2ast.js
#!/usr/bin/env node
import * as fs from "fs";
import { getParser } from "@unified-latex/unified-latex-util-parse";
const content = fs.readFileSync("sample.tex");
const parser = getParser();
const parsedAst = parser.parse(content.toString());
console.log(JSON.stringify(parsedAst, undefined, " "));
EOF
cat << 'EOF' > sample.tex
\begin{minted}{latex}
\section{section title}
this is an embedded source.
\end{minted}
EOF
# I uses v20.11.0
node -v
npm install
npx tex2ast I may have misunderstood how to initialize the parser. If so, please point it out. |
It appears you're right! The code is in the grammar, but it was never tested. I will look into it. |
Should be fixed in v1.6.1 |
@siefkenj I'm still having problems in 1.7.1 using Example document: \begin{minted}{csharp}
using System;
public class Program
{
int a = 3;
bool b = true;
public static void Main()
{
// Write "Hello World" to the console
Console.WriteLine("Hello World");
}
}
\end{minted} ExpectedNo change Actual\begin{minted}
{csharp} using System;
public class Program { int a = 3; bool b = true; public static void Main() { // Write "Hello World" to the console Console.WriteLine("Hello World"); } }
\end{minted} Note: I have explicitly locked |
Environment
Background
minted
andlstlisting
is a popular environment in LaTeX to show source code.It will contains some special chars for LaTeX and it should not be parsed normally.
https://www.overleaf.com/learn/latex/Code_Highlighting_with_minted
https://www.overleaf.com/learn/latex/Code_listing#Using_listings_to_highlight_code
In other words, they are one of a
verbatim
environment.Expected behavior
unified-latex parses them as
verbatim
environment.Actual behavior
unified-latex parses them normaly. It will parsed as normal latex source when the syntax of embedded source code matches LaTeX's one.
I uses following command to show AST:
And
sample.tex
is as follows:AST of sample.tex
#37 seems to introduce support for macros of them, but not for environments.
The text was updated successfully, but these errors were encountered: