"
@@ -79,7 +80,10 @@ let page htm conversion text =
^ opt_kv "Series:" (str_set "series" text)
^ opt_kv "Topics:" (topic_links (set "topics" text))
^ opt_kv "Id:" text.id
- ^ opt_kv "References:" (ref_links (set "references" text))
+ ^ opt_kv "Refers:" (ref_links (set "references" text))
+ ^ opt_kv "Referred by:" (try
+ ref_links (Conversion.Id_map.find text.id conversion.Conversion.references)
+ with Not_found -> "")
^ {|
|} in
wrap conversion htm text.title ((T.of_string text.body header) ^ "
")
diff --git a/lib/id.ml b/lib/id.ml
index 1dab0ce..3850a2f 100644
--- a/lib/id.ml
+++ b/lib/id.ml
@@ -12,7 +12,7 @@ let random_state = Random.State.make_self_init
(*end*)
type t = string
-let compare = String.compare
+let compare = String.compare
let nil = ""
let short ?(len) id =
diff --git a/lib/reference_set.ml b/lib/reference_set.ml
new file mode 100644
index 0000000..6c456ec
--- /dev/null
+++ b/lib/reference_set.ml
@@ -0,0 +1 @@
+module Map = Map.Make(String)
diff --git a/lib/string_set.ml b/lib/string_set.ml
index ae0ac59..fca4fc1 100644
--- a/lib/string_set.ml
+++ b/lib/string_set.ml
@@ -1,7 +1,12 @@
include Set.Make(String)
let list_of_csv x = Str.(split (regexp " *, *")) (String.trim x)
-let of_string x = of_list (list_of_csv x)
+let list_of_ssv x = Str.(split (regexp " +")) (String.trim x)
+
+let of_string ?(separator=list_of_csv) x = of_list (separator x)
+let of_csv_string x = of_string ~separator:list_of_csv x
+let of_ssv_string x = of_string ~separator:list_of_ssv x
+
let to_string ?(pre="") ?(sep=", ") s =
let j a x = match a, x with "", _ -> x | _, "" -> a | _ -> a ^ sep ^ x in
fold (fun x acc -> j acc x) s pre
diff --git a/lib/text.ml b/lib/text.ml
index 6a4feda..1b010fa 100644
--- a/lib/text.ml
+++ b/lib/text.ml
@@ -25,8 +25,8 @@ let oldest a b = Date.(compare b.date a.date)
let str key m = try String_map.find (String.lowercase_ascii key) m.string_map with Not_found -> ""
let set key m = try String_map.find (String.lowercase_ascii key) m.stringset_map with Not_found -> String_set.empty
let str_set key m = String_set.to_string @@ set key m
-let with_str_set m key str = { m with
- stringset_map = String_map.add (String.lowercase_ascii key) (String_set.of_string str) m.stringset_map
+let with_str_set ?(separator=String_set.of_csv_string) m key str = { m with
+ stringset_map = String_map.add (String.lowercase_ascii key) (separator str) m.stringset_map
}
let with_kv x (k,v) =
@@ -39,7 +39,11 @@ let with_kv x (k,v) =
| "authors" -> { x with authors = Person.Set.of_string (trim v)}
| "date" -> { x with date = Date.{ x.date with created = Date.of_string v }}
| "date-edited"-> { x with date = Date.{ x.date with edited = Date.of_string v }}
- | "licences" | "topics" | "keywords" | "references" | "series" as k -> with_str_set x k v
+ | "licences" | "topics" | "keywords" | "series" as k -> with_str_set x k v
+ | "references" -> with_str_set
+ ~separator:(fun x -> String_set.map (fun x -> String.(sub x 1 (length x-2)))
+ (String_set.of_ssv_string x))
+ x k v
| k -> { x with string_map = String_map.add k (trim v) x.string_map }
let kv_of_string line = match Str.(bounded_split (regexp ": *")) line 2 with
diff --git a/readme.txt b/readme.txt
index 3b447c9..e211391 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,16 +1,25 @@
ID: ka4wtj
Title: Logarion
+References: <3sqd84>