My agentic slop goes here. Not intended for anyone else!

more

Changed files
+10 -2
stack
+10 -2
stack/river/lib/markdown_converter.ml
···
let add_text text =
let trimmed = String.trim text in
if trimmed <> "" then begin
-
(* Add space if needed and last char isn't already whitespace *)
-
if !need_space then begin
match last_char () with
| Some (' ' | '\n') -> ()
| _ -> Buffer.add_char buffer ' '
···
let add_text text =
let trimmed = String.trim text in
if trimmed <> "" then begin
+
(* Check if text starts with punctuation that shouldn't have space before it *)
+
let starts_with_punctuation =
+
String.length trimmed > 0 &&
+
(match trimmed.[0] with
+
| ',' | '.' | ';' | ':' | '!' | '?' | ')' | ']' | '}' -> true
+
| _ -> false)
+
in
+
+
(* Add space if needed, unless we're before punctuation *)
+
if !need_space && not starts_with_punctuation then begin
match last_char () with
| Some (' ' | '\n') -> ()
| _ -> Buffer.add_char buffer ' '