Index: trunk/cli/conversion.ml
===================================================================
--- trunk/cli/conversion.ml	(revision 39)
+++ trunk/cli/conversion.ml	(revision 41)
@@ -11,4 +11,5 @@
 	topics: (String_set.t * String_set.t) Topic_set.Map.t;
 	references: Ref_set.t Id_map.t;
+	replies: Ref_set.t Id_map.t;
 	texts: Text.t list
 }
@@ -26,4 +27,5 @@
 	topics = Topic_set.Map.empty;
 	references = Id_map.empty;
+	replies = Id_map.empty;
 	texts = []
 }
Index: trunk/cli/convert.ml
===================================================================
--- trunk/cli/convert.ml	(revision 39)
+++ trunk/cli/convert.ml	(revision 41)
@@ -34,17 +34,22 @@
 
 let fold_refs text refs = String_set.fold (acc_ref text.Text.id) (Text.set "references" text) refs
+let fold_reps text reps = String_set.fold (acc_ref text.Text.id) (Text.set "in-reply-to" text) reps
 
 let directory converters noindex repo =
-	let fn (ts,refs,ls,acc) ((elt,_) as r) =
+	let fn (ts,refs,reps,ls,acc) ((elt,_) as r) =
 		Topic_set.to_map ts (Text.set "topics" elt),
-		fold_refs elt refs,
+		fold_refs elt refs, fold_reps elt reps,
 		elt::ls,
-		if convert converters repo r then acc+1 else acc in
-	let topics, references, texts, count =
-		File_store.(fold ~dir:repo.Conversion.dir ~order:newest fn (Topic_set.Map.empty, Conversion.Id_map.empty, [], 0)) in
+		if convert converters {repo with references = refs; replies = reps} r then acc+1 else acc in
+	let topics, references, replies, texts, count =
+		File_store.(fold ~dir:repo.Conversion.dir ~order:oldest fn
+			(Topic_set.Map.empty, Conversion.Id_map.empty, Conversion.Id_map.empty, [], 0)) in
 	let topic_roots = try List.rev @@ String_set.list_of_csv (Store.KV.find "Topics" repo.kv)
 		with Not_found -> Topic_set.roots topics in
-	let repo = Conversion.{ repo with topic_roots; topics; references; texts } in
-	if not noindex then List.iter (fun c -> match c.Conversion.indices with None -> () | Some f -> f repo) converters;
+	Printf.eprintf "%d\n" (Conversion.Id_map.cardinal replies);
+	let repo = Conversion.{ repo with
+		topic_roots; topics; references; replies; texts = List.rev texts } in
+	if not noindex then
+		List.iter (fun c -> match c.Conversion.indices with None -> () | Some f -> f repo) converters;
 	Printf.printf "Converted: %d Indexed: %d\n" count (List.length texts)
 
@@ -74,10 +79,8 @@
 			| Ok text ->
 				let dir = "." in
-				let references = File_store.(fold ~dir ~order:newest
-					(fun refs (elt, _) -> fold_refs elt refs) Conversion.Id_map.empty) in
-					Conversion.Id_map.iter
-						(fun k v -> Conversion.Ref_set.iter (fun e -> Printf.eprintf "%s %s\n" k e) v)
-						references;
-				let repo = { (Conversion.empty ()) with dir; kv = load_kv ""; references } in
+				let references, replies = File_store.(fold ~dir ~order:newest
+					(fun (refs, reps) (elt, _) -> fold_refs elt refs, fold_reps elt reps)
+					(Conversion.Id_map.empty, Conversion.Id_map.empty)) in
+				let repo = { (Conversion.empty ()) with dir; kv = load_kv ""; references; replies } in
 				ignore @@ convert (converters types repo.kv) repo (text, [path])
 		)
Index: trunk/cli/html.ml
===================================================================
--- trunk/cli/html.ml	(revision 39)
+++ trunk/cli/html.ml	(revision 41)
@@ -40,5 +40,5 @@
 	header body footer
 
-let topic_link root topic = 
+let topic_link root topic =
 	let replaced_space = String.map (function ' '->'+' | x->x) in
 	"<a href='index." ^ root ^ ".htm#" ^ replaced_space topic ^ "'>"
@@ -47,5 +47,5 @@
 module HtmlConverter = struct
 	include Converter.Html
-	let uid_uri u a = Printf.sprintf "%s<a href='%s%s'>%s</a>" a u ext u
+	let uid_uri u a = Printf.sprintf "%s<a href='%s%s'>&lt;%s&gt;</a>" a u ext u
 	let angled_uri u a =
 		if try String.sub u 0 10 = "urn:txtid:" with Invalid_argument _ -> false
@@ -74,4 +74,5 @@
 			String_set.fold (fun r a -> sep_append a (link r)) x ""
 		in
+		Printf.eprintf "%s %d\n" text.id (Conversion.Id_map.cardinal conversion.Conversion.replies);
 		"<article><header><dl>"
 		^ opt_kv "Title:" text.title
@@ -82,7 +83,11 @@
 		^ opt_kv "Id:" text.id
 		^ opt_kv "Refers:" (ref_links (set "references" text))
+		^ opt_kv "In reply to:" (ref_links (set "in-reply-to" text))
 		^ opt_kv "Referred by:" (try
 				ref_links (Conversion.Id_map.find text.id conversion.Conversion.references)
 				with Not_found -> "")
+		^ opt_kv "Replies:" (try
+				ref_links (Conversion.Id_map.find text.id conversion.Conversion.replies)
+				with Not_found -> "empty replies")
 		^ {|</dl></header><pre style="white-space:pre-wrap">|} in
 	wrap conversion htm text.title ((T.of_string text.body header) ^ "</pre></article>")
