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()