# is_in_inset, set_bool_value
# find_tokens, check_token
-from lyx2lyx_tools import (put_cmd_in_ert, add_to_preamble, lyx2latex, revert_language, revert_flex_inset)
+from lyx2lyx_tools import (put_cmd_in_ert, add_to_preamble, lyx2latex,
+ revert_language, revert_flex_inset)
# revert_font_attrs, insert_to_preamble, latex_length
# get_ert, lyx2verbatim, length_in_bp, convert_info_insets
# revert_flex_inset, hex2ratio, str2bool
return fm
def convert_fonts(document, fm):
- " Handle font definition to LaTeX "
+ " Handle font definition (LaTeX preamble -> native) "
rpkg = re.compile(r'^\\usepackage(\[([^\]]*)\])?\{([^\}]+)\}')
rscaleopt = re.compile(r'^scaled?=(.*)')
i = 0
while i < len(document.preamble):
- i = find_re(document.preamble, rpkg, i)
+ i = find_re(document.preamble, rpkg, i+1)
if i == -1:
return
mo = rpkg.search(document.preamble[i])
break
if not pkg in fm.pkginmap:
- i += 1
continue
# determine fontname
fn = fm.getfontname(pkg, options)
if fn == None:
- i += 1
continue
del document.preamble[i]
fontinfo = fm.font2pkgmap[fn]
if i > 0 and document.preamble[i-1] == "% Added by lyx2lyx":
del document.preamble[i-1]
+ i -= 1
if fontscale != None:
j = find_token(document.header, fontscale, 0)
if j != -1:
rscales = re.compile(r'^\s*(\d+)\s+(\d+)')
i = 0
while i < len(document.header):
- i = find_re(document.header, rfontscale, i)
+ i = find_re(document.header, rfontscale, i+1)
if (i == -1):
break
mo = rfontscale.search(document.header[i])
if mo == None:
- i += 1
continue
ft = mo.group(1) # 'roman', 'sans', 'typewriter', 'math'
val = get_value(document.header, ft, i)
words = val.split(' ') # ! splits also values like '"DejaVu Sans"'
font = words[0].strip('"') # TeX font name has no whitespace
if not font in fm.font2pkgmap:
- i += 1
continue
fontinfo = fm.font2pkgmap[font]
val = fontinfo.package
fontmap[val].extend([fontinfo.scaleopt + "=" + format(float(xval1) / 100, '.2f')])
if len(fontinfo.options) > 0:
fontmap[val].extend(fontinfo.options)
- i += 1
###############################################################################
###
tokenend = len('\\begin_layout ')
i = 0
while True:
- i = find_token_exact(document.body, '\\begin_layout ', i)
+ i = find_token_exact(document.body, '\\begin_layout ', i+1)
if i == -1:
return
layout = document.body[i][tokenend:].strip()
if layout not in layouts:
- i += 1
continue
j = find_end_of_layout(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of layout at line %d" % i)
- i += 1
continue
while document.body[j+1].strip() == '':
j += 1
first = -1
i = 0
while True:
- i = find_token_exact(document.body, '\\begin_layout ', i)
+ i = find_token_exact(document.body, '\\begin_layout ', i+1)
if i == -1:
break
layout = document.body[i][tokenend:].strip()
if layout not in layouts:
- i += 1
continue
k = find_end_of_layout(document.body, i)
if k == -1:
document.warning("Malformed LyX document: Can't find end of layout at line %d" % i)
- i += 1;
continue
if first == -1:
first = i
- i = k+1
+ i = k
if first == -1:
return
insertFrontmatter('End', k+1)
i = 0
while True:
- i = find_token(document.body, '\\begin_inset CommandInset include', i)
+ i = find_token(document.body, '\\begin_inset CommandInset include', i+1)
if i == -1:
break
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of command inset at line %d" % i)
- i += 1
continue
while i < j and document.body[i].strip() != '':
i += 1
i = 0
while True:
- i = find_token(document.body, "\\begin_inset Flex Landscape", i)
+ i = find_token(document.body, "\\begin_inset Flex Landscape", i+1)
if i == -1:
return
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of Landscape inset")
- i += 1
continue
if document.body[i] == "\\begin_inset Flex Landscape (Floating)":
document.body[i : i + 4] = put_cmd_in_ert("\\begin{landscape}")
add_to_preamble(document, ["\\usepackage{pdflscape}"])
- # no need to reset i
def convert_fontenc(document):
def revert_floatpclass(document):
" Remove float placement params 'document' and 'class' "
- i = 0
- i = find_token(document.header, "\\float_placement class", 0)
- if i != -1:
- del document.header[i]
+ del_token(document.header, "\\float_placement class")
i = 0
while True:
- i = find_token(document.body, '\\begin_inset Float', i)
+ i = find_token(document.body, '\\begin_inset Float', i+1)
if i == -1:
break
j = find_end_of_inset(document.body, i)
k = find_token(document.body, 'placement document', i, i + 2)
if k != -1:
del document.body[k]
- i += 1
continue
del document.body[k]
def revert_floatalignment(document):
" Remove float alignment params "
- i = 0
- i = find_token(document.header, "\\float_alignment", 0)
- galignment = ""
- if i != -1:
- galignment = get_value(document.header, "\\float_alignment", i)
- del document.header[i]
+ galignment = get_value(document.header, "\\float_alignment", delete=True)
i = 0
while True:
- i = find_token(document.body, '\\begin_inset Float', i)
+ i = find_token(document.body, '\\begin_inset Float', i+1)
if i == -1:
break
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of inset at line " + str(i))
- i += 1
- k = find_token(document.body, 'alignment', i, i + 4)
+ continue
+ k = find_token(document.body, 'alignment', i, i+4)
if k == -1:
i = j
continue
l = find_token(document.body, "\\begin_layout Plain Layout", i, j)
if l == -1:
document.warning("Can't find float layout!")
- i += 1
continue
alcmd = []
if alignment == "left":
alcmd = put_cmd_in_ert("\\raggedleft{}")
if len(alcmd) > 0:
document.body[l+1:l+1] = alcmd
- i += 1
-
+ i = j
def revert_tuftecite(document):
" Revert \cite commands in tufte classes "
i = 0
while (True):
- i = find_token(document.body, "\\begin_inset CommandInset citation", i)
+ i = find_token(document.body, "\\begin_inset CommandInset citation", i+1)
if i == -1:
break
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Can't find end of citation inset at line %d!!" %(i))
- i += 1
continue
k = find_token(document.body, "LatexCommand", i, j)
if k == -1:
document.warning("Can't find LatexCommand for citation inset at line %d!" %(i))
- i = j + 1
+ i = j
continue
cmd = get_value(document.body, "LatexCommand", k)
if cmd != "cite":
- i = j + 1
+ i = j
continue
pre = get_quoted_value(document.body, "before", i, j)
post = get_quoted_value(document.body, "after", i, j)
res += "[]"
res += "{" + key + "}"
document.body[i:j+1] = put_cmd_in_ert([res])
- i = j + 1
+ i = j
def revert_stretchcolumn(document):
" We remove the column varwidth flags or everything else will become a mess. "
i = 0
while True:
- i = find_token(document.body, "\\begin_inset Tabular", i)
+ i = find_token(document.body, "\\begin_inset Tabular", i+1)
if i == -1:
return
- j = find_end_of_inset(document.body, i + 1)
+ j = find_end_of_inset(document.body, i+1)
if j == -1:
document.warning("Malformed LyX document: Could not find end of tabular.")
continue
if re.search('^<column.*varwidth="[^"]+".*>$', document.body[k]):
document.warning("Converting 'tabularx'/'xltabular' table to normal table.")
document.body[k] = document.body[k].replace(' varwidth="true"', '')
- i = i + 1
def revert_vcolumns(document):
needarray = False
try:
while True:
- i = find_token(document.body, "\\begin_inset Tabular", i)
+ i = find_token(document.body, "\\begin_inset Tabular", i+1)
if i == -1:
return
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Could not find end of tabular.")
- i += 1
continue
# Collect necessary column information
document.body[nl:nl+1] = put_cmd_in_ert("\\\\")
m += 1
- i = j + 1
+ i = j
finally:
if needarray == True:
i = 0
bibresources = []
while (True):
- i = find_token(document.body, "\\begin_inset CommandInset bibtex", i)
+ i = find_token(document.body, "\\begin_inset CommandInset bibtex", i+1)
if i == -1:
break
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Can't find end of bibtex inset at line %d!!" %(i))
- i += 1
continue
encoding = get_quoted_value(document.body, "encoding", i, j)
if not encoding:
- i += 1
continue
# remove encoding line
k = find_token(document.body, "encoding", i, j)
if k != -1:
del document.body[k]
if encoding == "default":
- i += 1
continue
# Re-find inset end line
j = find_end_of_inset(document.body, i)
document.body[j+1:j+1] = put_cmd_in_ert("\\egroup")
document.body[i:i] = put_cmd_in_ert("\\bgroup\\inputencoding{" + encodings[encoding] + "}")
- i = j + 1
+ i = j
}
i = 0
while True:
- i = find_token(document.body, "\\begin_inset Info", i)
+ i = find_token(document.body, "\\begin_inset Info", i+1)
if i == -1:
return
- j = find_end_of_inset(document.body, i + 1)
+ j = find_end_of_inset(document.body, i+1)
if j == -1:
document.warning("Malformed LyX document: Could not find end of Info inset.")
- i = i + 1
continue
tp = find_token(document.body, 'type', i, j)
tpv = get_quoted_value(document.body, "type", tp)
if tpv != "buffer":
- i = i + 1
continue
arg = find_token(document.body, 'arg', i, j)
argv = get_quoted_value(document.body, "arg", arg)
if argv not in list(types.keys()):
- i = i + 1
continue
document.body[tp] = "type \"vcs\""
document.body[arg] = "arg \"" + types[argv] + "\""
- i = i + 1
def revert_vcsinfo(document):
args = ["revision", "tree-revision", "author", "time", "date" ]
i = 0
while True:
- i = find_token(document.body, "\\begin_inset Info", i)
+ i = find_token(document.body, "\\begin_inset Info", i+1)
if i == -1:
return
- j = find_end_of_inset(document.body, i + 1)
+ j = find_end_of_inset(document.body, i+1)
if j == -1:
document.warning("Malformed LyX document: Could not find end of Info inset.")
- i = i + 1
continue
tp = find_token(document.body, 'type', i, j)
tpv = get_quoted_value(document.body, "type", tp)
if tpv != "vcs":
- i = i + 1
continue
arg = find_token(document.body, 'arg', i, j)
argv = get_quoted_value(document.body, "arg", arg)
if argv not in args:
document.warning("Malformed Info inset. Invalid vcs arg.")
- i = i + 1
continue
document.body[tp] = "type \"buffer\""
document.body[arg] = "arg \"vcs-" + argv + "\""
- i = i + 1
def revert_dateinfo(document):
i = 0
while True:
- i = find_token(document.body, "\\begin_inset Info", i)
+ i = find_token(document.body, "\\begin_inset Info", i+1)
if i == -1:
return
- j = find_end_of_inset(document.body, i + 1)
+ j = find_end_of_inset(document.body, i+1)
if j == -1:
document.warning("Malformed LyX document: Could not find end of Info inset.")
- i = i + 1
continue
tp = find_token(document.body, 'type', i, j)
tpv = get_quoted_value(document.body, "type", tp)
if tpv not in types:
- i = i + 1
continue
arg = find_token(document.body, 'arg', i, j)
argv = get_quoted_value(document.body, "arg", arg)
# our dateformat strings are utf8-encoded:
result = result.decode('utf-8')
document.body[i : j+1] = [result]
- i = i + 1
def revert_timeinfo(document):
i = 0
while True:
- i = find_token(document.body, "\\begin_inset Info", i)
+ i = find_token(document.body, "\\begin_inset Info", i+1)
if i == -1:
return
- j = find_end_of_inset(document.body, i + 1)
+ j = find_end_of_inset(document.body, i+1)
if j == -1:
document.warning("Malformed LyX document: Could not find end of Info inset.")
- i = i + 1
continue
tp = find_token(document.body, 'type', i, j)
tpv = get_quoted_value(document.body, "type", tp)
if tpv not in types:
- i = i + 1
continue
arg = find_token(document.body, 'arg', i, j)
argv = get_quoted_value(document.body, "arg", arg)
fmt = fmt.replace("'", "")
result = dte.strftime(fmt)
document.body[i : j+1] = result
- i = i + 1
def revert_namenoextinfo(document):
i = 0
while True:
- i = find_token(document.body, "\\begin_inset Info", i)
+ i = find_token(document.body, "\\begin_inset Info", i+1)
if i == -1:
return
- j = find_end_of_inset(document.body, i + 1)
+ j = find_end_of_inset(document.body, i+1)
if j == -1:
document.warning("Malformed LyX document: Could not find end of Info inset.")
- i = i + 1
continue
tp = find_token(document.body, 'type', i, j)
tpv = get_quoted_value(document.body, "type", tp)
if tpv != "buffer":
- i = i + 1
continue
arg = find_token(document.body, 'arg', i, j)
argv = get_quoted_value(document.body, "arg", arg)
if argv != "name-noext":
- i = i + 1
continue
document.body[arg] = "arg \"name\""
- i = i + 1
def revert_l7ninfo(document):
i = 0
while True:
- i = find_token(document.body, "\\begin_inset Info", i)
+ i = find_token(document.body, "\\begin_inset Info", i+1)
if i == -1:
return
- j = find_end_of_inset(document.body, i + 1)
+ j = find_end_of_inset(document.body, i+1)
if j == -1:
document.warning("Malformed LyX document: Could not find end of Info inset.")
- i = i + 1
continue
tp = find_token(document.body, 'type', i, j)
tpv = get_quoted_value(document.body, "type", tp)
if tpv != "l7n":
- i = i + 1
continue
arg = find_token(document.body, 'arg', i, j)
argv = get_quoted_value(document.body, "arg", arg)
# remove trailing colons, menu accelerator (|...) and qt accelerator (&), while keeping literal " & "
argv = argv.rstrip(':').split('|')[0].replace(" & ", "</amp;>").replace("&", "").replace("</amp;>", " & ")
document.body[i : j+1] = argv
- i = i + 1
def revert_listpargs(document):
" Reverts listpreamble arguments to TeX-code "
i = 0
while True:
- i = find_token(document.body, "\\begin_inset Argument listpreamble:", i)
+ i = find_token(document.body, "\\begin_inset Argument listpreamble:", i+1)
if i == -1:
return
j = find_end_of_inset(document.body, i)
parent = get_containing_layout(document.body, i)
if parent == False:
document.warning("Malformed LyX document: Can't find parent paragraph layout")
- i += 1
continue
parbeg = parent[3]
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", i)
subst = ["\\begin_inset ERT", "status collapsed", "", "\\begin_layout Plain Layout",
"{"] + content + ["}", "\\end_layout", "", "\\end_inset", ""]
document.body[parbeg : parbeg] = subst
- i += 1
def revert_lformatinfo(document):
i = 0
while True:
- i = find_token(document.body, "\\begin_inset Info", i)
+ i = find_token(document.body, "\\begin_inset Info", i+1)
if i == -1:
return
- j = find_end_of_inset(document.body, i + 1)
+ j = find_end_of_inset(document.body, i+1)
if j == -1:
document.warning("Malformed LyX document: Could not find end of Info inset.")
- i = i + 1
continue
tp = find_token(document.body, 'type', i, j)
tpv = get_quoted_value(document.body, "type", tp)
if tpv != "lyxinfo":
- i = i + 1
continue
arg = find_token(document.body, 'arg', i, j)
argv = get_quoted_value(document.body, "arg", arg)
if argv != "layoutformat":
- i = i + 1
continue
# hardcoded for now
document.body[i : j+1] = "69"
- i = i + 1
def convert_hebrew_parentheses(document):
" Remove tablestyle params "
i = 0
- i = find_token(document.header, "\\tablestyle", 0)
+ i = find_token(document.header, "\\tablestyle")
if i != -1:
del document.header[i]
i = 0
bibresources = []
while (True):
- i = find_token(document.body, "\\begin_inset CommandInset bibtex", i)
+ i = find_token(document.body, "\\begin_inset CommandInset bibtex", i+1)
if i == -1:
break
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Can't find end of bibtex inset at line %d!!" %(i))
- i += 1
continue
encodings = get_quoted_value(document.body, "file_encodings", i, j)
if not encodings:
- i += 1
+ i = j
continue
bibfiles = get_quoted_value(document.body, "bibfiles", i, j).split(",")
opts = get_quoted_value(document.body, "biblatexopts", i, j)
document.body[i:j+1] = repl
j += 27
- i = j + 1
+ i = j
def revert_cmidruletrimming(document):
i = 0
while True:
# first, let's find out if we need to do anything
- i = find_token(document.body, '<cell ', i)
+ i = find_token(document.body, '<cell ', i+1)
if i == -1:
return
j = document.body[i].find('trim="')
if j == -1:
- i += 1
continue
rgx = re.compile(r' (bottom|top)line[lr]trim="true"')
# remove trim option
document.body[i] = rgx.sub('', document.body[i])
- i += 1
-
ruby_inset_def = [
r'### Inserted by lyx2lyx (ruby inset) ###',
" Replace user-preamble code with native lineno support."
use_lineno = 0
options = ""
- j = find_token(document.preamble, "\\linenumbers", 1)
- if j > -1:
- usepkg = re.match(r"\\usepackage(.*){lineno}", document.preamble[j-1])
+ i = find_token(document.preamble, "\\linenumbers", 1)
+ if i > -1:
+ usepkg = re.match(r"\\usepackage(.*){lineno}", document.preamble[i-1])
if usepkg:
use_lineno = 1
options = usepkg.group(1).strip("[]")
- del(document.preamble[j-1:j+1])
- del_token(document.preamble, "% Added by lyx2lyx", j-2, j-1)
+ del(document.preamble[i-1:i+1])
+ del_token(document.preamble, "% Added by lyx2lyx", i-2, i-1)
k = find_token(document.header, "\\index ")
if options == "":
r' ForcePlain true',
r' ParbreakIsNewline true',
r' FreeSpacing true',
- r' Requires covington',
+ r' Requires covington',
r' Preamble',
r' \def\glosstr{}',
r' \@ifundefined{linggloss}{%',
r' InToc true',
r' ResetsFont true',
r' Argument 1',
- r' Decoration conglomerate',
- r' LabelString "Translation"',
- r' MenuString "Glosse Translation|s"',
- r' Tooltip "Add a translation for the glosse"',
+ r' Decoration conglomerate',
+ r' LabelString "Translation"',
+ r' MenuString "Glosse Translation|s"',
+ r' Tooltip "Add a translation for the glosse"',
r' EndArgument',
r'End'
]
r' ParbreakIsNewline true',
r' FreeSpacing true',
r' InToc true',
- r' Requires covington',
+ r' Requires covington',
r' Preamble',
r' \def\glosstr{}',
r' \@ifundefined{lingglosss}{%',
r' EndPreamble',
r' ResetsFont true',
r' Argument 1',
- r' Decoration conglomerate',
- r' LabelString "Translation"',
- r' MenuString "Glosse Translation|s"',
- r' Tooltip "Add a translation for the glosse"',
+ r' Decoration conglomerate',
+ r' LabelString "Translation"',
+ r' MenuString "Glosse Translation|s"',
+ r' Tooltip "Add a translation for the glosse"',
r' EndArgument',
r'End'
]
def revert_linggloss(document):
" Revert to old ling gloss definitions "
- document.del_local_layout(gloss_inset_def)
- document.del_local_layout(glosss_inset_def)
-
if not "linguistics" in document.get_module_list():
return
+ document.del_local_layout(gloss_inset_def)
+ document.del_local_layout(glosss_inset_def)
cov_req = False
glosses = ["\\begin_inset Flex Interlinear Gloss (2 Lines)", "\\begin_inset Flex Interlinear Gloss (3 Lines)"]
for glosse in glosses:
i = 0
while True:
- i = find_token(document.body, glosse, i)
+ i = find_token(document.body, glosse, i+1)
if i == -1:
break
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of Gloss inset")
- i += 1
continue
arg = find_token(document.body, "\\begin_inset Argument 1", i, j)
argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg)
if argbeginPlain == -1:
document.warning("Malformed LyX document: Can't find optarg plain Layout")
- i += 1
continue
argendPlain = find_end_of_inset(document.body, argbeginPlain)
optargcontent = document.body[argbeginPlain + 1 : argendPlain - 2]
argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg)
if argbeginPlain == -1:
document.warning("Malformed LyX document: Can't find arg 1 plain Layout")
- i += 1
continue
argendPlain = find_end_of_inset(document.body, argbeginPlain)
marg1content = document.body[argbeginPlain + 1 : argendPlain - 2]
argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg)
if argbeginPlain == -1:
document.warning("Malformed LyX document: Can't find arg 2 plain Layout")
- i += 1
continue
argendPlain = find_end_of_inset(document.body, argbeginPlain)
marg2content = document.body[argbeginPlain + 1 : argendPlain - 2]
argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg)
if argbeginPlain == -1:
document.warning("Malformed LyX document: Can't find arg 3 plain Layout")
- i += 1
continue
argendPlain = find_end_of_inset(document.body, argbeginPlain)
marg3content = document.body[argbeginPlain + 1 : argendPlain - 2]
if not cov_req:
document.append_local_layout("Requires covington")
cov_req = True
- i = beginPlain + 1
+ i = beginPlain
def revert_subexarg(document):
cov_req = False
i = 0
while True:
- i = find_token(document.body, "\\begin_layout Subexample", i)
+ i = find_token(document.body, "\\begin_layout Subexample", i+1)
if i == -1:
break
j = find_end_of_layout(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of Subexample layout")
- i += 1
continue
while True:
# check for consecutive layouts
j = find_end_of_layout(document.body, k)
if j == -1:
document.warning("Malformed LyX document: Can't find end of Subexample layout")
- i += 1
continue
arg = find_token(document.body, "\\begin_inset Argument 1", i, j)
if arg == -1:
- i += 1
continue
endarg = find_end_of_inset(document.body, arg)
argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg)
if argbeginPlain == -1:
document.warning("Malformed LyX document: Can't find optarg plain Layout")
- i += 1
continue
argendPlain = find_end_of_inset(document.body, argbeginPlain)
optargcontent = lyx2latex(document, document.body[argbeginPlain + 1 : argendPlain - 2])
j = find_end_of_layout(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of Subexample layout")
- i += 1
continue
while True:
# check for consecutive layouts
j = find_end_of_layout(document.body, k)
if j == -1:
document.warning("Malformed LyX document: Can't find end of Subexample layout")
- i += 1
continue
endev = put_cmd_in_ert("\\end{subexamples}")
if not cov_req:
document.append_local_layout("Requires covington")
cov_req = True
- i += 1
def revert_drs(document):
for drs in drses:
i = 0
while True:
- i = find_token(document.body, drs, i)
+ i = find_token(document.body, drs, i+1)
if i == -1:
break
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of DRS inset")
- i += 1
continue
# Check for arguments
argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg)
if argbeginPlain == -1:
document.warning("Malformed LyX document: Can't find Argument 1 plain Layout")
- i += 1
continue
argendPlain = find_end_of_inset(document.body, argbeginPlain)
prearg1content = document.body[argbeginPlain + 1 : argendPlain - 2]
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of DRS inset")
- i += 1
continue
arg = find_token(document.body, "\\begin_inset Argument 2", i, j)
argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg)
if argbeginPlain == -1:
document.warning("Malformed LyX document: Can't find Argument 2 plain Layout")
- i += 1
continue
argendPlain = find_end_of_inset(document.body, argbeginPlain)
prearg2content = document.body[argbeginPlain + 1 : argendPlain - 2]
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of DRS inset")
- i += 1
continue
arg = find_token(document.body, "\\begin_inset Argument post:1", i, j)
argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg)
if argbeginPlain == -1:
document.warning("Malformed LyX document: Can't find Argument post:1 plain Layout")
- i += 1
continue
argendPlain = find_end_of_inset(document.body, argbeginPlain)
postarg1content = document.body[argbeginPlain + 1 : argendPlain - 2]
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of DRS inset")
- i += 1
continue
arg = find_token(document.body, "\\begin_inset Argument post:2", i, j)
argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg)
if argbeginPlain == -1:
document.warning("Malformed LyX document: Can't find Argument post:2 plain Layout")
- i += 1
continue
argendPlain = find_end_of_inset(document.body, argbeginPlain)
postarg2content = document.body[argbeginPlain + 1 : argendPlain - 2]
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of DRS inset")
- i += 1
continue
arg = find_token(document.body, "\\begin_inset Argument post:3", i, j)
argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg)
if argbeginPlain == -1:
document.warning("Malformed LyX document: Can't find Argument post:3 plain Layout")
- i += 1
continue
argendPlain = find_end_of_inset(document.body, argbeginPlain)
postarg3content = document.body[argbeginPlain + 1 : argendPlain - 2]
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of DRS inset")
- i += 1
continue
arg = find_token(document.body, "\\begin_inset Argument post:4", i, j)
argbeginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg, endarg)
if argbeginPlain == -1:
document.warning("Malformed LyX document: Can't find Argument post:4 plain Layout")
- i += 1
continue
argendPlain = find_end_of_inset(document.body, argbeginPlain)
postarg4content = document.body[argbeginPlain + 1 : argendPlain - 2]
document.append_local_layout("Provides covington 1")
add_to_preamble(document, ["\\usepackage{drs,covington}"])
cov_req = True
- i = beginPlain + 1
+ i = beginPlain
##