@@ -82,6 +82,31 @@ let html_of_breadcrumbs (breadcrumbs : Types.breadcrumb list) =
82
82
make_navigation ~up_url: up.href
83
83
(List. rev html @ sep @ [ Html. txt current.name ])
84
84
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. link ~rel: [ `Stylesheet ] ~href: odoc_css_uri () ;
97
+ Html. meta ~a: [ Html. a_charset " utf-8" ] () ;
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
+
85
110
let page_creator ~config ~url ~uses_katex header breadcrumbs toc content =
86
111
let theme_uri = Config. theme_uri config in
87
112
let support_uri = Config. support_uri config in
@@ -93,21 +118,13 @@ let page_creator ~config ~url ~uses_katex header breadcrumbs toc content =
93
118
Printf. sprintf " %s (%s)" url.name (String. concat " ." path)
94
119
in
95
120
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
103
122
let search_uri uri =
104
123
match uri with
105
124
| Types. Absolute uri -> uri
106
125
| Relative uri ->
107
126
Link. href ~config ~resolve: (Current url) (Url. from_path uri)
108
127
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
111
128
let search_scripts =
112
129
match search_uris with
113
130
| [] -> []
@@ -142,30 +159,19 @@ let search_urls = %s;
142
159
(Html. txt " " );
143
160
]
144
161
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
163
162
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
+ [
169
175
Html. link ~rel: [ `Stylesheet ] ~href: katex_css_uri () ;
170
176
Html. script ~a: [ Html. a_src katex_js_uri ] (Html. txt " " );
171
177
Html. script
@@ -185,7 +191,9 @@ let search_urls = %s;
185
191
});
186
192
| });
187
193
]
188
- else default_meta_elements
194
+ else []
195
+ in
196
+ default_meta_elements ~config ~url @ highlightjs_meta @ katex_meta
189
197
in
190
198
let meta_elements = meta_elements @ search_scripts in
191
199
Html. head (Html. title (Html. txt title_string)) meta_elements
@@ -229,35 +237,11 @@ let path_of_module_of_source ppf url =
229
237
| None -> ()
230
238
231
239
let src_page_creator ~breadcrumbs ~config ~url ~header name content =
232
- let theme_uri = Config. theme_uri config in
233
240
let head : Html_types.head Html.elt =
234
241
let title_string =
235
242
Format. asprintf " Source: %s%a" name path_of_module_of_source url
236
243
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
261
245
Html. head (Html. title (Html. txt title_string)) meta_elements
262
246
in
263
247
let body =
0 commit comments