@@ -149,8 +149,9 @@ cdef class LexborNode:
149149 If ``True``, apply ``str.strip()`` to each fragment before joining to
150150 remove surrounding whitespace. Defaults to ``False``.
151151 skip_empty : bool, optional
152- Exclude text nodes that ``lxb_dom_node_is_empty`` considers empty when
153- ``True``. Defaults to ``False``.
152+ Exclude text nodes whose content is only ASCII whitespace (space,
153+ tab, newline, form feed or carriage return) when ``True``.
154+ Defaults to ``False``.
154155
155156 Returns
156157 -------
@@ -174,7 +175,7 @@ cdef class LexborNode:
174175 if node.type == LXB_DOM_NODE_TYPE_TEXT:
175176 text = < unsigned char * > lexbor_str_data_noi(& (< lxb_dom_character_data_t * > node).data)
176177 if text != NULL :
177- if not skip_empty or not self ._is_empty_text_node (node):
178+ if not skip_empty or not is_empty_text_node (node):
178179 py_text = text.decode(_ENCODING)
179180 container.append(py_text)
180181 node = node.next
@@ -440,8 +441,9 @@ cdef class LexborNode:
440441 When ``True``, yield text nodes in addition to element nodes. Defaults
441442 to ``False``.
442443 skip_empty : bool, optional
443- When ``include_text`` is ``True``, ignore text nodes that
444- ``lxb_dom_node_is_empty`` deems empty. Defaults to ``False``.
444+ When ``include_text`` is ``True``, ignore text nodes made up solely
445+ of ASCII whitespace (space, tab, newline, form feed or carriage
446+ return). Defaults to ``False``.
445447
446448 Yields
447449 ------
@@ -457,7 +459,7 @@ cdef class LexborNode:
457459 if node.type == LXB_DOM_NODE_TYPE_TEXT and not include_text:
458460 node = node.next
459461 continue
460- if node.type == LXB_DOM_NODE_TYPE_TEXT and include_text and skip_empty and self ._is_empty_text_node (node):
462+ if node.type == LXB_DOM_NODE_TYPE_TEXT and include_text and skip_empty and is_empty_text_node (node):
461463 node = node.next
462464 continue
463465
@@ -594,8 +596,9 @@ cdef class LexborNode:
594596 When ``True``, include text nodes in the traversal sequence. Defaults
595597 to ``False``.
596598 skip_empty : bool, optional
597- Skip empty text nodes (as determined by ``lxb_dom_node_is_empty``)
598- when ``include_text`` is ``True``. Defaults to ``False``.
599+ Skip text nodes that contain only ASCII whitespace (space, tab,
600+ newline, form feed or carriage return) when ``include_text`` is
601+ ``True``. Defaults to ``False``.
599602
600603 Yields
601604 ------
@@ -609,7 +612,7 @@ cdef class LexborNode:
609612
610613 while node != NULL :
611614 if include_text or node.type != LXB_DOM_NODE_TYPE_TEXT:
612- if not skip_empty or not self ._is_empty_text_node (node):
615+ if not skip_empty or not is_empty_text_node (node):
613616 lxb_node = LexborNode.new(< lxb_dom_node_t * > node, self .parser)
614617 yield lxb_node
615618
@@ -1039,22 +1042,11 @@ cdef class LexborNode:
10391042 Returns
10401043 -------
10411044 bool
1042- ``True`` when the node is a text node and
1043- ``lxb_dom_node_is_empty`` reports that its parent subtree contains
1044- only whitespace ( or nothing ).
1045+ ``True`` when the node is a text node whose character data consists
1046+ only of ASCII whitespace characters ( space , tab , newline , form feed
1047+ or carriage return ).
10451048 """
1046- return self._is_empty_text_node(self.node )
1047-
1048- cdef inline bint _is_empty_text_node(self , lxb_dom_node_t *node ):
1049- if node.type != LXB_DOM_NODE_TYPE_TEXT:
1050- return False
1051-
1052- # lexbor's emptiness check walks children of the passed node; for a
1053- # text node we need to evaluate its parent so the text itself is
1054- # inspected.
1055- if node.parent != NULL :
1056- return lxb_dom_node_is_empty(node.parent)
1057- return lxb_dom_node_is_empty(node)
1049+ return is_empty_text_node(self.node )
10581050
10591051
10601052@cython.internal
0 commit comments