selectolax 0.3.28__cp312-cp312-win32.whl → 0.3.29__cp312-cp312-win32.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of selectolax might be problematic. Click here for more details.
- selectolax/__init__.py +1 -1
- selectolax/lexbor/node.pxi +16 -4
- selectolax/lexbor.c +1570 -1438
- selectolax/lexbor.cp312-win32.pyd +0 -0
- selectolax/lexbor.pyi +2 -2
- selectolax/lexbor.pyx +4 -2
- selectolax/modest/node.pxi +21 -5
- selectolax/parser.c +1751 -1597
- selectolax/parser.cp312-win32.pyd +0 -0
- selectolax/parser.pyi +13 -20
- selectolax/parser.pyx +4 -2
- {selectolax-0.3.28.dist-info → selectolax-0.3.29.dist-info}/METADATA +3 -2
- selectolax-0.3.29.dist-info/RECORD +26 -0
- {selectolax-0.3.28.dist-info → selectolax-0.3.29.dist-info}/WHEEL +1 -1
- selectolax-0.3.28.dist-info/RECORD +0 -26
- {selectolax-0.3.28.dist-info → selectolax-0.3.29.dist-info/licenses}/LICENSE +0 -0
- {selectolax-0.3.28.dist-info → selectolax-0.3.29.dist-info}/top_level.txt +0 -0
selectolax/__init__.py
CHANGED
selectolax/lexbor/node.pxi
CHANGED
|
@@ -416,9 +416,14 @@ cdef class LexborNode:
|
|
|
416
416
|
node = node.next
|
|
417
417
|
|
|
418
418
|
|
|
419
|
-
def unwrap(self):
|
|
419
|
+
def unwrap(self, delete_empty=False):
|
|
420
420
|
"""Replace node with whatever is inside this node.
|
|
421
421
|
|
|
422
|
+
Parameters
|
|
423
|
+
----------
|
|
424
|
+
delete_empty : bool, default False
|
|
425
|
+
If True, removes empty tags.
|
|
426
|
+
|
|
422
427
|
Examples
|
|
423
428
|
--------
|
|
424
429
|
|
|
@@ -426,9 +431,12 @@ cdef class LexborNode:
|
|
|
426
431
|
>>> tree.css_first('i').unwrap()
|
|
427
432
|
>>> tree.html
|
|
428
433
|
'<html><head></head><body><div>Hello world!</div></body></html>'
|
|
429
|
-
|
|
434
|
+
|
|
435
|
+
Note: by default, empty tags are ignored, use "delete_empty" to change this.
|
|
430
436
|
"""
|
|
431
437
|
if self.node.first_child == NULL:
|
|
438
|
+
if delete_empty:
|
|
439
|
+
lxb_dom_node_destroy(<lxb_dom_node_t *> self.node)
|
|
432
440
|
return
|
|
433
441
|
cdef lxb_dom_node_t* next_node;
|
|
434
442
|
cdef lxb_dom_node_t* current_node;
|
|
@@ -445,7 +453,7 @@ cdef class LexborNode:
|
|
|
445
453
|
lxb_dom_node_insert_before(self.node, self.node.first_child)
|
|
446
454
|
lxb_dom_node_destroy(<lxb_dom_node_t *> self.node)
|
|
447
455
|
|
|
448
|
-
def unwrap_tags(self, list tags):
|
|
456
|
+
def unwrap_tags(self, list tags, delete_empty = False):
|
|
449
457
|
"""Unwraps specified tags from the HTML tree.
|
|
450
458
|
|
|
451
459
|
Works the same as the ``unwrap`` method, but applied to a list of tags.
|
|
@@ -454,6 +462,8 @@ cdef class LexborNode:
|
|
|
454
462
|
----------
|
|
455
463
|
tags : list
|
|
456
464
|
List of tags to remove.
|
|
465
|
+
delete_empty : bool, default False
|
|
466
|
+
If True, removes empty tags.
|
|
457
467
|
|
|
458
468
|
Examples
|
|
459
469
|
--------
|
|
@@ -462,11 +472,13 @@ cdef class LexborNode:
|
|
|
462
472
|
>>> tree.body.unwrap_tags(['i','a'])
|
|
463
473
|
>>> tree.body.html
|
|
464
474
|
'<body><div>Hello world!</div></body>'
|
|
475
|
+
|
|
476
|
+
Note: by default, empty tags are ignored, use "delete_empty" to change this.
|
|
465
477
|
"""
|
|
466
478
|
|
|
467
479
|
for tag in tags:
|
|
468
480
|
for element in self.css(tag):
|
|
469
|
-
element.unwrap()
|
|
481
|
+
element.unwrap(delete_empty)
|
|
470
482
|
|
|
471
483
|
|
|
472
484
|
def traverse(self, include_text=False):
|