Skip to content

Commit

Permalink
Merge pull request #2146 from midichef/html_captions
Browse files Browse the repository at this point in the history
[html] display title/aria-label/caption/summary
  • Loading branch information
anjakefala authored Dec 7, 2023
2 parents 9fd728b + 243db37 commit 6bf20c8
Show file tree
Hide file tree
Showing 2 changed files with 8 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
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
5 changes: 5 additions & 0 deletions visidata/loaders/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class HtmlTablesSheet(IndexSheet):
Column('tag', width=0, getter=lambda col,row: row.html.tag),
Column('id', getter=lambda col,row: row.html.attrib.get('id')),
Column('classes', getter=lambda col,row: row.html.attrib.get('class')),
Column('title', getter=lambda col,row: row.html.attrib.get('title')),
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 6bf20c8

Please sign in to comment.