Read References field; referred by listing; test & tidy documentation

git-svn-id: file:///srv/svn/repo/kosuzu/trunk@39 eb64cd80-c68d-6f47-b6a3-0ada418499da
This commit is contained in:
fox
2022-12-12 22:52:55 +00:00
parent e6452a861d
commit 1547dc4d27
9 changed files with 108 additions and 38 deletions

View File

@@ -25,7 +25,7 @@ let wrap conv htm text_title body =
let feed = try Logarion.Store.KV.find "HTM-feed" conv.Conversion.kv
with Not_found -> if Sys.file_exists (Filename.concat conv.Conversion.dir "feed.atom")
then "feed.atom" else "" in
let header = match htm.templates.header with
let header = match htm.templates.header with
| Some x -> replace x
| None -> Printf.(sprintf "<header><a href='.'>%s</a>%s</header>" site_title
(if feed <> "" then sprintf "<nav><a href='%s' id='feed'>feed</a></nav>" feed else ""))
@@ -46,6 +46,7 @@ let topic_link root topic =
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 angled_uri u a =
if try String.sub u 0 10 = "urn:txtid:" with Invalid_argument _ -> false
then angled_uri (String.(sub u 10 (length u - 10)) ^ ext) a else angled_uri u a
@@ -69,7 +70,7 @@ let page htm conversion text =
sep_append a (List.fold_left (fun a t -> sep_append ~sep:" > " a (topic_link (List.hd ts) t)) "" ts) in
String_set.fold to_linked x "" in
let ref_links x =
let link l = HtmlConverter.angled_uri (String.(sub l 1 (length l-2))) "" in
let link l = HtmlConverter.uid_uri l "" in
String_set.fold (fun r a -> sep_append a (link r)) x ""
in
"<article><header><dl>"
@@ -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 -> "")
^ {|</dl></header><pre style="white-space:pre-wrap">|} in
wrap conversion htm text.title ((T.of_string text.body header) ^ "</pre></article>")