commit 54850146ea7c179e5a3295ac556a822e3954167a
Author: Enrico Forestieri <for...@lyx.org>
Date:   Tue Mar 25 20:06:02 2025 -0400

    Fix bug #13149
    
    Local layout files are not included in a LyX archive.
---
 lib/scripts/lyxpak.py | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/lib/scripts/lyxpak.py b/lib/scripts/lyxpak.py
index 59ff89b821..812e713837 100755
--- a/lib/scripts/lyxpak.py
+++ b/lib/scripts/lyxpak.py
@@ -44,6 +44,7 @@ re_input = 
re.compile(b'^(.*)\\\\(input|include){(\\s*)(.+)(\\s*)}.*$')
 re_ertinput = re.compile(b'^(input|include)({)(\\s*)(.+)(\\s*)}.*$')
 re_package = re.compile(b'^(.*)\\\\(usepackage){(\\s*)(.+)(\\s*)}.*$')
 re_class = re.compile(b'^(\\\\)(textclass)(\\s+)(.+)\\s*$')
+re_latexclass = 
re.compile(b'^(.*)\\\\(DeclareLaTeXClass)\\[(\\s*)(.+)(\\s*)\\].*$')
 re_norecur = 
re.compile(b'^(.*)\\\\(verbatiminput|lstinputlisting|includegraphics\\[*.*\\]*){(\\s*)(.+)(\\s*)}.*$')
 re_ertnorecur = 
re.compile(b'^(verbatiminput|lstinputlisting|includegraphics\\[*.*\\]*)({)(\\s*)(.+)(\\s*)}.*$')
 re_filename = re.compile(b'^(\\s*)(filename)(\\s+)(.+)\\s*$')
@@ -154,8 +155,23 @@ def gather_files(curfile, incfiles, lyx2lyx):
                 extlist = [b'.sty']
                 if not match:
                     match = re_class.match(lines[i])
-                    extlist = [b'.cls']
-                    if not match:
+                    if match:
+                        extlist = [b'.cls']
+                        file = match.group(4).strip(b'"')
+                        local_layout = os.path.join(curdir, file) + b'.layout'
+                        if os.path.exists(unicode(local_layout, 'utf-8')):
+                            if not abspath(local_layout) in incfiles:
+                                incfiles.append(abspath(local_layout))
+                                f = gzopen(local_layout)
+                                l = f.readlines()
+                                f.close()
+                                j = 0
+                                while j < len(l):
+                                    match = re_latexclass.match(l[j])
+                                    if match:
+                                        break
+                                    j += 1
+                    else:
                         if maybe_in_ert:
                             match = re_ertnorecur.match(lines[i])
                         else:
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to