def remove_color_default(document):
" Remove \color default"
i = 0
- while 1:
+ while True:
i = find_token(document.body, "\\color default", i)
if i == -1:
return
" \InsetSpace ~ -> \SpecialChar ~"
regexp = re.compile(r'(.*)(\\InsetSpace\s+)(\S+)')
i = 0
- while 1:
+ while True:
i = find_re(document.body, regexp, i)
if i == -1:
break
"\\begin_inset LatexCommand \\eqref -> ERT"
regexp = re.compile(r'^\\begin_inset\s+LatexCommand\s+\\eqref')
i = 0
- while 1:
+ while True:
i = find_re(document.body, regexp, i)
if i == -1:
break
def remove_insetparent(document):
" Remove \lyxparent"
i = 0
- while 1:
+ while True:
i = find_token(document.body, "\\begin_inset LatexCommand \\lyxparent", i)
if i == -1:
break
external_rexp = re.compile(r'\\begin_inset External ([^,]*),"([^"]*)",')
external_header = "\\begin_inset External"
i = 0
- while 1:
+ while True:
i = find_token(document.body, external_header, i)
if i == -1:
break
" Revert inset External."
external_header = "\\begin_inset External"
i = 0
- while 1:
+ while True:
i = find_token(document.body, external_header, i)
if i == -1:
break
" Revert inset External. (part II)"
draft_token = '\tdraft'
i = 0
- while 1:
+ while True:
i = find_token(document.body, '\\begin_inset External', i)
if i == -1:
break
" Convert \\layout comment"
i = 0
comment = "\\layout Comment"
- while 1:
+ while True:
i = find_token(document.body, comment, i)
if i == -1:
return
'\\layout %s' % document.default_layout]
i = i + 7
- while 1:
+ while True:
old_i = i
i = find_token(document.body, "\\layout", i)
if i == -1:
def revert_comment(document):
" Revert comments"
i = 0
- while 1:
+ while True:
i = find_tokens(document.body, ["\\begin_inset Comment", "\\begin_inset Greyedout"], i)
if i == -1:
i = i + 1
struct_stack = ["\\layout"]
- while 1:
+ while True:
i = find_tokens(document.body, ["\\begin_inset", "\\end_inset", "\\layout",
"\\begin_deeper", "\\end_deeper", "\\the_end"], i)
def rm_end_layout(document):
" Remove \end_layout"
i = 0
- while 1:
+ while True:
i = find_token(document.body, '\\end_layout', i)
if i == -1:
def rm_body_changes(document):
" Remove body changes."
i = 0
- while 1:
+ while True:
i = find_token(document.body, "\\change_", i)
if i == -1:
return
def layout2begin_layout(document):
" \layout -> \begin_layout "
i = 0
- while 1:
+ while True:
i = find_token(document.body, '\\layout', i)
if i == -1:
return
def begin_layout2layout(document):
" \begin_layout -> \layout "
i = 0
- while 1:
+ while True:
i = find_token(document.body, '\\begin_layout', i)
if i == -1:
return
" Convert table valignment, center -> middle"
regexp = re.compile(r'^\\begin_inset\s+Tabular')
i = 0
- while 1:
+ while True:
i = find_re(document.body, regexp, i)
if i == -1:
return
" Convert table valignment, middle -> center"
regexp = re.compile(r'^\\begin_inset\s+Tabular')
i = 0
- while 1:
+ while True:
i = find_re(document.body, regexp, i)
if i == -1:
return
attribute_values = ['default', 'default', 'default', 'default',
'default', 'default', 'default', 'none', document.language]
i = 0
- while 1:
+ while True:
i = find_token(document.body, "\\begin_layout", i)
if i == -1:
return
def convert_note(document):
" Convert Notes. "
i = 0
- while 1:
+ while True:
i = find_tokens(document.body, ["\\begin_inset Note",
"\\begin_inset Comment",
"\\begin_inset Greyedout"], i)
" Revert Notes. "
note_header = "\\begin_inset Note "
i = 0
- while 1:
+ while True:
i = find_token(document.body, note_header, i)
if i == -1:
break
def convert_box(document):
" Convert Boxes. "
i = 0
- while 1:
+ while True:
i = find_tokens(document.body, ["\\begin_inset Boxed",
"\\begin_inset Doublebox",
"\\begin_inset Frameless",
" Revert Boxes."
box_header = "\\begin_inset Box "
i = 0
- while 1:
+ while True:
i = find_token(document.body, box_header, i)
if i == -1:
break
def convert_collapsable(document):
" Convert collapsed insets. "
i = 0
- while 1:
+ while True:
i = find_tokens_exact(document.body, ["\\begin_inset Box",
"\\begin_inset Branch",
"\\begin_inset CharStyle",
# If, however, we find a line starting '\begin_layout'
# (_always_ present) then break with a warning message
i = i + 1
- while 1:
+ while True:
if (document.body[i] == "collapsed false"):
document.body[i] = "status open"
break
def revert_collapsable(document):
" Revert collapsed insets. "
i = 0
- while 1:
+ while True:
i = find_tokens_exact(document.body, ["\\begin_inset Box",
"\\begin_inset Branch",
"\\begin_inset CharStyle",
# If, however, we find a line starting '\begin_layout'
# (_always_ present) then break with a warning message
i = i + 1
- while 1:
+ while True:
if (document.body[i] == "status open"):
document.body[i] = "collapsed false"
break
def convert_ert(document):
" Convert ERT. "
i = 0
- while 1:
+ while True:
i = find_token(document.body, "\\begin_inset ERT", i)
if i == -1:
break
# If, however, we find a line starting '\begin_layout'
# (_always_ present) then break with a warning message
i = i + 1
- while 1:
+ while True:
if (document.body[i] == "status Open"):
document.body[i] = "status open"
break
def revert_ert(document):
" Revert ERT. "
i = 0
- while 1:
+ while True:
i = find_token(document.body, "\\begin_inset ERT", i)
if i == -1:
break
# If, however, we find a line starting '\begin_layout'
# (_always_ present) then break with a warning message
i = i + 1
- while 1:
+ while True:
if (document.body[i] == "status open"):
document.body[i] = "status Open"
break
inner_pos = ["c","t","b","s"]
i = 0
- while 1:
+ while True:
i = find_token(document.body, "\\begin_inset Minipage", i)
if i == -1:
return
# Convert the insets
i = 0
- while 1:
+ while True:
i = find_tokens(document.body, tokens, i)
if i == -1:
return
pos = ['t', 'c', 'b']
inner_pos = ['c', 't', 'b', 's']
i = 0
- while 1:
+ while True:
i = find_token(document.body, '\\begin_inset Frameless', i)
if i == -1:
return
def remove_branches(document):
" Remove branches. "
i = 0
- while 1:
+ while True:
i = find_token(document.header, "\\branch", i)
if i == -1:
break
del document.header[i:j+1]
i = 0
- while 1:
+ while True:
i = find_token(document.body, "\\begin_inset Branch", i)
if i == -1:
return
# If, however, we find a line starting '\layout'
# (_always_ present) then break with a warning message
collapsed_found = 0
- while 1:
+ while True:
if (document.body[i][:9] == "collapsed"):
del document.body[i]
collapsed_found = 1
def convert_float(document):
" Convert sideway floats. "
i = 0
- while 1:
+ while True:
i = find_token_exact(document.body, '\\begin_inset Float', i)
if i == -1:
return
# If, however, we find a line starting '\begin_layout'
# (_always_ present) then break with a warning message
i = i + 1
- while 1:
+ while True:
if (document.body[i][:4] == "wide"):
document.body.insert(i + 1, 'sideways false')
break
def revert_float(document):
" Revert sideways floats. "
i = 0
- while 1:
+ while True:
i = find_token_exact(document.body, '\\begin_inset Float', i)
if i == -1:
return
""" Add extension to documentnames of insetgraphics if necessary.
"""
i = 0
- while 1:
+ while True:
i = find_token(document.body, "\\begin_inset Graphics", i)
if i == -1:
return
i = 0
- while 1:
+ while True:
i = find_token(document.body, "\\begin_layout Author", i)
if i == -1:
return
def convert_bullets(document):
" Convert bullets. "
i = 0
- while 1:
+ while True:
i = find_token(document.header, "\\bullet", i)
if i == -1:
return
def revert_bullets(document):
" Revert bullets. "
i = 0
- while 1:
+ while True:
i = find_token(document.header, "\\bullet", i)
if i == -1:
return
"\\leftindent"
i = 0
- while 1:
+ while True:
i = find_token(document.body, '\\begin_layout', i)
if i == -1:
return
i = i + 1
- while 1:
+ while True:
if body[i].strip() and body[i].split()[0] not in allowed_parameters:
break
'\\emph', '\\numeric', '\\bar', '\\noun',
'\\color', '\\lang']
i = 0
- while 1:
+ while True:
i = find_token(document.body, '\\begin_inset ERT', i)
if i == -1:
return
# convert non-standard paragraphs to standard
k = i
- while 1:
+ while True:
k = find_token(document.body, "\\begin_layout", k, j)
if k == -1:
break
# insert an empty paragraph before each paragraph but the first
k = i
first_pagraph = 1
- while 1:
+ while True:
k = find_token(document.body, "\\begin_layout", k, j)
if k == -1:
break
# convert \\newline to new paragraph
k = i
- while 1:
+ while True:
k = find_token(document.body, "\\newline", k, j)
if k == -1:
break
def revert_ert_paragraphs(document):
" Remove double paragraph breaks. "
i = 0
- while 1:
+ while True:
i = find_token(document.body, '\\begin_inset ERT', i)
if i == -1:
return
# replace paragraph breaks with \newline
k = i
- while 1:
+ while True:
k = find_token(document.body, "\\end_layout", k, j)
l = find_token(document.body, "\\begin_layout", k, j)
if k == -1 or l == -1:
# replace double \newlines with paragraph breaks
k = i
- while 1:
+ while True:
k = find_token(document.body, "\\newline", k, j)
if k == -1:
break
# Change language in the document body
regexp = re.compile(r'^\\lang\s+frenchb')
i = 0
- while 1:
+ while True:
i = find_re(document.body, regexp, i)
if i == -1:
break
return
i = 0
- while 1:
+ while True:
i = find_token(document.body, "\\begin_layout SGML", i)
if i == -1: