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

fix extract_texkeys_and_urls_from_pdf #106

Merged
merged 1 commit into from
Aug 7, 2023
Merged
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
10 changes: 7 additions & 3 deletions refextract/references/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import logging

from PyPDF2 import PdfFileReader
from PyPDF2.generic import ByteStringObject

from .regexs import re_reference_in_dest

Expand Down Expand Up @@ -57,9 +58,12 @@ def extract_texkeys_and_urls_from_pdf(pdf_file):
LOGGER.debug(u"PDF: Internal PyPDF2 error, no TeXkeys returned.")
return []
# not all named destinations point to references
refs = [
dest for dest in destinations.items() if re_reference_in_dest.match(dest[0])
]
refs = []
for destination in destinations.items():
destination_key = destination[0].decode("utf-8") if isinstance(destination[0], ByteStringObject) else destination[0]
match = re_reference_in_dest.match(destination_key)
if match:
refs.append(destination)
try:
if _destinations_in_two_columns(pdf, refs):
LOGGER.debug(u"PDF: Using two-column layout")
Expand Down
Loading