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

Use just the first word from #2 to determine language in \markdownRendererInputFencedCodePrototype #225

Closed
Witiko opened this issue Dec 7, 2022 · 0 comments · Fixed by #244
Labels
commonmark Related to making the syntax of markdown follow the CommonMark spec context Related to the ConTeXt interface and implementation defaults Related to default option values and renderer prototypes good first issue latex Related to the LaTeX interface and implementation
Milestone

Comments

@Witiko
Copy link
Owner

Witiko commented Dec 7, 2022

CommonMark specifies that only the first word of a fenced code infostring is typically used to determine language. However, in the definition of \markdownRendererInputFencedCodePrototype for LaTeX and ConTeXt, we use the entire infostring to determine language:

markdown/markdown.dtx

Lines 26290 to 26322 in 6d2b8d6

inputFencedCode = {%
\ifx\relax#2\relax
\VerbatimInput{#1}%
\else
\@ifundefined{minted@code}{%
\@ifundefined{lst@version}{%
\markdownRendererInputFencedCode{#1}{}%
% \end{macrocode}
% \par
% \begin{markdown}
%
% When the \pkg{listings} package is loaded, use it for syntax highlighting.
%
% \end{markdown}
% \begin{macrocode}
}{%
\lstinputlisting[language=#2]{#1}%
}%
% \end{macrocode}
% \par
% \begin{markdown}
%
% When the \pkg{minted} package is loaded, use it for syntax highlighting.
% The \pkg{minted} package is preferred over \pkg{listings}.
%
% \end{markdown}
% \begin{macrocode}
}{%
\catcode`\#=6\relax
\inputminted{#2}{#1}%
\catcode`\#=12\relax
}%
\fi},

markdown/markdown.dtx

Lines 27164 to 27195 in 6d2b8d6

\def\markdownRendererInputFencedCodePrototype#1#2{%
\ifx\relax#2\relax
\typefile{#1}%
\else
% \end{macrocode}
% \par
% \begin{markdown}
%
% The code fence infostring is used as a name from the \Hologo{ConTeXt}
% \mref{definetyping} macro. This allows the user to set up code highlighting
% mapping as follows:
% ````` tex
% % Map the `TEX` syntax highlighter to the `latex` infostring.
% \definetyping [latex]
% \setuptyping [latex] [option=TEX]
%
% \starttext
% \startmarkdown
% ~~~ latex
% \documentclass{article}
% \begin{document}
% Hello world!
% \end{document}
% ~~~
% \stopmarkdown
% \stoptext
% `````````
%
% \end{markdown}
% \begin{macrocode}
\typefile[#2][]{#1}%
\fi}%

@Witiko Witiko added good first issue latex Related to the LaTeX interface and implementation context Related to the ConTeXt interface and implementation commonmark Related to making the syntax of markdown follow the CommonMark spec defaults Related to default option values and renderer prototypes labels Dec 7, 2022
@Witiko Witiko added this to the 2.20.0 milestone Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commonmark Related to making the syntax of markdown follow the CommonMark spec context Related to the ConTeXt interface and implementation defaults Related to default option values and renderer prototypes good first issue latex Related to the LaTeX interface and implementation
Projects
None yet
1 participant