Fix line numbers in LaTeX and HTML with leading comments in code

This commit is contained in:
Denis Merigoux 2022-08-10 10:45:49 +02:00
parent 54c97d1d0c
commit 228b6c830a
No known key found for this signature in database
GPG Key ID: EE99DCFA365C3EE3
3 changed files with 3 additions and 3 deletions

View File

@ -135,7 +135,7 @@ let pygmentize_code (c : string Marked.pos) (language : C.backend_lang) : string
"style=colorful,anchorlinenos=True,lineanchors=\""
^ String_common.to_ascii (Pos.get_file (Marked.get_mark c))
^ "\",linenos=table,linenostart="
^ string_of_int (Pos.get_start_line (Marked.get_mark c) - 1);
^ string_of_int (Pos.get_start_line (Marked.get_mark c) + 1);
"-o";
temp_file_out;
temp_file_in;

View File

@ -247,7 +247,7 @@ let rec law_structure_to_latex
%s```\n\
\\end{minted}"
(pre_latexify (Filename.basename (Pos.get_file (Marked.get_mark c))))
(Pos.get_start_line (Marked.get_mark c) - 1)
(Pos.get_start_line (Marked.get_mark c) + 1)
(get_language_extension language)
(Marked.unmark c)
| A.CodeBlock (_, c, true) when not print_only_law ->

View File

@ -653,7 +653,7 @@ source_file_item:
| text = law_text { LawText text }
| BEGIN_CODE code_and_pos = code text = END_CODE {
let (code, pos) = code_and_pos in
CodeBlock (code, (text, pos), false)
CodeBlock (code, (text, Pos.from_lpos $sloc), false)
}
| heading = law_heading {
LawHeading (heading, [])