mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-26 01:49:22 +00:00
Reduce indentation. Also, it is probably not a good idea to use "string"
as a variable name here. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36042 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
dcc164407a
commit
fbfdef21f1
@ -259,11 +259,11 @@ def lyx2latex(document, lines):
|
|||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
||||||
def latex_length(string):
|
def latex_length(slen):
|
||||||
'Convert lengths to their LaTeX representation.'
|
'Convert lengths to their LaTeX representation.'
|
||||||
i = 0
|
i = 0
|
||||||
percent = False
|
percent = False
|
||||||
# the string has the form
|
# the slen has the form
|
||||||
# ValueUnit+ValueUnit-ValueUnit or
|
# ValueUnit+ValueUnit-ValueUnit or
|
||||||
# ValueUnit+-ValueUnit
|
# ValueUnit+-ValueUnit
|
||||||
# the + and - (glue lengths) are optional
|
# the + and - (glue lengths) are optional
|
||||||
@ -274,41 +274,42 @@ def latex_length(string):
|
|||||||
"page%":"\\paperwidth", "line%":"\\linewidth",
|
"page%":"\\paperwidth", "line%":"\\linewidth",
|
||||||
"theight%":"\\textheight", "pheight%":"\\paperheight"}
|
"theight%":"\\textheight", "pheight%":"\\paperheight"}
|
||||||
for unit in units.keys():
|
for unit in units.keys():
|
||||||
i = string.find(unit)
|
i = slen.find(unit)
|
||||||
if i == -1:
|
if i == -1:
|
||||||
percent = True
|
continue
|
||||||
minus = string.rfind("-", 1, i)
|
percent = True
|
||||||
plus = string.rfind("+", 0, i)
|
minus = slen.rfind("-", 1, i)
|
||||||
latex_unit = units[unit]
|
plus = slen.rfind("+", 0, i)
|
||||||
if plus == -1 and minus == -1:
|
latex_unit = units[unit]
|
||||||
value = string[:i]
|
if plus == -1 and minus == -1:
|
||||||
value = str(float(value)/100)
|
value = slen[:i]
|
||||||
end = string[i + len(unit):]
|
value = str(float(value)/100)
|
||||||
string = value + latex_unit + end
|
end = slen[i + len(unit):]
|
||||||
if plus > minus:
|
slen = value + latex_unit + end
|
||||||
value = string[plus + 1:i]
|
if plus > minus:
|
||||||
value = str(float(value)/100)
|
value = slen[plus + 1:i]
|
||||||
begin = string[:plus + 1]
|
value = str(float(value)/100)
|
||||||
end = string[i+len(unit):]
|
begin = slen[:plus + 1]
|
||||||
string = begin + value + latex_unit + end
|
end = slen[i+len(unit):]
|
||||||
if plus < minus:
|
slen = begin + value + latex_unit + end
|
||||||
value = string[minus + 1:i]
|
if plus < minus:
|
||||||
value = str(float(value)/100)
|
value = slen[minus + 1:i]
|
||||||
begin = string[:minus + 1]
|
value = str(float(value)/100)
|
||||||
string = begin + value + latex_unit
|
begin = slen[:minus + 1]
|
||||||
|
slen = begin + value + latex_unit
|
||||||
|
|
||||||
# replace + and -, but only if the - is not the first character
|
# replace + and -, but only if the - is not the first character
|
||||||
string = string[0] + string[1:].replace("+", " plus ").replace("-", " minus ")
|
slen = slen[0] + slen[1:].replace("+", " plus ").replace("-", " minus ")
|
||||||
# handle the case where "+-1mm" was used, because LaTeX only understands
|
# handle the case where "+-1mm" was used, because LaTeX only understands
|
||||||
# "plus 1mm minus 1mm"
|
# "plus 1mm minus 1mm"
|
||||||
if string.find("plus minus"):
|
if slen.find("plus minus"):
|
||||||
lastvaluepos = string.rfind(" ")
|
lastvaluepos = slen.rfind(" ")
|
||||||
lastvalue = string[lastvaluepos:]
|
lastvalue = slen[lastvaluepos:]
|
||||||
string = string.replace(" ", lastvalue + " ")
|
slen = slen.replace(" ", lastvalue + " ")
|
||||||
if percent == False:
|
if percent == False:
|
||||||
return "False," + string
|
return "False," + slen
|
||||||
else:
|
else:
|
||||||
return "True," + string
|
return "True," + slen
|
||||||
|
|
||||||
|
|
||||||
def revert_flex_inset(document, name, LaTeXname, position):
|
def revert_flex_inset(document, name, LaTeXname, position):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user