]> git.lyx.org Git - features.git/commitdiff
lyx_1_6.py: fix dataloss in URL conversion routine
authorUwe Stöhr <uwestoehr@web.de>
Thu, 1 Nov 2007 22:17:54 +0000 (22:17 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Thu, 1 Nov 2007 22:17:54 +0000 (22:17 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21359 a592a061-630c-0410-9148-cb99ea01b6c8

lib/lyx2lyx/lyx_1_6.py

index c5fea14fefd4acc4eb5292d382b23eada77f254a..1290ca9c2b98ae65171d52186e304da6bdc880c9 100644 (file)
@@ -521,20 +521,28 @@ def convert_url(document):
     'Convert url insets to url charstyles'
     if document.backend == "docbook":
       return
-    r = re.compile(r'target\s+"(.*)"')
     didone = False
     i = 0
     while True:
       i = find_token(document.body, "\\begin_inset CommandInset url", i)
       if i == -1:
         break
+      n = find_token(document.body, "name", i)
+      if n == i + 2:
+        # place the URL name in typewriter before the new URL insert
+        # grab the name 'bla' from the e.g. the line 'name "bla"',
+        # therefore start with the 6th character
+        name = document.body[n][6:-1]
+        newname = ["\\begin_layout Standard",
+          name + " "]
+        document.body[i-1:i-1] = newname
+        i = i + 1
       j = find_token(document.body, "target", i)
       if j == -1:
         document.warning("Malformed LyX document: Can't find target for url inset")
         i = j
         continue
-      m = r.match(document.body[j])
-      target = m.group(1)
+      target = document.body[j][8:-1]
       k = find_token(document.body, "\\end_inset", j)
       if k == -1:
         document.warning("Malformed LyX document: Can't find end of url inset")
@@ -543,6 +551,7 @@ def convert_url(document):
       newstuff = ["\\begin_inset Flex URL",
         "status collapsed", "", 
         "\\begin_layout Standard",
+        "",
         target,
         "\\end_layout",
         ""]