From 813da105fe73d33c95c9d96831cf7fcb4f28efe7 Mon Sep 17 00:00:00 2001 From: James Kent Date: Thu, 15 Oct 2026 07:41:54 -0500 Subject: [PATCH] Parse inline tables when a HighWire page has no public URL Current science.org pages are identified as HighWire but carry no citation_public_url meta tag. HighWireSource.parse_article indexed that tag unconditionally, so parsing raised TypeError and the article got no extraction. When the tag is missing, the tables printed in the page are parsed with the same helper DefaultSource uses for inline tables. The T.expansion download path is unchanged when the tag is present. Co-Authored-By: Claude Opus 5.5 --- ace/sources.py | 13 ++++++++++-- ace/tests/data/highwire_inline_table.html | 26 +++++++++++++++++++++++ ace/tests/test_ace.py | 16 ++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 ace/tests/data/highwire_inline_table.html diff --git a/ace/sources.py b/ace/sources.py index f5a04f4..2102564 100644 --- a/ace/sources.py +++ b/ace/sources.py @@ -1413,9 +1413,18 @@ def parse_article(self, html, pmid=None, **kwargs): if not soup: return False + # Current pages carry no public URL and print their tables inline. + public_url = soup.find('meta', {'name': 'citation_public_url'}) + if public_url is None: + tables = [] + self._append_leaf_candidate_tables(soup, tables) + self.article.tables = tables + if not tables: + self.article.missing_source = True + return self.article + # To download tables, we need the content URL and the number of tables - content_url = soup.find('meta', { - 'name': 'citation_public_url'})['content'] + content_url = public_url['content'] n_tables = len(soup.find_all('span', class_='table-label')) diff --git a/ace/tests/data/highwire_inline_table.html b/ace/tests/data/highwire_inline_table.html new file mode 100644 index 0000000..35a1fe3 --- /dev/null +++ b/ace/tests/data/highwire_inline_table.html @@ -0,0 +1,26 @@ + + + + + + +Inline table without a public URL + + +
+

Inline table without a public URL

+
+

Activation peaks are listed in Table 1.

+
+Table 1 + + + + + +
Peak coordinates
RegionxyzPeak Z
Left amygdala-22-6-164.1
Right insula361823.8
+
+
+
+ + diff --git a/ace/tests/test_ace.py b/ace/tests/test_ace.py index 0ec7835..ff644cb 100644 --- a/ace/tests/test_ace.py +++ b/ace/tests/test_ace.py @@ -557,6 +557,22 @@ def test_sciencedirect_combined_coordinate_column_source(test_weird_data_path, s assert _count_valid_activations(article.tables) >= 1 +def test_highwire_page_without_public_url_parses_inline_tables(test_data_path, source_manager): + # Current science.org pages have no citation_public_url, so the expansion + # download is skipped and the table comes from the page itself. + html = open(join(test_data_path, 'highwire_inline_table.html')).read() + source = source_manager.identify_source(html) + assert source.__class__.__name__ == 'HighWireSource' + + article = source.parse_article(html, pmid='99900001', skip_metadata=True) + + assert article is not None + assert len(article.tables) == 1 + table = article.tables[0] + assert table.position == 1 + assert table.n_activations == 2 + + def test_springer_inline_table_fallback_source(test_weird_data_path, source_manager): pmid = '27007121' html = open(join(test_weird_data_path, pmid + '.html')).read()