Changeset 38 in code
- Timestamp:
- Dec 4, 2022, 7:18:52 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cli/html.ml
r24 r38 47 47 module HtmlConverter = struct 48 48 include Converter.Html 49 let angled_uri u a = if String.sub u 0 10 <> "urn:txtid:" then 50 angled_uri u a else angled_uri (String.(sub u 10 (length u - 10)) ^ ext) a 49 let angled_uri u a = 50 if try String.sub u 0 10 = "urn:txtid:" with Invalid_argument _ -> false 51 then angled_uri (String.(sub u 10 (length u - 10)) ^ ext) a else angled_uri u a 51 52 end 52 53 … … 60 61 (* let author acc auth = sep_append acc Person.(auth.name ^ " ") in*) 61 62 let authors = Person.Set.to_string text.authors in 62 let keywords = str_set "keywords" text in63 63 let header = 64 64 let time x = Printf.sprintf {|<time datetime="%s">%s</time>|} … … 69 69 sep_append a (List.fold_left (fun a t -> sep_append ~sep:" > " a (topic_link (List.hd ts) t)) "" ts) in 70 70 String_set.fold to_linked x "" in 71 let ref_links x = 72 let link l = HtmlConverter.angled_uri (String.(sub l 1 (length l-2))) "" in 73 String_set.fold (fun r a -> sep_append a (link r)) x "" 74 in 71 75 "<article><header><dl>" 72 76 ^ opt_kv "Title:" text.title … … 75 79 ^ opt_kv "Series:" (str_set "series" text) 76 80 ^ opt_kv "Topics:" (topic_links (set "topics" text)) 77 ^ opt_kv "Keywords:" keywords78 81 ^ opt_kv "Id:" text.id 82 ^ opt_kv "References:" (ref_links (set "references" text)) 79 83 ^ {|</dl></header><pre style="white-space:pre-wrap">|} in 80 84 wrap conversion htm text.title ((T.of_string text.body header) ^ "</pre></article>") -
trunk/header
r14 r38 5 5 Authors: List of name with optional set of <address> 6 6 Date-edited: ISO8601, use only when text edited 7 References: list of text ID links 7 8 8 9 A blank line must follow the last header field. -
trunk/lib/text.ml
r3 r38 26 26 let set key m = try String_map.find (String.lowercase_ascii key) m.stringset_map with Not_found -> String_set.empty 27 27 let str_set key m = String_set.to_string @@ set key m 28 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 } 28 let with_str_set m key str = { m with 29 stringset_map = String_map.add (String.lowercase_ascii key) (String_set.of_string str) m.stringset_map 30 } 29 31 30 32 let with_kv x (k,v) = … … 38 40 | "date" -> { x with date = Date.{ x.date with created = Date.of_string v }} 39 41 | "date-edited"-> { x with date = Date.{ x.date with edited = Date.of_string v }} 40 | "licences" | "topics" | "keywords" | " series" as k -> with_str_set x k v42 | "licences" | "topics" | "keywords" | "references" | "series" as k -> with_str_set x k v 41 43 | k -> { x with string_map = String_map.add k (trim v) x.string_map } 42 44 … … 78 80 s "Topics" (str_set "topics" x); 79 81 s "Keywords" (str_set "keywords" x); 82 s "References"(str_set "references" x); 80 83 s "Series" (str_set "series" x); 81 84 s "Abstract" (str "abstract" x);
Note:
See TracChangeset
for help on using the changeset viewer.