2222#include < mutex>
2323
2424namespace odr ::internal::html {
25-
2625namespace {
2726
2827void front (const Document &document, const WritingState &state) {
28+ HtmlWriter &out = state.out ();
29+
2930 bool paged_content = ((document.document_type () == DocumentType::text) &&
3031 state.config ().text_document_margin ) ||
3132 document.document_type () == DocumentType::presentation ||
3233 document.document_type () == DocumentType::drawing;
3334
34- state.out ().write_begin ();
35- state.out ().write_header_begin ();
36- state.out ().write_header_charset (" UTF-8" );
37- state.out ().write_header_target (" _blank" );
38- state.out ().write_header_title (" odr" );
35+ out.write_begin ();
36+ out.write_header_begin ();
37+ out.write_header_charset (" UTF-8" );
38+ out.write_header_target (" _blank" );
39+ out.write_header_title (" odr" );
40+ out.write_header_meta (" color-scheme" , " light dark" );
3941 if (paged_content) {
40- state. out () .write_header_viewport (" width=device-width,user-scalable=yes" );
42+ out.write_header_viewport (" width=device-width,user-scalable=yes" );
4143 } else {
42- state. out () .write_header_viewport (
44+ out.write_header_viewport (
4345 " width=device-width,initial-scale=1.0,user-scalable=yes" );
4446 }
4547
@@ -52,11 +54,11 @@ void front(const Document &document, const WritingState &state) {
5254 state.config ().resource_locator (odr_css_resource, state.config ());
5355 state.resources ().emplace_back (std::move (odr_css_resource), odr_css_location);
5456 if (odr_css_location.has_value ()) {
55- state. out () .write_header_style (odr_css_location.value ());
57+ out.write_header_style (odr_css_location.value ());
5658 } else {
57- state. out () .write_header_style_begin ();
58- util::stream::pipe (*odr_css_file.stream (), state. out () .out ());
59- state. out () .write_header_style_end ();
59+ out.write_header_style_begin ();
60+ util::stream::pipe (*odr_css_file.stream (), out.out ());
61+ out.write_header_style_end ();
6062 }
6163
6264 if (document.document_type () == DocumentType::spreadsheet) {
@@ -72,15 +74,15 @@ void front(const Document &document, const WritingState &state) {
7274 state.resources ().emplace_back (std::move (odr_spreadsheet_css_resource),
7375 odr_spreadsheet_css_location);
7476 if (odr_spreadsheet_css_location.has_value ()) {
75- state. out () .write_header_style (odr_spreadsheet_css_location.value ());
77+ out.write_header_style (odr_spreadsheet_css_location.value ());
7678 } else {
77- state. out () .write_header_style_begin ();
78- util::stream::pipe (*odr_spreadsheet_css_file.stream (), state. out () .out ());
79- state. out () .write_header_style_end ();
79+ out.write_header_style_begin ();
80+ util::stream::pipe (*odr_spreadsheet_css_file.stream (), out.out ());
81+ out.write_header_style_end ();
8082 }
8183 }
8284
83- state. out () .write_header_end ();
85+ out.write_header_end ();
8486
8587 std::string body_clazz = " odr-body" ;
8688 if (paged_content) {
@@ -101,22 +103,23 @@ void front(const Document &document, const WritingState &state) {
101103 }
102104 }
103105
104- state. out () .write_body_begin (HtmlElementOptions ().set_class (body_clazz));
106+ out.write_body_begin (HtmlElementOptions ().set_class (body_clazz));
105107
106108 if (paged_content) {
107- state.out ().write_element_begin (
108- " div" , HtmlElementOptions ().set_class (" odr-pages" ));
109+ out.write_element_begin (" div" , HtmlElementOptions ().set_class (" odr-pages" ));
109110 }
110111}
111112
112113void back (const Document &document, const WritingState &state) {
114+ HtmlWriter &out = state.out ();
115+
113116 bool paged_content = ((document.document_type () == DocumentType::text) &&
114117 state.config ().text_document_margin ) ||
115118 document.document_type () == DocumentType::presentation ||
116119 document.document_type () == DocumentType::drawing;
117120
118121 if (paged_content) {
119- state. out () .write_element_end (" div" );
122+ out.write_element_end (" div" );
120123 }
121124
122125 auto odr_js_file = File (
@@ -128,15 +131,15 @@ void back(const Document &document, const WritingState &state) {
128131 state.config ().resource_locator (odr_js_resource, state.config ());
129132 state.resources ().emplace_back (std::move (odr_js_resource), odr_js_location);
130133 if (odr_js_location.has_value ()) {
131- state. out () .write_script (odr_js_location.value ());
134+ out.write_script (odr_js_location.value ());
132135 } else {
133- state. out () .write_script_begin ();
134- util::stream::pipe (*odr_js_file.stream (), state. out () .out ());
135- state. out () .write_script_end ();
136+ out.write_script_begin ();
137+ util::stream::pipe (*odr_js_file.stream (), out.out ());
138+ out.write_script_end ();
136139 }
137140
138- state. out () .write_body_end ();
139- state. out () .write_end ();
141+ out.write_body_end ();
142+ out.write_end ();
140143}
141144
142145std::string fill_path_variables (const std::string &path,
@@ -407,7 +410,6 @@ class PageHtmlFragment final : public HtmlFragmentBase {
407410};
408411
409412} // namespace
410-
411413} // namespace odr::internal::html
412414
413415namespace odr ::internal {
0 commit comments