[OCaml] Org mode parser.
feat rename heading_contents to contents
The field stuttered since it lives on the heading type. Plain 'contents' is concise and unambiguous. BREAKING CHANGE: Ast.heading.heading_contents renamed to Ast.heading.contents
Changed files
README.org
@@ -53,7 +53,7 @@
53
53
tags = [ "tag1"; "tag2" ];
54
54
planning = None;
55
55
properties = [];
56
Removed:
heading_contents =
56
Added:
contents =
57
57
[ Paragraph
58
58
([ Italic [ Plain "italic" ];
59
59
Plain " and ";
@@ -96,7 +96,7 @@
96
96
let rec from_headings acc = function
97
97
| [] -> acc
98
98
| h :: rest ->
99
Removed:
let acc = from_elements acc h.heading_contents in
99
Added:
let acc = from_elements acc h.contents in
100
100
let acc = from_headings acc h.children in
101
101
from_headings acc rest
102
102
in
lib/ast.ml
@@ -166,7 +166,7 @@
166
166
tags : string list;
167
167
planning : planning option;
168
168
properties : property list;
169
Removed:
heading_contents : element list;
169
Added:
contents : element list;
170
170
children : heading list;
171
171
}
172
172
lib/ast.mli
@@ -167,7 +167,7 @@
167
167
tags : string list;
168
168
planning : planning option;
169
169
properties : property list;
170
Removed:
heading_contents : element list;
170
Added:
contents : element list;
171
171
children : heading list;
172
172
}
173
173
lib/normalize.ml
@@ -543,7 +543,7 @@
543
543
tags;
544
544
planning;
545
545
properties;
546
Removed:
heading_contents = contents;
546
Added:
contents;
547
547
children;
548
548
} in
549
549
heading :: process_headings siblings_raw
test/test_main.ml
@@ -477,28 +477,28 @@
477
477
(List.length h3.A.children >= 6);
478
478
(* Unordered list *)
479
479
let ul_heading = List.nth h3.A.children 0 in
480
Removed:
let ul_elems = ul_heading.A.heading_contents in
480
Added:
let ul_elems = ul_heading.A.contents in
481
481
let has_unordered = List.exists (function
482
482
| A.Plain_list (A.Unordered, items) -> List.length items >= 3
483
483
| _ -> false) ul_elems in
484
484
Alcotest.(check bool) "has unordered list" true has_unordered;
485
485
(* Ordered list *)
486
486
let ol_heading = List.nth h3.A.children 1 in
487
Removed:
let ol_elems = ol_heading.A.heading_contents in
487
Added:
let ol_elems = ol_heading.A.contents in
488
488
let has_ordered = List.exists (function
489
489
| A.Plain_list (A.Ordered, items) -> List.length items >= 3
490
490
| _ -> false) ol_elems in
491
491
Alcotest.(check bool) "has ordered list" true has_ordered;
492
492
(* Descriptive list *)
493
493
let dl_heading = List.nth h3.A.children 2 in
494
Removed:
let dl_elems = dl_heading.A.heading_contents in
494
Added:
let dl_elems = dl_heading.A.contents in
495
495
let has_descriptive = List.exists (function
496
496
| A.Plain_list (A.Descriptive, items) -> List.length items >= 2
497
497
| _ -> false) dl_elems in
498
498
Alcotest.(check bool) "has descriptive list" true has_descriptive;
499
499
(* Source block *)
500
500
let src_heading = List.nth h3.A.children 3 in
501
Removed:
let src_elems = src_heading.A.heading_contents in
501
Added:
let src_elems = src_heading.A.contents in
502
502
let has_src = List.exists (function
503
503
| A.Block (A.Src_block sb) ->
504
504
sb.A.src_language = Some "ocaml" &&
@@ -507,21 +507,21 @@
507
507
Alcotest.(check bool) "has src block with ocaml" true has_src;
508
508
(* Quote block *)
509
509
let qt_heading = List.nth h3.A.children 4 in
510
Removed:
let qt_elems = qt_heading.A.heading_contents in
510
Added:
let qt_elems = qt_heading.A.contents in
511
511
let has_quote = List.exists (function
512
512
| A.Block (A.Quote_block _) -> true
513
513
| _ -> false) qt_elems in
514
514
Alcotest.(check bool) "has quote block" true has_quote;
515
515
(* Example block *)
516
516
let ex_heading = List.nth h3.A.children 5 in
517
Removed:
let ex_elems = ex_heading.A.heading_contents in
517
Added:
let ex_elems = ex_heading.A.contents in
518
518
let has_example = List.exists (function
519
519
| A.Block (A.Example_block _) -> true
520
520
| _ -> false) ex_elems in
521
521
Alcotest.(check bool) "has example block" true has_example;
522
522
(* Tables heading is at index 3 *)
523
523
let h4 = List.nth full_doc.A.headings 3 in
524
Removed:
let table_elems = h4.A.heading_contents in
524
Added:
let table_elems = h4.A.contents in
525
525
let has_table = List.exists (function
526
526
| A.Table t ->
527
527
let has_standard = List.exists (function
@@ -533,7 +533,7 @@
533
533
Alcotest.(check bool) "has table with rows and rules" true has_table;
534
534
(* Miscellaneous heading is at index 4 *)
535
535
let h5 = List.nth full_doc.A.headings 4 in
536
Removed:
let misc_elems = h5.A.heading_contents in
536
Added:
let misc_elems = h5.A.contents in
537
537
let has_fixed_width = List.exists (function
538
538
| A.Fixed_width lines -> List.length lines >= 2
539
539
| _ -> false) misc_elems in
@@ -579,7 +579,7 @@
579
579
Alcotest.(check bool) "preamble para2 has link" true has_link;
580
580
(* Timestamps heading (index 5) *)
581
581
let h6 = List.nth full_doc.A.headings 5 in
582
Removed:
let ts_elems = h6.A.heading_contents in
582
Added:
let ts_elems = h6.A.contents in
583
583
let all_inlines = List.concat_map (function
584
584
| A.Paragraph (il, _) -> il
585
585
| _ -> []) ts_elems in