zestedesavoir / zmarkdown

Live demo: https://zestedesavoir.github.io/zmarkdown/
MIT License
224 stars 52 forks source link

Code blocks are shuffled in the PDF export of a tutorial #466

Open entwanne opened 2 years ago

entwanne commented 2 years ago

Hi,

zgorg2004 noticed on Zeste de Savoir that some blocks of code didn't contain the correct content in the PDF export of Un zeste de Python.

For example at page 269 we can see: 2022-07-05-171150_687x374_scrot

The name of the listing is correct (attaques.csv) but the content is the one of an earlier extract (new.ini page 268).

Everything is good in the HTML version of the tutorial: https://zestedesavoir.com/tutoriels/2514/un-zeste-de-python/6-entrees-sorties/7-formatage/#4-4-csv

StaloneLab commented 1 year ago

Hi, and sorry for the delay,

I checked this bug, and first thought it was due to ZMarkdown, but the LaTeX seems to be correctly generated on the website (line 13774 and following). I do not understand how it could be due to the template... Can you confirm if the LaTeX is indeed correct, or if I am mistaking? I will open an issue on the LaTeX side if the error is not due to the generation of the LaTeX file.

entwanne commented 1 year ago

Hi,

Sorry for the delay but yes I confirm that the LaTex file is good.

Voici un exemple de document CSV :

\begin{CodeBlock}{csv}
nom,type,degats
charge,normal,20
tonnerre,foudre,50
jet-de-flotte,aquatique,40
brûlure,flamme,40
\end{CodeBlock}
\captionof{listing}{attaques.csv}

Une première ligne (l’en-tête) identifie les noms des colonnes, elle est facultative, mais il faudra en tenir compte lors de l’analyse du fichier.
StaloneLab commented 1 year ago

Thanks, I transferred on the LaTeX template repository, I am tagging the issue here while waiting for the answer.

StaloneLab commented 1 year ago

Karnaj says that the issue is due to the LaTeX package used for code blocks not supporting the csv language. We could add support for the language in our template, but I do not think it would be very useful, since CSV doesn't require that much syntax highlighting; it is not even highlighted in the HTML content anyway. I think the best way to solve the issue would be to transform the code block in your tutorial's Markdown to text (not specifying the language should also work), considering that CSV is not a valid language in ZMarkdown. What do you think? Would you prefer the language to be discarded if invalid?

entwanne commented 1 year ago

Ok thanks for the details. I'll update my tutorial to fix the block, but yes I think it would be great to discard at zmd level unsupported languages.