Closed lostenderman closed 1 year ago
The corresponding unit test is testfiles/CommonMark_0.30/fenced_code_blocks/025.test
:
% ---RESULT--- "example": 143,
%
% <pre><code class="language-ruby">def foo(x)
% return 3
% end
% </code></pre>
%
% ---\RESULT---
<<<
~~~~ ruby startline=3 $%@#$
def foo(x)
return 3
end
~~~~~~~
>>>
documentBegin
BEGIN fencedCode
- src: ./_markdown_test/bec320a1e3b741ba35aaee15586aa06d.verbatim
- infostring: ruby startline=3 $%@#$
END fencedCode
documentEnd
Here is the result of running git checkout commonmark; cd tests; ./test.sh "testfiles/CommonMark_0.30/fenced_code_blocks/025.test"
:
Testfile testfiles/CommonMark_0.30/fenced_code_blocks/025.test
Format templates/plain/
Template templates/plain/input.tex.m4
Command pdftex --shell-escape --interaction=nonstopmode test.tex
*** test-expected.log 2022-12-22 11:55:38.255546587 +0100
--- test-actual.log 2022-12-22 11:55:44.515493283 +0100
***************
*** 1,6 ****
documentBegin
BEGIN fencedCode
- src: ./_markdown_test/bec320a1e3b741ba35aaee15586aa06d.verbatim
! - infostring: ruby startline=3 $%@#$
END fencedCode
documentEnd
--- 1,6 ----
documentBegin
BEGIN fencedCode
- src: ./_markdown_test/bec320a1e3b741ba35aaee15586aa06d.verbatim
! - infostring: ruby startline=3 (dollarSign)(percentSign)@(hash)(dollarSign)
END fencedCode
documentEnd
This issue seems related to the writer->fencedCode()
method, which produces the \markdownRendererInputFencedCode
TeX macro. Specifically, we use the writer->string()
(or self.escape_typographic_material()
under the renaming proposed in #101) method to encode the infostring.
An obvious solution is to replace writer->string()
with writer->escape_uri()
(or define writer->infostring
equal to writer->escape_programmatic_text()
under the renaming proposed in #101). However, this makes it impossible to (ab)use infostrings to typeset text such as image labels, see for example Section 1.1.2 and Figure 1 in the TUGboat 42:2 article Markdown 2.10.0: LaTeX themes & snippets, two flavors of comments, and LuaMetaTeX.
Therefore, a better solution would be to change the arity of the \markdownRendererFencedCode
macro to 3 and have the writer->fencedCode()
use writer->string()
for the second parameter and writer->infostring()
(after the renaming proposed in #101) for the third parameter. This way, both use cases would be satisfied. In the unit test output (1, 2), we would use the third parameter rather than the second parameter to satisfy the unit test.
See https://spec.commonmark.org/0.30/#example-143