find_end_of_inset, find_end_of_layout, find_nonempty_line, \
get_containing_layout, get_value, check_token
-# Provide support for both python 2 and 3
-PY2 = sys.version_info[0] == 2
-if not PY2:
- text_type = str
- unichr = chr
-else:
- text_type = unicode
- unichr = unichr
-# End of code to support for both python 2 and 3
-
####################################################################
# Private helper functions
}
i = 0
- while 1:
+ while True:
i = find_token(document.body, "\\begin_deeper", i)
if i == -1:
break
i = i + 1
i = 0
- while 1:
+ while True:
i = find_token(document.body, "\\align", i)
if i == -1:
break
regexp = re.compile(r'^\\begin_layout (?:(-*)|(\s*))(Separator|EndOfSlide)(?:(-*)|(\s*))$', re.IGNORECASE)
i = 0
- while 1:
+ while True:
i = find_re(document.body, regexp, i)
if i == -1:
return
"", "\\end_inset", ""]
i = 0
- while 1:
+ while True:
i = find_token(document.body, "\\begin_inset Separator", i)
if i == -1:
return
"""
parbreakinset = "\\begin_inset Separator parbreak"
i = 0
- while 1:
+ while True:
i = find_token(document.body, parbreakinset, i)
if i == -1:
return
Revert latexpar separators to parbreak separators.
"""
i = 0
- while 1:
+ while True:
i = find_token(document.body, "\\begin_inset Separator latexpar", i)
if i == -1:
return
else:
i = j
continue
+ if len(words) > 0 and words[0] in ["\\leftindent", "\\paragraph_spacing", "\\align", "\\labelwidthstring"]:
+ # skip paragraph parameters (bug 10243)
+ i += 1
+ continue
while True:
j = document.body[i].find("--")
if j == -1:
if i == -1:
document.warning("Malformed LyX document: No \\textclass!!")
return
- if document.dir == "":
- origin = "stdin"
+ if document.dir == u'':
+ origin = u'stdin'
else:
- relpath = ''
- if document.systemlyxdir and document.systemlyxdir != '':
+ relpath = u''
+ if document.systemlyxdir and document.systemlyxdir != u'':
try:
if os.path.isabs(document.dir):
absdir = os.path.normpath(document.dir)
else:
abssys = os.path.normpath(os.path.abspath(document.systemlyxdir))
relpath = os.path.relpath(absdir, abssys)
- if relpath.find('..') == 0:
- relpath = ''
+ if relpath.find(u'..') == 0:
+ relpath = u''
except:
- relpath = ''
- if relpath == '':
- origin = document.dir.replace('\\', '/') + '/'
+ relpath = u''
+ if relpath == u'':
+ origin = document.dir.replace(u'\\', u'/') + u'/'
else:
- origin = os.path.join("/systemlyxdir", relpath).replace('\\', '/') + '/'
- if os.name != 'nt':
- origin = text_type(origin, sys.getfilesystemencoding())
+ origin = os.path.join(u"/systemlyxdir", relpath).replace(u'\\', u'/') + u'/'
document.header[i:i] = ["\\origin " + origin]