Commit
Author: Kevin Schoon [kevinschoon@gmail.com]
Hash: d1fa53cec4be81e9abcaf64c4942d78f8d520b0a
Timestamp: Wed, 16 Jun 2021 18:49:35 +0000 (3 years ago)

+0 -81 +/-1 browse
rm dead code
1diff --git a/bin/note.ml b/bin/note.ml
2index 7de5c2a..adbc0cf 100644
3--- a/bin/note.ml
4+++ b/bin/note.ml
5 @@ -5,87 +5,6 @@ let cfg = Config.config_path |> Config.load
6
7 let context = cfg.context
8
9- module Util = struct
10- open ANSITerminal
11-
12- let rec to_words (accm : string list) (doc : Omd.doc) : string list =
13- let split_words inline =
14- match inline with Omd.Text text -> String.split ~on:' ' text | _ -> []
15- in
16- match doc with
17- | [] -> accm
18- | hd :: tl -> (
19- (* TODO: account for headings, lists, etc *)
20- match hd.bl_desc with
21- | Paragraph inline ->
22- let accm = accm @ split_words inline.il_desc in
23- to_words accm tl
24- | _ -> to_words accm tl)
25-
26- let paint_tag (styles : Config.StylePair.t list) text : string =
27- match
28- List.find ~f:(fun entry -> String.equal entry.pattern text) styles
29- with
30- | Some entry -> sprintf entry.styles "%s" text
31- | None -> sprintf [ Foreground Default ] "%s" text
32-
33- let to_cells ~columns ~styles (notes : Note.note list) =
34- let header =
35- List.map
36- ~f:(fun column ->
37- let text_value = Config.Column.to_string column in
38- let text_length = String.length text_value in
39- let text_value = sprintf [ Bold; Underlined ] "%s" text_value in
40- (text_value, text_length, 1))
41- columns
42- in
43- let note_cells =
44- let default_padding = 1 in
45- List.fold ~init:[]
46- ~f:(fun accm note ->
47- accm
48- @ [
49- List.map
50- ~f:(fun column ->
51- match column with
52- | `Title ->
53- let text_value = note.frontmatter.title in
54- (text_value, String.length text_value, default_padding)
55- | `Description ->
56- let text_value = note.frontmatter.description in
57- (text_value, String.length text_value, default_padding)
58- | `Slug ->
59- let text_value =
60- match note.slug with
61- | Some slug -> slug |> Slug.shortname
62- | None -> "??"
63- in
64- (text_value, String.length text_value, default_padding)
65- | `Tags ->
66- let text_value =
67- String.concat ~sep:"|" note.frontmatter.tags
68- in
69- let text_length = String.length text_value in
70- let tags = note.frontmatter.tags in
71- let tags =
72- List.map ~f:(fun tag -> paint_tag styles tag) tags
73- in
74- let text_value = String.concat ~sep:"|" tags in
75- (text_value, text_length, default_padding)
76- | `WordCount ->
77- let text_value =
78- Core.sprintf "%d"
79- (List.length
80- (to_words [] (note.content |> Omd.of_string)))
81- in
82- (text_value, String.length text_value, default_padding))
83- columns;
84- ])
85- notes
86- in
87- [ header ] @ note_cells
88- end
89-
90 module Encoding = struct
91 let to_string ~style (note : Note.note) =
92 match style with