src/html.cpp

changeset 22
a9230f197e61
parent 20
8639ccd855ba
child 26
0b3a92df96db
equal deleted inserted replaced
21:bc8b76ca9ee9 22:a9230f197e61
30 30
31 namespace html { 31 namespace html {
32 static constexpr const char* weekdays[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}; 32 static constexpr const char* weekdays[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
33 33
34 static unsigned indentation; 34 static unsigned indentation;
35 static const char *tabs = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; 35 static const char *tabs = " ";
36 static void indent(int change = 0) { 36 static void indent(int change = 0) {
37 indentation += change; 37 indentation += change;
38 fwrite(tabs, 1, indentation, stdout); 38 fwrite(tabs, 4, indentation, stdout);
39 } 39 }
40 40
41 static std::string encode(const std::string &data) { 41 static std::string encode(const std::string &data) {
42 std::string buffer; 42 std::string buffer;
43 buffer.reserve(data.size()+16); 43 buffer.reserve(data.size()+16);
127 127
128 void html::close(bool fragment) { 128 void html::close(bool fragment) {
129 if (fragment) { 129 if (fragment) {
130 puts("</div>"); 130 puts("</div>");
131 } else { 131 } else {
132 puts("\t\t</div>\n\t</body>\n</html>"); 132 puts(" </div>\n </body>\n</html>");
133 } 133 }
134 } 134 }
135 135
136 void html::h1(const std::string& heading) { 136 void html::h1(const std::string& heading) {
137 indent(); 137 indent();

mercurial