Fix line overflow message, and line offset errors

This commit is contained in:
Louis Gesbert 2024-03-06 14:15:07 +01:00
parent 95e3c4bedd
commit 26c28bbd35
3 changed files with 7 additions and 10 deletions

View File

@ -140,7 +140,7 @@ let rec law_structure_to_html
let t = pre_html t in
if t = "" then () else Format.fprintf fmt "<div class='law-text'>%s</div>" t
| A.CodeBlock (_, c, metadata) when not print_only_law ->
let start_line = Pos.get_start_line (Mark.get c) - 1 in
let start_line = Pos.get_start_line (Mark.get c) + 1 in
let filename = Pos.get_file (Mark.get c) in
let block_content = Mark.remove c in
check_exceeding_lines start_line filename block_content;

View File

@ -34,7 +34,7 @@ let update_lines_of_code c =
- Pos.get_start_line (Mark.get c)
- 1
(** Espaces various LaTeX-sensitive characters *)
(** Escapes various LaTeX-sensitive characters *)
let pre_latexify (s : string) : string =
(* Then we send to pandoc, to ensure the markdown features used in the
original document are correctly printed! *)
@ -296,7 +296,7 @@ let rec law_structure_to_latex
(pre_latexify (Mark.remove al)))
| A.LawText t -> Format.fprintf fmt "%s" (pre_latexify t)
| A.CodeBlock (_, c, false) when not print_only_law ->
let start_line = Pos.get_start_line (Mark.get c) - 1 in
let start_line = Pos.get_start_line (Mark.get c) + 1 in
let filename = Pos.get_file (Mark.get c) in
let block_content = Mark.remove c in
check_exceeding_lines start_line filename block_content;

View File

@ -113,13 +113,10 @@ let check_exceeding_lines
Uutf.String.fold_utf_8 (fun (acc : int) _ _ -> acc + 1) 0 s
in
if len_s > max_len then
Message.emit_warning
"@[<v>The line @{<bold;yellow>%d@} in @{<bold;magenta>%s@} is \
exceeding @{<bold;red}%d@} characters:@,\
%s@{<red>%s@}@]"
(start_line + i + 1)
filename max_len (String.sub s 0 max_len)
(String.sub s max_len (len_s - max_len)))
Message.emit_spanned_warning
(Pos.from_info filename (start_line + i) (max_len + 1)
(start_line + i) (len_s + 1))
"This line is exceeding @{<bold;red>%d@} characters" max_len)
let with_pygmentize_lexer lang f =
let lexer_py =