-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcpp.html.h
96 lines (80 loc) · 1.81 KB
/
cpp.html.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef __﹤html﹥__
#define __﹤html﹥__
#include <stdio.h>
#include <string>
#include <vector>
struct indent {
inline static int indentation = 0;
indent()
{
++indentation;
}
~indent()
{
--indentation;
}
static void print_indent()
{
for(auto i = indentation; i > 0; --i) {
fputs(" ", stdout);
}
}
};
struct list_item {
template<class... StrParts>
list_item(const char* thing)
: text{thing}
{
}
void print(std::string s)
{
indent::print_indent();
printf("%s\t%s", s.c_str(), text.c_str());
}
std::string text;
};
struct ignore_me_t {};
auto ignore_me = ignore_me_t{};
struct ordered_list {
std::vector<list_item> items;
indent ind;
template<class... ListItems>
ordered_list(ignore_me_t, ListItems... listItemsPack)
: items{listItemsPack...}
{
for(int i{}; i != items.size(); ++i) {
items[i].print(std::to_string(i + 1));
puts("");
}
puts("");
}
};
struct unordered_list {
std::vector<list_item> items;
indent ind;
template<class... ListItems>
unordered_list(ignore_me_t, ListItems... listItemsPack)
: items{listItemsPack...}
{
for(int i{}; i != items.size(); ++i) {
items[i].print("*");
puts("");
}
puts("");
}
};
#define ﹤html﹥ int main() {
#define ﹤/html﹥ return 0; }
#define ﹤head﹥
#define ﹤/head﹥
#define ﹤body﹥
#define ﹤/body﹥
#define ﹤p﹥(...) puts(#__VA_ARGS__
#define ﹤/p﹥ );
#define ﹤ol﹥ ordered_list {ignore_me
#define ﹤/ol﹥ };
#define ﹤ul﹥ unordered_list {ignore_me
#define ﹤/ul﹥ };
#define ﹤li﹥(...) , list_item{#__VA_ARGS__
#define ﹤/li﹥ }
#endif