From 10f7b8cb3556cbef68481fbcc30f86e88926f3e5 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Mon, 7 Jul 2008 16:12:32 +0000 Subject: [PATCH] Fix bug 4984: Revert Flex URL to InsetURL. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25477 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/lyx_1_6.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py index 138ccae588..8edcbed964 100644 --- a/lib/lyx2lyx/lyx_1_6.py +++ b/lib/lyx2lyx/lyx_1_6.py @@ -1116,6 +1116,36 @@ def revert_href(document): ["\\begin_inset CommandInset url", "LatexCommand url"] i = i + 2 +def revert_url(document): + 'Reverts Flex URL insets to old-style URL insets' + i = 0 + while True: + i = find_token(document.body, "\\begin_inset Flex URL", i) + if i == -1: + return + j = find_end_of_inset(document.body, i) + if j == -1: + document.warning("Can't find end of inset in revert_url!") + return + k = find_default_layout(document, i, j) + if k == -1: + document.warning("Can't find default layout in revert_url!") + i = j + continue + l = find_end_of(document.body, k, "\\begin_layout", "\\end_layout") + if l == -1 or l >= j: + document.warning("Can't find end of default layout in revert_url!") + i = j + continue + # OK, so the inset's data is between lines k and l. + data = " ".join(document.body[k+1:l]) + data = data.strip() + newinset = ["\\begin_inset LatexCommand url", "target \"" + data + "\"",\ + "", "\\end_inset"] + document.body[i:j+1] = newinset + i = i + len(newinset) + + def convert_include(document): 'Converts include insets to new format.' @@ -2713,7 +2743,7 @@ revert = [[337, [revert_polytonicgreek]], [297, [revert_macro_optional_params]], [296, [revert_albanian, revert_lowersorbian, revert_uppersorbian]], [295, [revert_include]], - [294, [revert_href]], + [294, [revert_href, revert_url]], [293, [revert_pdf_options_2]], [292, [revert_inset_info]], [291, [revert_japanese, revert_japanese_encoding]],