Skip to content

Commit

Permalink
Fixed tag section handling
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenldl committed Feb 20, 2023
1 parent 58bad7c commit 83bf276
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.0.6

- Fixed Notefd to only handle consecutive tag sections

## 0.0.5

- Added `--tags` and `--ltags` flags
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ About topic ABC

The final title is computed in the same way as above.

#### Multiple tag sections
#### Multiple consecutive tag sections
```
Meeting YYYY-MM-DD
About topic ABC
Expand Down
14 changes: 9 additions & 5 deletions src/notefd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,27 @@ module Parsers = struct
end

let parse (l : string list) : string list * String_set.t =
let rec aux title tags l =
let rec aux handled_tag_section title tags l =
match l with
| [] -> (List.rev title, tags)
| x :: xs ->
match Angstrom.(parse_string ~consume:Consume.Prefix) Parsers.p x with
| Ok x ->
(match x with
| Title x -> aux (x :: title) tags xs
| Title x ->
if handled_tag_section then
aux handled_tag_section title tags []
else
aux handled_tag_section (x :: title) tags xs
| Tags l ->
let tags =
String_set.add_list tags l
in
aux title tags xs
aux true title tags xs
)
| Error _ -> aux title tags xs
| Error _ -> aux handled_tag_section title tags xs
in
aux [] String_set.empty l
aux false [] String_set.empty l

let process path : (header, string) result =
let+ lines = get_first_few_lines path in
Expand Down
2 changes: 1 addition & 1 deletion src/version_string.ml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let s = "0.0.5"
let s = "0.0.6"

0 comments on commit 83bf276

Please # to comment.