@@ -30,6 +30,15 @@ let json_of_toc (toc : Types.toc list) : Json.json =
3030 let toc_json_list = toc |> List. map section in
3131 `Array toc_json_list
3232
33+ let json_of_html config h =
34+ let htmlpp = Html. pp_elt ~indent: (Config. indent config) () in
35+ String. concat " " (List. map (Format. asprintf " %a" htmlpp) h)
36+
37+ let json_of_sidebar config sidebar =
38+ match sidebar with
39+ | None -> `Null
40+ | Some sidebar -> `String (json_of_html config sidebar)
41+
3342let make ~config ~preamble ~url ~breadcrumbs ~sidebar ~toc ~uses_katex
3443 ~source_anchor content children =
3544 let filename = Link.Path. as_filename ~config url in
@@ -38,15 +47,7 @@ let make ~config ~preamble ~url ~breadcrumbs ~sidebar ~toc ~uses_katex
3847 let source_anchor =
3948 match source_anchor with Some url -> `String url | None -> `Null
4049 in
41- let json_of_html h =
42- let htmlpp = Html. pp_elt ~indent: (Config. indent config) () in
43- String. concat " " (List. map (Format. asprintf " %a" htmlpp) h)
44- in
45- let global_toc =
46- match sidebar with
47- | None -> `Null
48- | Some sidebar -> `String (json_of_html sidebar)
49- in
50+ let global_toc = json_of_sidebar config sidebar in
5051 let content ppf =
5152 Format. pp_print_string ppf
5253 (json_to_string
@@ -58,24 +59,26 @@ let make ~config ~preamble ~url ~breadcrumbs ~sidebar ~toc ~uses_katex
5859 (" toc" , json_of_toc toc);
5960 (" global_toc" , global_toc);
6061 (" source_anchor" , source_anchor);
61- (" preamble" , `String (json_of_html preamble));
62- (" content" , `String (json_of_html content));
62+ (" preamble" , `String (json_of_html config preamble));
63+ (" content" , `String (json_of_html config content));
6364 ]))
6465 in
6566 { Odoc_document.Renderer. filename; content; children; path = url }
6667
67- let make_src ~config ~url ~breadcrumbs content =
68+ let make_src ~config ~url ~breadcrumbs ~ sidebar content =
6869 let filename = Link.Path. as_filename ~config url in
6970 let filename = Fpath. add_ext " .json" filename in
7071 let htmlpp = Html. pp_elt ~indent: (Config. indent config) () in
7172 let json_to_string json = Json. to_string json in
73+ let global_toc = json_of_sidebar config sidebar in
7274 let content ppf =
7375 Format. pp_print_string ppf
7476 (json_to_string
7577 (`Object
7678 [
7779 (" type" , `String " source" );
7880 (" breadcrumbs" , json_of_breadcrumbs breadcrumbs);
81+ (" global_toc" , global_toc);
7982 ( " content" ,
8083 `String
8184 (String. concat " "
0 commit comments