let render_to_strings ~map_unicode_to_tex choose_action size markup =
prerr_endline ("render size is " ^ string_of_int size);
+ let add_markup attr txt =
+ let txt = Netencoding.Html.encode ~in_enc:`Enc_utf8 () txt in
+ let value_of_attr (_,_,v) = v in
+ let title =
+ try Some (value_of_attr (List.find (fun (_,t,_) -> t = "title") attr))
+ with _ -> None in
+ let href =
+ try Some (value_of_attr (List.find (fun (_,t,_) -> t = "href") attr))
+ with _ -> None in
+ match title,href with
+ | None,None -> txt
+ | None,Some u -> "<A href=\"" ^ u ^ "\">" ^ txt ^ "</A>"
+ | Some t, Some u ->
+ "<A href=\"" ^ u ^ "\" title=\"" ^ t ^ "\">" ^ txt ^ "</A>"
+ | Some t, None ->
+ let u = "cic:/fakeuri.con" in
+ "<A href=\"" ^ u ^ "\" title=\"" ^ t ^ "\">" ^ txt ^ "</A>"
+ in
+
let max_size = max_int in
let rec aux_box =
function
- | Box.Text (_, t) -> fixed_rendering t
+ | Box.Text (attr, t) ->
+ fun x ->
+ (match fixed_rendering t x with
+ | len, [txt] -> len, [add_markup attr txt]
+ | _ -> assert false)
| Box.Space _ -> fixed_rendering string_space
| Box.Ink _ -> fixed_rendering string_ink
| Box.Action (_, []) -> assert false