Skip to content

Commit

Permalink
[html] show table's sibling h1-h6 tags
Browse files Browse the repository at this point in the history
  • Loading branch information
midichef committed Dec 7, 2023
1 parent 38e2e40 commit 243db37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/golden/pull2140.tsv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name rows cols id classes title aria_label caption summary
table_0 0 0 test_empty
links 0 5
name rows cols id classes title aria_label caption summary heading
table_0 0 0 test_empty
links 0 5
1 change: 1 addition & 0 deletions visidata/loaders/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class HtmlTablesSheet(IndexSheet):
Column('aria_label', getter=lambda col,row: row.html.attrib.get('aria-label')),
Column('caption', getter=lambda col,row: row.html.xpath('normalize-space(./caption)') if row.html.xpath('./caption') else None, cache=True),
Column('summary', getter=lambda col,row: row.html.attrib.get('summary')),
Column('heading', getter=lambda col,row: row.html.xpath('normalize-space(./preceding-sibling::*[self::h1 or self::h2 or self::h3 or self::h4 or self::h5 or self::h6][1])') or None, cache=True),
]
def iterload(self):
lxml = vd.importExternal('lxml')
Expand Down

0 comments on commit 243db37

Please sign in to comment.