-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender.c
More file actions
46 lines (39 loc) · 908 Bytes
/
render.c
File metadata and controls
46 lines (39 loc) · 908 Bytes
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
/* SPDX-License-Identifier: MIT */
/* SPDX-FileCopyrightText: (c) Copyright 2024 Andrew Bower <andrew@bower.uk> */
#include "config.h"
#include "render.h"
enum render_state {
STATE_NEWLINE,
STATE_NEWLINE2,
STATE_NEWLINE3PLUS,
STATE_SPACE,
STATE_SPACE2PLUS,
STATE_TEXT,
};
enum render_state state = STATE_NEWLINE;
void render_element(const char8_t *tag, bool end, const struct render_elem *rendering) {
if (opt.render_mode == RENDER_MODE_LITERAL)
return;
if (!rendering)
rendering = get_rendering(tag);
if (rendering) {
switch (rendering->spacing) {
case SPACING_NONE:
break;
case SPACING_PARA:
puts("");
break;
case SPACING_NEWLINE:
if (!end)
puts("");
break;
case SPACING_SPACE:
if (!end)
putchar(' ');
break;
}
}
}
void render_text(const char8_t *text) {
fputs((char *) text, stdout);
}