Skip to content

Commit b583c5b

Browse files
committed
run dune build @fmt
Signed-off-by: Marcello Seri <marcello.seri@gmail.com>
1 parent 3dfb07a commit b583c5b

6 files changed

Lines changed: 40 additions & 19 deletions

File tree

bibfmt/bin/bibfmt.ml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ let bibfmt out strict single_line quiet verbose force files =
5555
"Warning: No valid BibTeX entries found in the file.\n%!";
5656
combined_content)
5757
else
58-
let options =
58+
let options =
5959
{ Bibtex.default_options with strict; single_line }
6060
in
6161
Bibtex.pretty_print_bibtex ~options parse_result.items)
@@ -114,7 +114,8 @@ let () =
114114
in
115115
let single_line =
116116
let doc =
117-
"Force field values onto a single line by replacing newlines with a space."
117+
"Force field values onto a single line by replacing newlines with a \
118+
space."
118119
in
119120
Arg.(value & flag & info [ "l"; "single-line" ] ~doc)
120121
in
@@ -141,7 +142,10 @@ let () =
141142
Arg.(value & pos_all string [] & info [] ~docv:"FILES" ~doc)
142143
in
143144
let bibfmt_t =
144-
Term.(ret (const bibfmt $ out $ strict $ single_line $ quiet $ verbose $ force $ files))
145+
Term.(
146+
ret
147+
(const bibfmt $ out $ strict $ single_line $ quiet $ verbose $ force
148+
$ files))
145149
in
146150
let info =
147151
let doc = "A little CLI tool to pretty print bibtex files." in

bibfmt/lib/bibtex.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,9 +677,8 @@ let format_entry options entry =
677677
|> List.filter (function
678678
| Field f -> (
679679
match f.value with
680-
| QuotedStringValue s
681-
| BracedStringValue s
682-
| UnquotedStringValue s ->
680+
| QuotedStringValue s | BracedStringValue s | UnquotedStringValue s
681+
->
683682
String.length (String.trim s) > 0
684683
| NumberValue _ -> true)
685684
| EntryComment _ -> true)
@@ -706,7 +705,9 @@ let format_entry options entry =
706705
let contents_str =
707706
if filtered_contents = [] then ""
708707
else
709-
let formatted_contents = List.map format_entry_content' filtered_contents in
708+
let formatted_contents =
709+
List.map format_entry_content' filtered_contents
710+
in
710711
let rec add_commas_except_last = function
711712
| [] -> []
712713
| [ last ] -> [ last ] (* No comma for the last item *)

bibfmt/lib/bibtex.mli

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,14 @@ val format_field_value_with_url_unescaping :
150150
@return String representation with URLs unescaped if applicable *)
151151

152152
val format_field : bool -> bool -> field -> string
153-
(** [format_field capitalized single_line field] formats a complete field (name = value).
153+
(** [format_field capitalized single_line field] formats a complete field (name
154+
= value).
154155
@param field The field to format
155156
@return String representation of the field *)
156157

157158
val format_entry_content : bool -> bool -> entry_content -> string
158-
(** [format_entry_content capitalized single_line content] formats entry content (field or comment).
159+
(** [format_entry_content capitalized single_line content] formats entry content
160+
(field or comment).
159161
@param content The entry content to format
160162
@return String representation of the content *)
161163

@@ -201,13 +203,14 @@ val find_duplicate_groups :
201203
Each group contains at least 2 entries that match on the specified keys. *)
202204

203205
val string_of_field_value : field_value -> string
204-
(** [string_of_field_value fv] converts a field value to its string representation.
206+
(** [string_of_field_value fv] converts a field value to its string
207+
representation.
205208
@param fv The field value to convert
206209
@return String representation of the field value *)
207210

208211
val make_field : string -> string -> entry_content
209-
(** [make_field name value] creates a BibTeX field with the given name and value.
210-
The value is wrapped in braces.
212+
(** [make_field name value] creates a BibTeX field with the given name and
213+
value. The value is wrapped in braces.
211214
@param name Field name
212215
@param value Field value as a string
213216
@return An entry_content Field with a BracedStringValue *)

doi2bib/bin/doi2bib.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ let process_id outfile id =
66
let open Lwt.Syntax in
77
let* bibtex = Http.get_bib_entry @@ Parser.parse_id id in
88

9-
let parsed_items = Bibtex.parse_bibtex bibtex |> List.map Helpers.clean_item in
9+
let parsed_items =
10+
Bibtex.parse_bibtex bibtex |> List.map Helpers.clean_item
11+
in
1012
let formatted =
1113
if List.length parsed_items = 0 then (
1214
Printf.eprintf

doi2bib/lib/helpers.ml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ let escape_ampersand s =
2020
(* We want to match '&' that is not preceded by '\', but the re library
2121
does not support lookbehind, so we can match either the start of the string or a non-backslash character before '&', keep it and replace
2222
the remaining '&' by '\&' *)
23-
let re = Re.compile (Re.seq [ Re.group (Re.alt [ Re.bos; Re.compl [ Re.char '\\' ] ]); Re.char '&' ]) in
23+
let re =
24+
Re.compile
25+
(Re.seq
26+
[
27+
Re.group (Re.alt [ Re.bos; Re.compl [ Re.char '\\' ] ]); Re.char '&';
28+
])
29+
in
2430
Re.replace re
2531
~f:(fun subs ->
2632
let prefix = Re.Group.get subs 1 in

doi2bib/lib/parser.ml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ let parse_id id =
1212
let n = String.length affix in
1313
String.length s >= n && String.sub (String.lowercase_ascii s) 0 n = affix
1414
in
15-
let sub start s = String.trim (String.sub s start (String.length s - start)) in
15+
let sub start s =
16+
String.trim (String.sub s start (String.length s - start))
17+
in
1618
match id with
1719
| doi when is_prefix "doi:" doi -> DOI (sub 4 doi)
1820
| arxiv when is_prefix "arxiv:" arxiv -> ArXiv (sub 6 arxiv)
@@ -41,14 +43,17 @@ let parse_atom id atom =
4143
get_attr "term" a
4244
in
4345
let bibid =
44-
(match String.split_on_char ' ' authors |> List.filter (fun s -> s <> "") with
46+
(match
47+
String.split_on_char ' ' authors |> List.filter (fun s -> s <> "")
48+
with
4549
| _ :: s :: _ -> s
4650
| s :: _ -> s
4751
| [] -> "")
4852
^ year
49-
^ (match String.index_opt title ' ' with
50-
| Some i -> String.sub title 0 i
51-
| None -> "")
53+
^
54+
match String.index_opt title ' ' with
55+
| Some i -> String.sub title 0 i
56+
| None -> ""
5257
in
5358
Printf.sprintf
5459
{|@misc{%s,

0 commit comments

Comments
 (0)