I have a listing rendering problem with source code from the BQN programming language. I use lualatex (LuaHBTeX, Version 1.17.0 (TeX Live 2023)). I tested various fonts and the result is the same. The fonts come from https://mlochbaum.github.io/BQN/fonts.html and in particular BQN386 is at https://github.com/dzaima/BQN386.
A spurious newline is inserted before 8 by lstlisting and the space before ↕ has disappeared. The same line using the verbatim environment or with verb is ok. Note that I cannot use the command lstinline because of an error. It looks like those special characters are messing with how listings interprets them.
Here is the relevant part of the generated pdf:
I have checked Latex: Listings with monospace fonts, How to enable contextual substitutions in lstlisting? and Use JetBrains Mono ligatures with fontspec and lstlisting environment.
Any idea to render the source code properly ?
MWE:
\documentclass{article}
\usepackage{fontspec}
\setmonofont{BQN386}
\usepackage{listings}
% \lstset{inputencoding=utf8,extendedchars=true}
\lstset{
basicstyle = \ttfamily,
% columns = flexible,
% keepspaces = true,
% alsoletter={↕},
}
% \lstdefinelanguage{BQN}{ %
% alsoletter=⌽⊸⌈↕, %
% }
% \lstset{language=BQN}
% \makeatletter
% \renewcommand*\verbatim@nolig@list{}
% \makeatother
\begin{document}
OK: {\tt ⌽⊸⌈ ↕8}. OK: \verb+⌽⊸⌈ ↕8+.
% File ended while scanning use of \lst@temp.
% Or \lstinline!⌽⊸⌈ ↕8!.
\par OK:
\begin{verbatim}
⌽⊸⌈ ↕8
\end{verbatim}
\par Not OK:
\begin{lstlisting}
⌽⊸⌈ ↕8
\end{lstlisting}
\end{document}

^^or^^^^? What does that mean ? – Ludovic Kuty Jan 14 '24 at 15:27