| 262 | } |
| 263 | |
| 264 | size_t extract(const char * __restrict src, size_t size, char * __restrict dst) |
| 265 | { |
| 266 | /** There are the following rules: |
| 267 | * - comments are removed with all their content; |
| 268 | * - elements 'script' and 'style' are removed with all their content; |
| 269 | * - for other elements tags are removed but content is processed as text; |
| 270 | * - CDATA should be copied verbatim; |
| 271 | */ |
| 272 | |
| 273 | const char * end = src + size; |
| 274 | char * dst_begin = dst; |
| 275 | |
| 276 | while (src < end) |
| 277 | { |
| 278 | bool needs_whitespace = dst != dst_begin && dst[-1] != ' '; |
| 279 | copyText(src, end, dst, needs_whitespace); |
| 280 | |
| 281 | processComment(src, end) |
| 282 | || processCDATA(src, end, dst) |
| 283 | || processElementAndSkipContent(src, end, "script") |
| 284 | || processElementAndSkipContent(src, end, "style") |
| 285 | || skipTag(src, end); |
| 286 | } |
| 287 | |
| 288 | return dst - dst_begin; |
| 289 | } |
| 290 | |
| 291 | } |
| 292 |
no test coverage detected