From 480ae7f22e38934da5d1a3e0ae6c5a71794f7eb4 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Thu, 5 Dec 2024 22:01:01 +0100 Subject: [PATCH] Account for extensions when creating a LyX archive LyX archives created after importing a LaTeX document may not include bibliography style and catalog files. This is because tex2lyx does not remove extensions, but the lyxpak script expects files without extensions. So, teach lyxpak to also take possible extensions into account. Fixes #13129 --- lib/scripts/lyxpak.py | 15 ++++++++++----- status.24x | 3 +++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/scripts/lyxpak.py b/lib/scripts/lyxpak.py index 07091f208c..59ff89b821 100755 --- a/lib/scripts/lyxpak.py +++ b/lib/scripts/lyxpak.py @@ -191,8 +191,11 @@ def gather_files(curfile, incfiles, lyx2lyx): file = match.group(3).strip(b'"') if file.startswith(b"bibtotoc,"): file = file[9:] + ext = os.path.splitext(file)[-1] + if ext != b'.bst': + file = file + b'.bst' if not os.path.isabs(file): - file = os.path.join(curdir, file + b'.bst') + file = os.path.join(curdir, file) if os.path.exists(unicode(file, 'utf-8')): incfiles.append(abspath(file)) i += 1 @@ -204,10 +207,12 @@ def gather_files(curfile, incfiles, lyx2lyx): bibfiles = match.group(3).strip(b'"').split(b',') j = 0 while j < len(bibfiles): - if os.path.isabs(bibfiles[j]): - file = bibfiles[j] + b'.bib' - else: - file = os.path.join(curdir, bibfiles[j] + b'.bib') + file = bibfiles[j] + ext = os.path.splitext(file)[-1] + if ext != b'.bib': + file = file + b'.bib' + if not os.path.isabs(file): + file = os.path.join(curdir, file) if os.path.exists(unicode(file, 'utf-8')): incfiles.append(abspath(file)) j += 1 diff --git a/status.24x b/status.24x index 621dd878e0..e40b3fe522 100644 --- a/status.24x +++ b/status.24x @@ -79,6 +79,9 @@ What's new - Fix tabular styles on systems with blanks in system directory path. +- Fix inclusion of bibliography files in a LyX archive when the document + was imported from a LaTeX source (bug 13129). + * USER INTERFACE