Skip to content

Commit

Permalink
fix extract_texkeys_and_urls_from_pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
MJedr committed Aug 4, 2023
1 parent 16e0a8e commit 4e1525c
Showing 1 changed file with 7 additions and 3 deletions.
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

0 comments on commit 4e1525c

Please sign in to comment.