From 4a1558855c0afe3c2f21e02181aede0385ec650d Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Thu, 4 Nov 2010 12:38:56 +0000 Subject: [PATCH] Simplify revert_paragraph_indentation. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36040 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/lyx_2_0.py | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index 8e4094249e..fc4d1dec7f 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -974,25 +974,18 @@ def revert_branch_filename(document): def revert_paragraph_indentation(document): " Revert custom paragraph indentation to preamble code " - i = 0 - while True: - i = find_token(document.header, "\\paragraph_indentation", i) - if i == -1: - break - # only remove the preamble line if default - # otherwise also write the value to the preamble - length = get_value(document.header, "\\paragraph_indentation", i) - if length == "default": - del document.header[i] - break - else: - # handle percent lengths - # latex_length returns "bool,length" - length = latex_length(length).split(",")[1] - add_to_preamble(document, ["% this command was inserted by lyx2lyx"]) - add_to_preamble(document, ["\\setlength{\\parindent}{" + length + "}"]) - del document.header[i] - i = i + 1 + i = find_token(document.header, "\\paragraph_indentation", i) + if i == -1: + return + length = get_value(document.header, "\\paragraph_indentation", i) + # we need only remove the line if indentation is default + if length != "default": + # handle percent lengths + # latex_length returns "bool,length" + length = latex_length(length).split(",")[1] + add_to_preamble(document, ["% this command was inserted by lyx2lyx"]) + add_to_preamble(document, ["\\setlength{\\parindent}{" + length + "}"]) + del document.header[i] def revert_percent_skip_lengths(document):