let msg = P.sprintf "This file was generated by %s, do not edit" myself
+let compose uri ext =
+ if uri.[pred (S.length uri)] = '/' then uri else
+ try
+ let i = S.index uri '#' in
+ let uri, fragment = S.sub uri 0 i, S.sub uri i (S.length uri - i) in
+ uri ^ ext ^ fragment
+ with Not_found -> uri ^ ext
+
let border cell =
let str = S.make 4 'n' in
if cell.M.cb.T.n then str.[0] <- 's';
| T.Plain s -> s
| T.Link (true, uri, s) -> P.sprintf "<a href=\"%s\">%s</a>" uri s
| T.Link (false, uri, s) ->
- let uri = !O.baseuri ^ baseuri ^ uri ^ ext in
+ let uri = !O.baseuri ^ baseuri ^ compose uri ext in
P.sprintf "<a href=\"%s\">%s</a>" uri s
+let name cell =
+ if cell.M.cn = "" then "" else P.sprintf " id=\"%s\"" cell.M.cn
+
let key cell =
- if cell.M.ck = [] then "<br/>" else S.concat " " (L.map (text cell.M.cu cell.M.cx) cell.M.ck)
+ if cell.M.ck = [] then "<br/>" else S.concat "" (L.map (text cell.M.cu cell.M.cx) cell.M.ck)
let ind i = S.make (2 * i) ' '
let out_cell och cell =
let cc = border cell in
- P.fprintf och "%s<td class=\"%s\">%s</td>\n"
- (ind (i+4)) (S.concat " " cc) (key cell)
+ P.fprintf och "%s<td class=\"%s\"%s>%s</td>\n"
+ (ind (i+4)) (S.concat " " cc) (name cell) (key cell)
let out_row och row =
P.fprintf och "%s<tr>\n" (ind (i+3));