Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[html] display title/aria-label/caption/summary #2146

Merged
merged 5 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading