Author: Kevin Schoon [kevinschoon@gmail.com]
Hash: 0edb7d1a6e9f70f73678a0dd2f26e8a8d5e08119
Timestamp: Mon, 12 Apr 2021 12:51:55 +0000 (3 years ago)

+11 -5 +/-2 browse
add support for html encoding
1diff --git a/lib/config.ml b/lib/config.ml
2index 6eafaf5..2c25555 100644
3--- a/lib/config.ml
4+++ b/lib/config.ml
5 @@ -31,15 +31,20 @@ module ListStyle = struct
6 end
7
8 module Encoding = struct
9- type t = [ `Json | `Yaml | `Raw ]
10+ type t = [ `Json | `Yaml | `Html | `Raw ]
11
12- let all = [ `Json; `Yaml; `Raw ]
13+ let all = [ `Json; `Yaml; `Html; `Raw ]
14
15- let to_string = function `Json -> "json" | `Yaml -> "yaml" | `Raw -> "raw"
16+ let to_string = function
17+ | `Json -> "json"
18+ | `Yaml -> "yaml"
19+ | `Html -> "html"
20+ | `Raw -> "raw"
21
22 let of_string = function
23 | "json" -> `Json
24 | "yaml" -> `Yaml
25+ | "html" -> `Html
26 | "raw" -> `Raw
27 | key -> failwith (sprintf "unsupported encoding type: %s" key)
28 end
29 @@ -291,8 +296,8 @@ let get t key =
30 | `LockFile -> t.lock_file
31 | `Editor -> t.editor
32 | `OnModification -> (
33- match t.on_modification with Some value -> value | None -> "null" )
34- | `OnSync -> ( match t.on_sync with Some value -> value | None -> "null" )
35+ match t.on_modification with Some value -> value | None -> "null")
36+ | `OnSync -> ( match t.on_sync with Some value -> value | None -> "null")
37 | `ListStyle -> ListStyle.to_string t.list_style
38 | `Encoding -> Encoding.to_string t.encoding
39 | `ColumnList ->
40 diff --git a/lib/note.ml b/lib/note.ml
41index afc20c9..8c4950f 100644
42--- a/lib/note.ml
43+++ b/lib/note.ml
44 @@ -160,6 +160,7 @@ module Encoding = struct
45 | `Raw -> In_channel.read_all (get_path t)
46 | `Json -> Ezjsonm.to_string (to_json t)
47 | `Yaml -> Yaml.to_string_exn (to_json t)
48+ | `Html -> Omd.to_html t.markdown
49 end
50
51 module Search = struct