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

JavaScript highlighting (fenced code blocks) #365

Closed
mitchallen opened this issue Oct 22, 2023 · 1 comment
Closed

JavaScript highlighting (fenced code blocks) #365

mitchallen opened this issue Oct 22, 2023 · 1 comment

Comments

@mitchallen
Copy link

mitchallen commented Oct 22, 2023

JavaScript keywords are not all being highlighted for blocks like this:

 ~~~{.javascript .numberLines caption="keywords.js"}
# Keywords

var a = "Alpha"
const b = "Beta"
let c = "Gamma"
~~~

In this case, only the const keyword is being highlighted. It seems like only generic keywords that could apply to many languages are being highlighted.

I'm building with the docker container using these parameters:

    --template eisvogel --listings

Do I need to pass in specific definitions for JavaScript?

@Wandmalfarbe
Copy link
Owner

When using the option --listings the listing package is used for syntax highlighting instead of the default highlighting with skylighting.

Listings has no definition for JavaScript, so there is no syntax highlighting. The list of supported programming languages is mentioned in the documentation in section 2.4 Programming languages. Eisvogel defines a default highlighting as Java here, so that is applied, when no language is present.

You can omit the option --listings to use the pandoc default syntax highlighting, which has definitions for JavaScript.

Markdown Input

~~~ {.js}
var a = "Alpha"
const b = "Beta"
let c = "Gamma"
~~~

~~~ {.sql}
CREATE TYPE person_t AS (
	firstName VARCHAR(50) NOT NULL,
	lastName VARCHAR(50) NOT NULL
);
~~~

LaTeX Output with Option --listings

\begin{lstlisting}
var a = "Alpha"
const b = "Beta"
let c = "Gamma"
\end{lstlisting}

\begin{lstlisting}[language=SQL]
CREATE TYPE person_t AS (
    firstName VARCHAR(50) NOT NULL,
    lastName VARCHAR(50) NOT NULL
);
\end{lstlisting}
Screenshot 2025-01-12 at 12 57 07

You can see the first code block is missing a language because pandoc knows that listings doesn't support javascript. The default highlighting of Java is applied.

LaTeX Output without Option --listings (uses skylighting)

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{var}\NormalTok{ a }\OperatorTok{=} \StringTok{"Alpha"}
\KeywordTok{const}\NormalTok{ b }\OperatorTok{=} \StringTok{"Beta"}
\KeywordTok{let}\NormalTok{ c }\OperatorTok{=} \StringTok{"Gamma"}
\end{Highlighting}
\end{Shaded}

\begin{Shaded}
\begin{Highlighting}[]
\KeywordTok{CREATE} \KeywordTok{TYPE}\NormalTok{ person\_t }\KeywordTok{AS}\NormalTok{ (}
\NormalTok{    firstName }\DataTypeTok{VARCHAR}\NormalTok{(}\DecValTok{50}\NormalTok{) }\KeywordTok{NOT} \KeywordTok{NULL}\NormalTok{,}
\NormalTok{    lastName }\DataTypeTok{VARCHAR}\NormalTok{(}\DecValTok{50}\NormalTok{) }\KeywordTok{NOT} \KeywordTok{NULL}
\NormalTok{);}
\end{Highlighting}
\end{Shaded}
Screenshot 2025-01-12 at 12 55 12

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

No branches or pull requests

2 participants