On Friday 11 May 2007 20:43:46 José Matos wrote:
> On Friday 11 May 2007 17:47:26 Richard Heck wrote:
> > I don't see any such option, but then I don't see this behavior on
> > Linux, either. The dialog opens up pretty much immediately, and I do
> > have a networked directory under /home/rgheck/.
> >
> > By the way, in experimenting, I tried opening the kluwer.lyx template,
> > and I got a lyx2lyx error.
>
>   I can reproduce the problem, I know what is wrong and I will search for a
> solution. :-)

  I send attached the patch that fixes it. I think this is the right solution, 
if not please shout. :-)

  The problem was the line
\bibitem [\protect\citeauthoryear{Surname-1 et al.}{year}]{PaperI}

  that confused the parser since the optional argument has curly brackets 
inside.

> > Richard

-- 
José Abílio
Index: lib/lyx2lyx/lyx_1_5.py
===================================================================
--- lib/lyx2lyx/lyx_1_5.py	(revision 18269)
+++ lib/lyx2lyx/lyx_1_5.py	(working copy)
@@ -340,19 +340,24 @@
 
 This must be called after convert_commandparams.
 """
-    regex = re.compile(r'\S+\s*(\[[^\[\{]*\])?(\{[^}]*\})')
     i = 0
     while 1:
         i = find_token(document.body, "\\bibitem", i)
         if i == -1:
             break
-        match = re.match(regex, document.body[i])
-        option = match.group(1)
-        argument = match.group(2)
+        j = document.body[i].find('[') + 1
+        k = document.body[i].rfind(']')
+        if j == 0: # No optional argument found
+            option = None
+        else:
+            option = document.body[i][j:k]
+        j = document.body[i].rfind('{') + 1
+        k = document.body[i].rfind('}')
+        argument = document.body[i][j:k]
         lines = ['\\begin_inset LatexCommand bibitem']
         if option != None:
-            lines.append('label "%s"' % option[1:-1].replace('"', '\\"'))
-        lines.append('key "%s"' % argument[1:-1].replace('"', '\\"'))
+            lines.append('label "%s"' % option.replace('"', '\\"'))
+        lines.append('key "%s"' % argument.replace('"', '\\"'))
         lines.append('')
         lines.append('\\end_inset')
         document.body[i:i+1] = lines

Reply via email to