mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-27 02:19:10 +00:00
lyx_1_6.py: fix dataloss in URL conversion routine
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21359 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a8cd9a4b8f
commit
c750446566
@ -521,20 +521,28 @@ def convert_url(document):
|
|||||||
'Convert url insets to url charstyles'
|
'Convert url insets to url charstyles'
|
||||||
if document.backend == "docbook":
|
if document.backend == "docbook":
|
||||||
return
|
return
|
||||||
r = re.compile(r'target\s+"(.*)"')
|
|
||||||
didone = False
|
didone = False
|
||||||
i = 0
|
i = 0
|
||||||
while True:
|
while True:
|
||||||
i = find_token(document.body, "\\begin_inset CommandInset url", i)
|
i = find_token(document.body, "\\begin_inset CommandInset url", i)
|
||||||
if i == -1:
|
if i == -1:
|
||||||
break
|
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)
|
j = find_token(document.body, "target", i)
|
||||||
if j == -1:
|
if j == -1:
|
||||||
document.warning("Malformed LyX document: Can't find target for url inset")
|
document.warning("Malformed LyX document: Can't find target for url inset")
|
||||||
i = j
|
i = j
|
||||||
continue
|
continue
|
||||||
m = r.match(document.body[j])
|
target = document.body[j][8:-1]
|
||||||
target = m.group(1)
|
|
||||||
k = find_token(document.body, "\\end_inset", j)
|
k = find_token(document.body, "\\end_inset", j)
|
||||||
if k == -1:
|
if k == -1:
|
||||||
document.warning("Malformed LyX document: Can't find end of url inset")
|
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",
|
newstuff = ["\\begin_inset Flex URL",
|
||||||
"status collapsed", "",
|
"status collapsed", "",
|
||||||
"\\begin_layout Standard",
|
"\\begin_layout Standard",
|
||||||
|
"",
|
||||||
target,
|
target,
|
||||||
"\\end_layout",
|
"\\end_layout",
|
||||||
""]
|
""]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user