mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Fix up revert_hspace_glue_lengths.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36048 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
04157a2820
commit
4f04086c97
@ -1056,15 +1056,14 @@ def revert_percent_hspace_lengths(document):
|
||||
document.warning("Malformed lyx document: Missing '\\length' in Space inset.")
|
||||
i = j
|
||||
continue
|
||||
protected = (document.body[i].find("\\hspace*{}") != -1)
|
||||
protected = ""
|
||||
if document.body[i].find("\\hspace*{}") != -1:
|
||||
protected = "*"
|
||||
# ...and if it used a percent length
|
||||
percent, length = latex_length(length)
|
||||
# revert the HSpace inset to ERT
|
||||
if percent == "True":
|
||||
if protected:
|
||||
subst = put_cmd_in_ert("\\hspace*{" + length + "}")
|
||||
else:
|
||||
subst = put_cmd_in_ert("\\hspace{" + length + "}")
|
||||
subst = put_cmd_in_ert("\\hspace" + protected + "{" + length + "}")
|
||||
document.body[i:j + 1] = subst
|
||||
# if we did a substitution, this will still be ok
|
||||
i = j
|
||||
@ -1077,23 +1076,28 @@ def revert_hspace_glue_lengths(document):
|
||||
i = find_token(document.body, "\\begin_inset space \\hspace", i)
|
||||
if i == -1:
|
||||
break
|
||||
protected = (document.body[i].find("\\hspace*{}") != -1)
|
||||
length = get_value(document.body, '\\length', i + 1)
|
||||
j = find_end_of_inset(document.body, i)
|
||||
if j == -1:
|
||||
document.warning("Can't find end of inset at line " + str(i))
|
||||
i += 1
|
||||
continue
|
||||
length = get_value(document.body, '\\length', i + 1, j)
|
||||
if length == '':
|
||||
document.warning("Malformed lyx document: Missing '\\length' in Space inset.")
|
||||
return
|
||||
i = j
|
||||
continue
|
||||
protected = ""
|
||||
if document.body[i].find("\\hspace*{}") != -1:
|
||||
protected = "*"
|
||||
# only revert if the length contains a plus or minus at pos != 0
|
||||
glue = re.compile(r'.+[\+-]')
|
||||
if glue.search(length):
|
||||
if length.find('-',1) != -1 or length.find('+',1) != -1:
|
||||
# handle percent lengths
|
||||
length = latex_length(length)[1]
|
||||
# revert the HSpace inset to ERT
|
||||
if protected:
|
||||
subst = [old_put_cmd_in_ert("\\hspace*{" + length + "}")]
|
||||
else:
|
||||
subst = [old_put_cmd_in_ert("\\hspace{" + length + "}")]
|
||||
document.body[i:i + 3] = subst
|
||||
i = i + 2
|
||||
subst = put_cmd_in_ert("\\hspace" + protected + "{" + length + "}")
|
||||
document.body[i:j+1] = subst
|
||||
i = j
|
||||
|
||||
|
||||
def convert_author_id(document):
|
||||
" Add the author_id to the \\author definition and make sure 0 is not used"
|
||||
|
Loading…
Reference in New Issue
Block a user