Skip to content

Commit f001d93

Browse files
committed
review: use Astring
1 parent 3ca3a99 commit f001d93

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/latex/raw.ml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,20 +209,13 @@ let ocamltag tag pp ppf x = create2 "ocamltag" Fmt.string pp ppf tag x
209209

210210
let math ppf x = Fmt.pf ppf {|$%s$|} x
211211

212-
let remove_empty_last_line x =
213-
let rec find_last_line pos x =
214-
if pos < 0 then x
215-
else
216-
match x.[pos] with
217-
| ' ' | '\012' | '\n' | '\r' | '\t' -> find_last_line (pos - 1) x
218-
| _ -> if pos = String.length x - 1 then x else String.sub x 0 (pos + 1)
219-
in
220-
find_last_line (String.length x - 1) x
221-
222212
let equation ppf x =
223213
let name = "equation*" in
224214
mbegin ppf name;
225215
Fmt.cut ppf ();
226-
Fmt.string ppf (remove_empty_last_line x);
216+
(* A blank line before \end{equation*} is a latex error,
217+
we trim on the right the user input to avoid any surprise *)
218+
let x = Astring.String.drop ~rev:true ~sat:Astring.Char.Ascii.is_white x in
219+
Fmt.string ppf x;
227220
Fmt.cut ppf ();
228221
mend ppf name

0 commit comments

Comments
 (0)