Пример #1
0
static int isWhitespaceRun(DFNode *run)
{
    for (DFNode *child = run->first; child != NULL; child = child->next) {
        switch (child->tag) {
            case WORD_RPR:
                break;
            case WORD_T: {
                char *str = DFNodeTextToString(child);
                int isWhitespace = DFStringIsWhitespace(str);
                free(str);
                if (!isWhitespace)
                    return 0;
                break;
            }
            default:
                return 0;
        }
    }
    return 1;
}
Пример #2
0
void DFRemoveWhitespaceNodes(DFNode *node)
{
    DFNode *next;
    for (DFNode *child = node->first; child != NULL; child = next) {
        next  = child->next;
        switch (child->tag) {
            case DOM_TEXT:
            case DOM_CDATA: {
                if (DFStringIsWhitespace(child->value))
                    DFRemoveNode(child);
                break;
            }
            case DOM_COMMENT:
                DFRemoveNode(child);
                break;
            default:
                DFRemoveWhitespaceNodes(child);
                break;
        }
    }
}
Пример #3
0
int DFIsWhitespaceNode(DFNode *node)
{
    return ((node->tag == DOM_TEXT) && DFStringIsWhitespace(node->value));
}