else:
lineERT += 1
if environment == True:
+ # FIXME This version of the routine does not check for and pass over
+ # arguments before n. So it attempts to process the argument in the
+ # document, no matter what has been specified.
+ #
+ # The other branch does do that, but probably that code would be better
+ # in a single location: Skip all those arguments, then process the ones
+ # we want.
end_ERT = find_end_of_inset(document.body, lineERT)
if end_ERT == -1:
document.warning("Can't find end of ERT!!")
document.body[lineERT2 : end2 + 1] = ["\\end_layout", "", "\\end_inset"]
document.body[lineERT : end_ERT + 1] = ["\\begin_inset Argument " + str(n), "status open", "", "\\begin_layout Plain Layout"]
n += 1
+ else:
+ document.warning("Unable to process argument!")
+ n += 1
###############################################################################
'begin{%s}' % (latex_name),
'\\end_layout', '', '\\begin_layout Plain Layout', '']
- while 1:
+ while True:
i = find_token(document.body, "\\begin_layout %s" % (layout_name), i)
if i == -1:
return
continue
# delete all line breaks insets (there are no other insets)
l = i
- while 1:
+ while True:
n = find_token(document.body, "\\begin_inset Newline newline", l, j)
if n == -1:
n = find_token(document.body, "\\begin_inset Newline linebreak", l, j)
def revert_tipa(document):
" Revert native TIPA insets to mathed or ERT. "
i = 0
- while 1:
+ while True:
i = find_token(document.body, "\\begin_inset IPA", i)
if i == -1:
return
finally:
if load_rotating:
- add_to_preamble(document, ["\\@ifundefined{turnbox}{\usepackage{rotating}}{}"])
+ add_to_preamble(document, ["\\@ifundefined{turnbox}{\\usepackage{rotating}}{}"])
def convert_cell_rotation(document):
finally:
if load_rotating:
- add_to_preamble(document, ["\\@ifundefined{turnbox}{\usepackage{rotating}}{}"])
+ add_to_preamble(document, ["\\@ifundefined{turnbox}{\\usepackage{rotating}}{}"])
def convert_table_rotation(document):
if document.textclass != "IEEEtran":
return
+ layouts = {"Page headings": False,
+ "Biography without photo": True}
+
+ for layout in list(layouts.keys()):
+ i = 0
+ while True:
+ i = find_token(document.body, '\\begin_layout ' + layout, i)
+ if i == -1:
+ break
+ revert_Argument_to_TeX_brace(document, i, 0, 1, 1, layouts[layout], False)
+ i += 1
+
i = 0
- i2 = 0
- j = 0
- k = 0
while True:
- if i != -1:
- i = find_token(document.body, "\\begin_layout Page headings", i)
- if i != -1:
- revert_Argument_to_TeX_brace(document, i, 0, 1, 1, False, False)
+ i = find_token(document.body, '\\begin_inset Flex Paragraph Start', i)
+ if i == -1:
+ break
+ revert_Argument_to_TeX_brace(document, i, 0, 1, 1, False, False)
+ i += 1
+
+ i = 0
+ while True:
+ i = find_token_exact(document.body, "\\begin_layout Biography", i)
+ if i == -1:
+ break
+
+ if document.body[i] == "\\begin_layout Biography without photo":
i += 1
- if i2 != -1:
- i2 = find_token(document.body, "\\begin_inset Flex Paragraph Start", i2)
- if i2 != -1:
- revert_Argument_to_TeX_brace(document, i2, 0, 1, 1, False, False)
- i2 = i2 + 1
- if j != -1:
- j = find_token(document.body, "\\begin_layout Biography without photo", j)
- if j != -1:
- revert_Argument_to_TeX_brace(document, j, 0, 1, 1, True, False)
- j += 1
- if k != -1:
- k = find_token(document.body, "\\begin_layout Biography", k)
- kA = find_token(document.body, "\\begin_layout Biography without photo", k)
- if k == kA and k != -1:
- k += 1
- continue
- if k != -1:
- # start with the second argument, therefore 2
- revert_Argument_to_TeX_brace(document, k, 0, 2, 2, True, False)
- k += 1
- if i == -1 and i2 == -1 and j == -1 and k == -1:
- return
+ continue
+
+ # start with the second argument, therefore 2
+ revert_Argument_to_TeX_brace(document, i, 0, 2, 2, True, False)
+ i += 1
def revert_IEEEtran_2(document):
if document.textclass != "IEEEtran":
return
+ layouts = {"Page headings": False,
+ "Biography without photo": True}
+
+ for layout in list(layouts.keys()):
+ i = 0
+ while True:
+ i = find_token(document.body, '\\begin_layout ' + layout, i)
+ if i == -1:
+ break
+ convert_TeX_brace_to_Argument(document, i, 1, 1, False, layouts[layout], False)
+ i += 1
+
i = 0
- j = 0
- k = 0
while True:
- if i != -1:
- i = find_token(document.body, "\\begin_layout Page headings", i)
- if i != -1:
- convert_TeX_brace_to_Argument(document, i, 1, 1, False, False, False)
+ i = find_token_exact(document.body, "\\begin_layout Biography", i)
+ if i == -1:
+ break
+
+ if document.body[i] == "\\begin_layout Biography without photo":
i += 1
- if j != -1:
- j = find_token(document.body, "\\begin_layout Biography without photo", j)
- if j != -1:
- convert_TeX_brace_to_Argument(document, j, 1, 1, False, True, False)
- j += 1
- if k != -1:
- # assure that we don't handle Biography Biography without photo
- k = find_token(document.body, "\\begin_layout Biography", k)
- kA = find_token(document.body, "\\begin_layout Biography without photo", k - 1)
- if k == kA and k != -1:
- k += 1
continue
- if k != -1:
- # the argument we want to convert is the second one
- convert_TeX_brace_to_Argument(document, k, 2, 2, False, True, False)
- k += 1
- if i == -1 and j == -1 and k == -1:
- return
+
+ # the argument we want to convert is the second one
+ convert_TeX_brace_to_Argument(document, i, 2, 2, False, True, False)
+ i += 1
def revert_AASTeX(document):