@@ -82,6 +82,31 @@ let html_of_breadcrumbs (breadcrumbs : Types.breadcrumb list) =
8282 make_navigation ~up_url: up.href
8383 (List. rev html @ sep @ [ Html. txt current.name ])
8484
85+ let file_uri ~config ~url (base : Types.uri ) file =
86+ match base with
87+ | Types. Absolute uri -> uri ^ " /" ^ file
88+ | Relative uri ->
89+ let page = Url.Path. { kind = `File ; parent = uri; name = file } in
90+ Link. href ~config ~resolve: (Current url) (Url. from_path page)
91+
92+ let default_meta_elements ~config ~url =
93+ let theme_uri = Config. theme_uri config in
94+ let odoc_css_uri = file_uri ~config ~url theme_uri " odoc.css" in
95+ [
96+ Html. meta ~a: [ Html. a_charset " utf-8" ] () ;
97+ Html. link ~rel: [ `Stylesheet ] ~href: odoc_css_uri () ;
98+ Html. meta
99+ ~a: [ Html. a_name " generator" ; Html. a_content " odoc %%VERSION%%" ]
100+ () ;
101+ Html. meta
102+ ~a:
103+ [
104+ Html. a_name " viewport" ;
105+ Html. a_content " width=device-width,initial-scale=1.0" ;
106+ ]
107+ () ;
108+ ]
109+
85110let page_creator ~config ~url ~uses_katex header breadcrumbs toc content =
86111 let theme_uri = Config. theme_uri config in
87112 let support_uri = Config. support_uri config in
@@ -93,21 +118,13 @@ let page_creator ~config ~url ~uses_katex header breadcrumbs toc content =
93118 Printf. sprintf " %s (%s)" url.name (String. concat " ." path)
94119 in
95120
96- let file_uri (base : Types.uri ) file =
97- match base with
98- | Types. Absolute uri -> uri ^ " /" ^ file
99- | Relative uri ->
100- let page = Url.Path. { kind = `File ; parent = uri; name = file } in
101- Link. href ~config ~resolve: (Current url) (Url. from_path page)
102- in
121+ let file_uri = file_uri ~config ~url in
103122 let search_uri uri =
104123 match uri with
105124 | Types. Absolute uri -> uri
106125 | Relative uri ->
107126 Link. href ~config ~resolve: (Current url) (Url. from_path uri)
108127 in
109- let odoc_css_uri = file_uri theme_uri " odoc.css" in
110- let highlight_js_uri = file_uri support_uri " highlight.pack.js" in
111128 let search_scripts =
112129 match search_uris with
113130 | [] -> []
@@ -142,30 +159,19 @@ let search_urls = %s;
142159 (Html. txt " " );
143160 ]
144161 in
145- let default_meta_elements =
146- [
147- Html. link ~rel: [ `Stylesheet ] ~href: odoc_css_uri () ;
148- Html. meta ~a: [ Html. a_charset " utf-8" ] () ;
149- Html. meta
150- ~a: [ Html. a_name " generator" ; Html. a_content " odoc %%VERSION%%" ]
151- () ;
152- Html. meta
153- ~a:
154- [
155- Html. a_name " viewport" ;
156- Html. a_content " width=device-width,initial-scale=1.0" ;
157- ]
158- () ;
159- Html. script ~a: [ Html. a_src highlight_js_uri ] (Html. txt " " );
160- Html. script (Html. txt " hljs.initHighlightingOnLoad();" );
161- ]
162- in
163162 let meta_elements =
164- if uses_katex then
165- let katex_css_uri = file_uri theme_uri " katex.min.css" in
166- let katex_js_uri = file_uri support_uri " katex.min.js" in
167- default_meta_elements
168- @ [
163+ let highlightjs_meta =
164+ let highlight_js_uri = file_uri support_uri " highlight.pack.js" in
165+ [
166+ Html. script ~a: [ Html. a_src highlight_js_uri ] (Html. txt " " );
167+ Html. script (Html. txt " hljs.initHighlightingOnLoad();" );
168+ ]
169+ in
170+ let katex_meta =
171+ if uses_katex then
172+ let katex_css_uri = file_uri theme_uri " katex.min.css" in
173+ let katex_js_uri = file_uri support_uri " katex.min.js" in
174+ [
169175 Html. link ~rel: [ `Stylesheet ] ~href: katex_css_uri () ;
170176 Html. script ~a: [ Html. a_src katex_js_uri ] (Html. txt " " );
171177 Html. script
@@ -185,7 +191,9 @@ let search_urls = %s;
185191 });
186192 | });
187193 ]
188- else default_meta_elements
194+ else []
195+ in
196+ default_meta_elements ~config ~url @ highlightjs_meta @ katex_meta
189197 in
190198 let meta_elements = meta_elements @ search_scripts in
191199 Html. head (Html. title (Html. txt title_string)) meta_elements
@@ -229,35 +237,11 @@ let path_of_module_of_source ppf url =
229237 | None -> ()
230238
231239let src_page_creator ~breadcrumbs ~config ~url ~header name content =
232- let theme_uri = Config. theme_uri config in
233240 let head : Html_types.head Html.elt =
234241 let title_string =
235242 Format. asprintf " Source: %s%a" name path_of_module_of_source url
236243 in
237- let file_uri (base : Types.uri ) file =
238- match base with
239- | Types. Absolute uri -> uri ^ " /" ^ file
240- | Relative uri ->
241- let page = Url.Path. { kind = `File ; parent = uri; name = file } in
242- Link. href ~config ~resolve: (Current url) (Url. from_path page)
243- in
244- let odoc_css_uri = file_uri theme_uri " odoc.css" in
245- let meta_elements =
246- [
247- Html. link ~rel: [ `Stylesheet ] ~href: odoc_css_uri () ;
248- Html. meta ~a: [ Html. a_charset " utf-8" ] () ;
249- Html. meta
250- ~a: [ Html. a_name " generator" ; Html. a_content " odoc %%VERSION%%" ]
251- () ;
252- Html. meta
253- ~a:
254- [
255- Html. a_name " viewport" ;
256- Html. a_content " width=device-width,initial-scale=1.0" ;
257- ]
258- () ;
259- ]
260- in
244+ let meta_elements = default_meta_elements ~config ~url in
261245 Html. head (Html. title (Html. txt title_string)) meta_elements
262246 in
263247 let body =
0 commit comments