@@ -102,11 +102,31 @@ template <typename T> inline bool vec_has(const vector<T> &vec, T val){
102
102
return std::find (vec.begin (), vec.end (), val) != vec.end ();
103
103
}
104
104
105
- template <typename T> inline bool node_in (myhtml_tree_node_t * node, T tag){
106
- while (node){
107
- if (node->tag_id == tag) return true ;
108
- node = node->parent ;
109
- }
105
+ template <typename ...T> inline bool node_in (myhtml_tree_node_t * node, T... tags){
106
+ while ((node = node->parent ))
107
+ for (myhtml_tag_id_t tag : {tags...})
108
+ if (node->tag_id == tag) return true ;
109
+
110
+ return false ;
111
+ }
112
+
113
+ template <typename ...T> inline bool node_before (myhtml_tree_node_t * node, T... tags){
114
+ while ((node = node->next ) && node->tag_id <= 0x003 );
115
+
116
+ if (node)
117
+ for (myhtml_tag_id_t tag : {tags...})
118
+ if (node->tag_id == tag) return true ;
119
+
120
+ return false ;
121
+ }
122
+
123
+ template <typename ...T> inline bool node_after (myhtml_tree_node_t * node, T... tags){
124
+ while ((node = node->prev ) && node->tag_id <= 0x003 );
125
+
126
+ if (node)
127
+ for (myhtml_tag_id_t tag : {tags...})
128
+ if (node->tag_id == tag) return true ;
129
+
110
130
return false ;
111
131
}
112
132
@@ -199,6 +219,12 @@ static pair<const function<void(myhtml_tree_node_t*, string&)>, const function<v
199
219
case MyHTML_TAG_UL:
200
220
rendered += " \n " ;
201
221
break ;
222
+ case MyHTML_TAG_TH:
223
+ case MyHTML_TAG_TD:
224
+ if (node_before (node_iter, MyHTML_TAG_TH, MyHTML_TAG_TD)){
225
+ rendered += " \t " ;
226
+ }
227
+ break ;
202
228
}
203
229
204
230
if (vec_has (breaking, node_iter->tag_id )){ // <br/>
0 commit comments