let rec string_of_line line = let buf = Buffer.create 512 in let add = Buffer.add_string buf in let rec loop = function | h::t -> (match h with | CData s -> add s | Emphasis (_, l) | Strong (_, l) | Italic (_, l) | Bold (_, l) | Citation (_, l) | Deleted (_, l) | Inserted (_, l) | Superscript (_, l) | Subscript (_, l) | Span (_, l) -> add (string_of_line l) | Acronym (s, _) | Code (_, s) -> add s | Notextile s -> (* TODO: whoops, what we have to do? *) add s | Image _ -> () | Link ((_, l), _, _) -> add (string_of_line l) | Reference i -> Printf.bprintf buf "[%d]" i); loop t | [] -> Buffer.contents buf in loop line