@@ -21,9 +21,17 @@ void Text::EmphasisNode::render_to_html(StringBuilder& builder) const
21
21
builder.append ((strong) ? " </strong>" : " </em>" );
22
22
}
23
23
24
- void Text::EmphasisNode::render_for_terminal (StringBuilder&) const
24
+ void Text::EmphasisNode::render_for_terminal (StringBuilder& builder ) const
25
25
{
26
- // FIXME.
26
+ if (strong) {
27
+ builder.append (" \e[1m" );
28
+ child->render_for_terminal (builder);
29
+ builder.append (" \e[22m" );
30
+ } else {
31
+ builder.append (" \e[3m" );
32
+ child->render_for_terminal (builder);
33
+ builder.append (" \e[23m" );
34
+ }
27
35
}
28
36
29
37
size_t Text::EmphasisNode::terminal_length () const
@@ -38,9 +46,11 @@ void Text::CodeNode::render_to_html(StringBuilder& builder) const
38
46
builder.append (" </code>" );
39
47
}
40
48
41
- void Text::CodeNode::render_for_terminal (StringBuilder&) const
49
+ void Text::CodeNode::render_for_terminal (StringBuilder& builder ) const
42
50
{
43
- // FIXME.
51
+ builder.append (" \e[1m" );
52
+ code->render_for_terminal (builder);
53
+ builder.append (" \e[22m" );
44
54
}
45
55
46
56
size_t Text::CodeNode::terminal_length () const
@@ -53,9 +63,11 @@ void Text::TextNode::render_to_html(StringBuilder& builder) const
53
63
builder.append (escape_html_entities (text));
54
64
}
55
65
56
- void Text::TextNode::render_for_terminal (StringBuilder&) const
66
+ void Text::TextNode::render_for_terminal (StringBuilder& builder ) const
57
67
{
58
- // FIXME.
68
+ String text_copy = text;
69
+ text_copy.replace (" \n " , " " );
70
+ builder.append (text_copy);
59
71
}
60
72
61
73
size_t Text::TextNode::terminal_length () const
@@ -80,9 +92,25 @@ void Text::LinkNode::render_to_html(StringBuilder& builder) const
80
92
}
81
93
}
82
94
83
- void Text::LinkNode::render_for_terminal (StringBuilder&) const
95
+ void Text::LinkNode::render_for_terminal (StringBuilder& builder ) const
84
96
{
85
- // FIXME.
97
+ StringBuilder href_builder;
98
+ href->render_for_terminal (href_builder);
99
+ String href_string = href_builder.build ();
100
+
101
+ bool is_linked = href_string.contains (" ://" );
102
+ if (is_linked) {
103
+ builder.append (" \e]8;;" );
104
+ builder.append (href_string);
105
+ builder.append (" \e\\ " );
106
+ }
107
+
108
+ text->render_for_terminal (builder);
109
+
110
+ if (is_linked) {
111
+ builder.appendff (" <{}>" , href_string);
112
+ builder.append (" \033 ]8;;\033\\ " );
113
+ }
86
114
}
87
115
88
116
size_t Text::LinkNode::terminal_length () const
@@ -97,9 +125,11 @@ void Text::MultiNode::render_to_html(StringBuilder& builder) const
97
125
}
98
126
}
99
127
100
- void Text::MultiNode::render_for_terminal (StringBuilder&) const
128
+ void Text::MultiNode::render_for_terminal (StringBuilder& builder ) const
101
129
{
102
- // FIXME.
130
+ for (auto & child : children) {
131
+ child.render_for_terminal (builder);
132
+ }
103
133
}
104
134
105
135
size_t Text::MultiNode::terminal_length () const
0 commit comments