lyx2lyx: Cosmetic clean up of the lyx_2_?.py files.

Remove the duplicated \# -*- coding: utf-8 -*-
lines that show in the third line.
As far as I know they are not used, the first line though is used
by python and text editors (emacs, vi & co) to get the file encoding.
That will also work in the second lines (because of the shebang convention)
but not in other lines.

Remove trailing whitespaces.
This commit is contained in:
José Matos 2017-03-27 10:16:31 +01:00
parent 101694a51f
commit 37901e2e25
4 changed files with 235 additions and 239 deletions

View File

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# This file is part of lyx2lyx
# -*- coding: utf-8 -*-
# Copyright (C) 2011 The LyX team
#
# This program is free software; you can redistribute it and/or
@ -27,7 +26,7 @@ from parser_tools import find_token, find_end_of, find_tokens, \
find_token_exact, find_end_of_inset, find_end_of_layout, \
find_token_backwards, is_in_inset, get_value, get_quoted_value, \
del_token, check_token, get_option_value
from lyx2lyx_tools import add_to_preamble, insert_to_preamble, \
put_cmd_in_ert, lyx2latex, latex_length, revert_flex_inset, \
revert_font_attrs, hex2ratio, str2bool
@ -156,7 +155,7 @@ def revert_phantom_types(document, ptype, cmd):
i = end
continue
substi = ["\\begin_inset ERT", "status collapsed", "",
"\\begin_layout Plain Layout", "", "", "\\backslash",
"\\begin_layout Plain Layout", "", "", "\\backslash",
cmd + "{", "\\end_layout", "", "\\end_inset"]
substj = ["\\size default", "", "\\begin_inset ERT", "status collapsed", "",
"\\begin_layout Plain Layout", "", "}", "\\end_layout", "", "\\end_inset"]
@ -168,7 +167,7 @@ def revert_phantom_types(document, ptype, cmd):
def revert_phantom(document):
revert_phantom_types(document, "Phantom", "phantom")
def revert_hphantom(document):
revert_phantom_types(document, "HPhantom", "hphantom")
@ -200,7 +199,7 @@ def revert_xetex(document):
roman = sans = typew = "default"
osf = False
sf_scale = tt_scale = 100.0
i = find_token(document.header, "\\font_roman", 0)
if i == -1:
document.warning("Malformed LyX document: Missing \\font_roman.")
@ -214,7 +213,7 @@ def revert_xetex(document):
else:
sans = get_value(document.header, "\\font_sans", i)
document.header[i] = "\\font_sans default"
i = find_token(document.header, "\\font_typewriter", 0)
if i == -1:
document.warning("Malformed LyX document: Missing \\font_typewriter.")
@ -235,7 +234,7 @@ def revert_xetex(document):
else:
# we do not need this value.
document.header[i] = "\\font_sc false"
i = find_token(document.header, "\\font_sf_scale", 0)
if i == -1:
document.warning("Malformed LyX document: Missing \\font_sf_scale.")
@ -286,7 +285,7 @@ def revert_xetex(document):
def revert_outputformat(document):
" Remove default output format param "
if not del_token(document.header, '\\default_output_format', 0):
document.warning("Malformed LyX document: Missing \\default_output_format.")
@ -344,7 +343,7 @@ def revert_splitindex(document):
preamble = []
if useindices:
preamble.append("\\usepackage{splitidx})")
# deal with index declarations in the preamble
i = 0
while True:
@ -355,7 +354,7 @@ def revert_splitindex(document):
if k == -1:
document.warning("Malformed LyX document: Missing \\end_index.")
return
if useindices:
if useindices:
line = document.header[i]
l = re.compile(r'\\index (.*)$')
m = l.match(line)
@ -366,7 +365,7 @@ def revert_splitindex(document):
del document.header[i:k + 1]
if preamble:
insert_to_preamble(document, preamble)
# deal with index insets
# these need to have the argument removed
i = 0
@ -392,7 +391,7 @@ def revert_splitindex(document):
subst = put_cmd_in_ert("\\sindex[" + itype + "]{" + content + "}")
document.body[i:k + 1] = subst
i = i + 1
# deal with index_print insets
i = 0
while True:
@ -431,7 +430,7 @@ def convert_splitindex(document):
if document.body[i + 1].find('LatexCommand printindex') == -1:
document.warning("Malformed LyX document: Incomplete printindex inset.")
return
subst = ["LatexCommand printindex",
subst = ["LatexCommand printindex",
"type \"idx\""]
document.body[i + 1:i + 2] = subst
i = i + 1
@ -515,10 +514,10 @@ def revert_ulinelatex(document):
def revert_custom_processors(document):
" Remove bibtex_command and index_command params "
if not del_token(document.header, '\\bibtex_command', 0):
document.warning("Malformed LyX document: Missing \\bibtex_command.")
if not del_token(document.header, '\\index_command', 0):
document.warning("Malformed LyX document: Missing \\index_command.")
@ -596,10 +595,10 @@ def revert_longtable_align(document):
if j == -1:
i += 1
continue
# FIXME Is this correct? It wipes out everything after the
# FIXME Is this correct? It wipes out everything after the
# one we found.
document.body[fline] = document.body[fline][:j - 1] + '>'
# since there could be a tabular inside this one, we
# since there could be a tabular inside this one, we
# cannot jump to end.
i += 1
@ -743,7 +742,7 @@ def convert_author_id(document):
i = 0
anum = 1
re_author = re.compile(r'(\\author) (\".*\")\s*(.*)$')
while True:
i = find_token(document.header, "\\author", i)
if i == -1:
@ -755,7 +754,7 @@ def convert_author_id(document):
document.header[i] = "\\author %i %s %s" % (anum, name, email)
anum += 1
i += 1
i = 0
while True:
i = find_token(document.body, "\\change_", i)
@ -859,7 +858,7 @@ def revert_mhchem(document):
if mhchem == "off":
# don't load case
return
return
if mhchem == "auto":
i = 0
@ -874,9 +873,9 @@ def revert_mhchem(document):
i += 1
if mhchem == "on":
pre = ["\\PassOptionsToPackage{version=3}{mhchem}",
pre = ["\\PassOptionsToPackage{version=3}{mhchem}",
"\\usepackage{mhchem}"]
insert_to_preamble(document, pre)
insert_to_preamble(document, pre)
def revert_fontenc(document):
@ -926,7 +925,7 @@ def merge_gbrief(document):
document.body[i] = "\\begin_layout " + obsoletedby[layout]
i += 1
document.textclass = "g-brief"
document.set_textclass()
@ -989,7 +988,7 @@ def revert_multirow(document):
if i == -1:
begin_table = end_table
continue
# store the number of rows and columns
numrows = get_option_value(document.body[begin_table], "rows")
numcols = get_option_value(document.body[begin_table], "columns")
@ -1016,13 +1015,13 @@ def revert_multirow(document):
break
begin_cell = begin_row
multirows.append([])
for column in range(numcols):
for column in range(numcols):
begin_cell = find_token(document.body, '<cell ', begin_cell, end_row)
if begin_cell == -1:
document.warning("Can't find column " + str(column + 1) + \
"in row " + str(row + 1))
break
# NOTE
# NOTE
# this will fail if someone puts "</cell>" in a cell, but
# that seems fairly unlikely.
end_cell = find_end_of(document.body, begin_cell, '<cell', '</cell>')
@ -1122,7 +1121,7 @@ def revert_math_output(document):
else:
document.warning("Unable to match " + document.header[i])
document.header[i] = "\\html_use_mathml " + newval
def revert_inset_preview(document):
@ -1137,7 +1136,7 @@ def revert_inset_preview(document):
document.warning("Malformed LyX document: Could not find end of Preview inset.")
i += 1
continue
# This has several issues.
# We need to do something about the layouts inside InsetPreview.
# If we just leave the first one, then we have something like:
@ -1146,16 +1145,16 @@ def revert_inset_preview(document):
# \begin_layout Standard
# and we get a "no \end_layout" error. So something has to be done.
# Ideally, we would check if it is the same as the layout we are in.
# If so, we just remove it; if not, we end the active one. But it is
# If so, we just remove it; if not, we end the active one. But it is
# not easy to know what layout we are in, due to depth changes, etc,
# and it is not clear to me how much work it is worth doing. In most
# cases, the layout will probably be the same.
#
#
# For the same reason, we have to remove the \end_layout tag at the
# end of the last layout in the inset. Again, that will sometimes be
# wrong, but it will usually be right. To know what to do, we would
# again have to know what layout the inset is in.
blay = find_token(document.body, "\\begin_layout", i, iend)
if blay == -1:
document.warning("Can't find layout for preview inset!")
@ -1167,13 +1166,13 @@ def revert_inset_preview(document):
# This is where we would check what layout we are in.
# The check for Standard is definitely wrong.
#
#
# lay = document.body[blay].split(None, 1)[1]
# if lay != oldlayout:
# # record a boolean to tell us what to do later....
# # better to do it later, since (a) it won't mess up
# # the numbering and (b) we only modify at the end.
# we want to delete the last \\end_layout in this inset, too.
# note that this may not be the \\end_layout that goes with blay!!
bend = find_end_of_layout(document.body, blay)
@ -1193,7 +1192,7 @@ def revert_inset_preview(document):
del document.body[bend]
del document.body[i:blay + 1]
# we do not need to reset i
def revert_equalspacing_xymatrix(document):
" Revert a Formula with xymatrix@! to an ERT inset "
@ -1210,12 +1209,12 @@ def revert_equalspacing_xymatrix(document):
document.warning("Malformed LyX document: Could not find end of Formula inset.")
i += 1
continue
for curline in range(i,j):
found = document.body[curline].find("\\xymatrix@!")
if found != -1:
break
if found != -1:
has_equal_spacing = True
content = [document.body[i][21:]]
@ -1230,7 +1229,7 @@ def revert_equalspacing_xymatrix(document):
has_preamble = True;
break;
i = j + 1
if has_equal_spacing and not has_preamble:
add_to_preamble(document, ['\\usepackage[all]{xy}'])
@ -1247,7 +1246,7 @@ def revert_notefontcolor(document):
# are there any grey notes?
if find_token(document.body, "\\begin_inset Note Greyedout", 0) == -1:
# no need to do anything else, and \renewcommand will throw
# no need to do anything else, and \renewcommand will throw
# an error since lyxgreyedout will not exist.
return
@ -1265,21 +1264,21 @@ def revert_notefontcolor(document):
def revert_turkmen(document):
"Set language Turkmen to English"
"Set language Turkmen to English"
if document.language == "turkmen":
document.language = "english"
i = find_token(document.header, "\\language", 0)
if i != -1:
document.header[i] = "\\language english"
if document.language == "turkmen":
document.language = "english"
i = find_token(document.header, "\\language", 0)
if i != -1:
document.header[i] = "\\language english"
j = 0
while True:
j = find_token(document.body, "\\lang turkmen", j)
if j == -1:
return
document.body[j] = document.body[j].replace("\\lang turkmen", "\\lang english")
j += 1
j = 0
while True:
j = find_token(document.body, "\\lang turkmen", j)
if j == -1:
return
document.body[j] = document.body[j].replace("\\lang turkmen", "\\lang english")
j += 1
def revert_fontcolor(document):
@ -1406,7 +1405,7 @@ def convert_html_quotes(document):
m = l.match(line)
if m:
document.header[i] = "\\html_latex_start " + m.group(1)
i = find_token(document.header, '\\html_latex_end', 0)
if i != -1:
line = document.header[i]
@ -1414,11 +1413,11 @@ def convert_html_quotes(document):
m = l.match(line)
if m:
document.header[i] = "\\html_latex_end " + m.group(1)
def revert_html_quotes(document):
" Remove quotes around html_latex_start and html_latex_end "
i = find_token(document.header, '\\html_latex_start', 0)
if i != -1:
line = document.header[i]
@ -1429,7 +1428,7 @@ def revert_html_quotes(document):
del document.header[i]
else:
document.header[i] = "\\html_latex_start \"" + m.group(1) + "\""
i = find_token(document.header, '\\html_latex_end', 0)
if i != -1:
line = document.header[i]
@ -1523,7 +1522,7 @@ def revert_makebox(document):
if j == -1:
i = z
continue
if not check_token(document.body[i], "\\begin_inset Box Frameless") \
or get_value(document.body, 'use_makebox', j) != 1:
del document.body[j]
@ -1634,8 +1633,8 @@ def convert_prettyref(document):
document.body[k] = "LatexCommand formatted"
i = j + 1
document.header.insert(-1, "\\use_refstyle 0")
def revert_refstyle(document):
" Reverts neutral formatted refs to prettyref "
re_ref = re.compile("^reference\s+\"(\w+):(\S+)\"")
@ -1658,7 +1657,7 @@ def revert_refstyle(document):
i = find_token(document.header, "\\use_refstyle", 0)
if i != -1:
document.header.pop(i)
def revert_nameref(document):
" Convert namerefs to regular references "
@ -1713,7 +1712,7 @@ def remove_Nameref(document):
break
cmdloc = i
i += 1
# Make sure it is actually in an inset!
val = is_in_inset(document.body, cmdloc, \
"\\begin_inset CommandInset ref")
@ -1733,7 +1732,7 @@ def revert_mathrsfs(document):
def convert_flexnames(document):
"Convert \\begin_inset Flex Custom:Style to \\begin_inset Flex Style and similarly for CharStyle and Element."
i = 0
rx = re.compile(r'^\\begin_inset Flex (?:Custom|CharStyle|Element):(.+)$')
while True:
@ -1813,7 +1812,7 @@ def revert_flexnames(document):
flexlist = flex_insets
else:
flexlist = flex_elements
rx = re.compile(r'^\\begin_inset Flex\s+(.+)$')
i = 0
while True:
@ -1870,7 +1869,7 @@ def revert_mathdots(document):
# force load case
add_to_preamble(document, ["\\usepackage{mathdots}"])
return
# so we are in the auto case. we want to load mathdots if \iddots is used.
i = 0
while True:
@ -1892,7 +1891,7 @@ def revert_mathdots(document):
def convert_rule(document):
" Convert \\lyxline to CommandInset line. "
i = 0
inset = ['\\begin_inset CommandInset line',
'LatexCommand rule',
'offset "0.5ex"',
@ -1982,7 +1981,7 @@ def revert_diagram(document):
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of Formula inset.")
return
return
lines = "\n".join(document.body[i:j])
if lines.find("\\Diagram") == -1:
i = j
@ -1991,9 +1990,9 @@ def revert_diagram(document):
# only need to do it once!
return
chapters = ("amsbook", "book", "docbook-book", "elsart", "extbook", "extreport",
"jbook", "jreport", "jsbook", "literate-book", "literate-report", "memoir",
"mwbk", "mwrep", "recipebook", "report", "scrbook", "scrreprt", "svmono",
chapters = ("amsbook", "book", "docbook-book", "elsart", "extbook", "extreport",
"jbook", "jreport", "jsbook", "literate-book", "literate-report", "memoir",
"mwbk", "mwrep", "recipebook", "report", "scrbook", "scrreprt", "svmono",
"svmult", "tbook", "treport", "tufte-book")
def convert_bibtex_clearpage(document):
@ -2037,13 +2036,13 @@ def convert_bibtex_clearpage(document):
document.warning("Can't find options for bibliography inset at line " + str(j))
j = k
continue
if val.find("bibtotoc") == -1:
j = k
continue
# so we want to insert a new page right before the paragraph that
# this bibliography thing is in.
# this bibliography thing is in.
lay = find_token_backwards(document.body, "\\begin_layout", j)
if lay == -1:
document.warning("Can't find layout containing bibliography inset at line " + str(j))
@ -2078,7 +2077,7 @@ def convert_passthru(document):
" http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg161298.html "
if not check_passthru:
return
rx = re.compile("\\\\begin_layout \s*(\w+)")
beg = 0
for lay in ["Chunk", "Scrap"]:
@ -2137,7 +2136,7 @@ def convert_passthru(document):
beg = end + 1
if didit:
beg += 4 # for the extra layout
def revert_passthru(document):
" http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg161298.html "
@ -2155,7 +2154,7 @@ def revert_passthru(document):
document.warning("Can't find end of layout at line " + str(beg))
beg += 1
continue
# we now want to find out if the next layout is the
# same as this one. but we will need to do this over and
# over again.
@ -2236,7 +2235,7 @@ def revert_multirowOffset(document):
if i == -1:
begin_table = end_table
continue
# store the number of rows and columns
numrows = get_option_value(document.body[begin_table], "rows")
numcols = get_option_value(document.body[begin_table], "columns")
@ -2263,13 +2262,13 @@ def revert_multirowOffset(document):
break
begin_cell = begin_row
multirows.append([])
for column in range(numcols):
for column in range(numcols):
begin_cell = find_token(document.body, '<cell ', begin_cell, end_row)
if begin_cell == -1:
document.warning("Can't find column " + str(column + 1) + \
"in row " + str(row + 1))
break
# NOTE
# NOTE
# this will fail if someone puts "</cell>" in a cell, but
# that seems fairly unlikely.
end_cell = find_end_of(document.body, begin_cell, '<cell', '</cell>')
@ -2321,7 +2320,7 @@ def revert_multirowOffset(document):
replace('valignment="middle"', 'valignment="top"')
# remove mroffset option
document.body[bcell] = rgx.sub('', document.body[bcell])
blay = find_token(document.body, "\\begin_layout", bcell, ecell)
if blay == -1:
document.warning("Can't find layout for cell!")

View File

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# This file is part of lyx2lyx
# -*- coding: utf-8 -*-
# Copyright (C) 2011 The LyX team
#
# This program is free software; you can redistribute it and/or
@ -117,7 +116,7 @@ def convert_TeX_brace_to_Argument(document, line, n, nmax, inset, environment, o
isInset must be true, if braces inside an InsetLayout needs to be converted
isEnvironment must be true, if the layout is for a LaTeX environment
isOpt must be true, if the argument is an optional one
Todo: this routine can currently handle only one mandatory argument of environments
'''
@ -168,7 +167,7 @@ def convert_TeX_brace_to_Argument(document, line, n, nmax, inset, environment, o
n += 1
endn = end
loop += 1
else:
else:
# no brace pair found
# now check the case that we have "}" + "{" in two ERTs
if opt:
@ -449,16 +448,16 @@ def revert_justification(document):
def revert_australian(document):
"Set English language variants Australian and Newzealand to English"
"Set English language variants Australian and Newzealand to English"
if document.language == "australian" or document.language == "newzealand":
if document.language == "australian" or document.language == "newzealand":
document.language = "english"
i = find_token(document.header, "\\language", 0)
if i != -1:
document.header[i] = "\\language english"
j = 0
while True:
j = find_token(document.body, "\\lang australian", j)
i = find_token(document.header, "\\language", 0)
if i != -1:
document.header[i] = "\\language english"
j = 0
while True:
j = find_token(document.body, "\\lang australian", j)
if j == -1:
j = find_token(document.body, "\\lang newzealand", 0)
if j == -1:
@ -466,7 +465,7 @@ def revert_australian(document):
else:
document.body[j] = document.body[j].replace("\\lang newzealand", "\\lang english")
else:
document.body[j] = document.body[j].replace("\\lang australian", "\\lang english")
document.body[j] = document.body[j].replace("\\lang australian", "\\lang english")
j += 1
@ -565,7 +564,7 @@ def handle_longtable_captions(document, forward):
if get_option_value(document.body[begin_row], 'endlastfoot') == 'true':
document.body[begin_row] = set_option_value(document.body[begin_row], 'endlastfoot', 'false')
begin_row = end_row
# since there could be a tabular inside this one, we
# since there could be a tabular inside this one, we
# cannot jump to end.
begin_table += 1
@ -975,9 +974,9 @@ def revert_cell_rotation(document):
put_cmd_in_ert("\\end{turn}")
document.body[i + 4 : i + 4] = \
put_cmd_in_ert("\\begin{turn}{" + value + "}")
i += 1
finally:
if load_rotating:
add_to_preamble(document, ["\\@ifundefined{turnbox}{\\usepackage{rotating}}{}"])
@ -997,7 +996,7 @@ def convert_cell_rotation(document):
rgx = re.compile(r'rotate="[^"]+?"')
# convert "true" to "90"
document.body[i] = rgx.sub('rotate="90"', document.body[i])
i += 1
@ -1034,9 +1033,9 @@ def revert_table_rotation(document):
put_cmd_in_ert("\\end{turn}")
document.body[i - 2 : i - 2] = \
put_cmd_in_ert("\\begin{turn}{" + value + "}")
i += 1
finally:
if load_rotating:
add_to_preamble(document, ["\\@ifundefined{turnbox}{\\usepackage{rotating}}{}"])
@ -1056,7 +1055,7 @@ def convert_table_rotation(document):
rgx = re.compile(r'rotate="[^"]+?"')
# convert "true" to "90"
document.body[i] = rgx.sub('rotate="90"', document.body[i])
i += 1
@ -1150,25 +1149,25 @@ def revert_use_cancel(document):
def revert_ancientgreek(document):
"Set the document language for ancientgreek to greek"
"Set the document language for ancientgreek to greek"
if document.language == "ancientgreek":
if document.language == "ancientgreek":
document.language = "greek"
i = find_token(document.header, "\\language", 0)
if i != -1:
document.header[i] = "\\language greek"
j = 0
while True:
j = find_token(document.body, "\\lang ancientgreek", j)
i = find_token(document.header, "\\language", 0)
if i != -1:
document.header[i] = "\\language greek"
j = 0
while True:
j = find_token(document.body, "\\lang ancientgreek", j)
if j == -1:
return
else:
document.body[j] = document.body[j].replace("\\lang ancientgreek", "\\lang greek")
document.body[j] = document.body[j].replace("\\lang ancientgreek", "\\lang greek")
j += 1
def revert_languages(document):
"Set the document language for new supported languages to English"
"Set the document language for new supported languages to English"
languages = [
"coptic", "divehi", "hindi", "kurmanji", "lao", "marathi", "occitan", "sanskrit",
@ -1177,11 +1176,11 @@ def revert_languages(document):
for n in range(len(languages)):
if document.language == languages[n]:
document.language = "english"
i = find_token(document.header, "\\language", 0)
if i != -1:
document.header[i] = "\\language english"
i = find_token(document.header, "\\language", 0)
if i != -1:
document.header[i] = "\\language english"
j = 0
while j < len(document.body):
while j < len(document.body):
j = find_token(document.body, "\\lang " + languages[n], j)
if j != -1:
document.body[j] = document.body[j].replace("\\lang " + languages[n], "\\lang english")
@ -1191,27 +1190,27 @@ def revert_languages(document):
def convert_armenian(document):
"Use polyglossia and thus non-TeX fonts for Armenian"
"Use polyglossia and thus non-TeX fonts for Armenian"
if document.language == "armenian":
i = find_token(document.header, "\\use_non_tex_fonts", 0)
if i != -1:
document.header[i] = "\\use_non_tex_fonts true"
if document.language == "armenian":
i = find_token(document.header, "\\use_non_tex_fonts", 0)
if i != -1:
document.header[i] = "\\use_non_tex_fonts true"
def revert_armenian(document):
"Use ArmTeX and thus TeX fonts for Armenian"
"Use ArmTeX and thus TeX fonts for Armenian"
if document.language == "armenian":
i = find_token(document.header, "\\use_non_tex_fonts", 0)
if i != -1:
document.header[i] = "\\use_non_tex_fonts false"
if document.language == "armenian":
i = find_token(document.header, "\\use_non_tex_fonts", 0)
if i != -1:
document.header[i] = "\\use_non_tex_fonts false"
def revert_libertine(document):
" Revert native libertine font definition to LaTeX "
" Revert native libertine font definition to LaTeX "
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
i = find_token(document.header, "\\font_roman libertine", 0)
if i != -1:
osf = False
@ -1230,9 +1229,9 @@ def revert_libertine(document):
def revert_txtt(document):
" Revert native txtt font definition to LaTeX "
" Revert native txtt font definition to LaTeX "
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
i = find_token(document.header, "\\font_typewriter txtt", 0)
if i != -1:
preamble = "\\renewcommand{\\ttdefault}{txtt}"
@ -1241,9 +1240,9 @@ def revert_txtt(document):
def revert_mathdesign(document):
" Revert native mathdesign font definition to LaTeX "
" Revert native mathdesign font definition to LaTeX "
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
mathdesign_dict = {
"mdbch": "charter",
"mdput": "utopia",
@ -1272,9 +1271,9 @@ def revert_mathdesign(document):
def revert_texgyre(document):
" Revert native TeXGyre font definition to LaTeX "
" Revert native TeXGyre font definition to LaTeX "
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
texgyre_fonts = ["tgadventor", "tgbonum", "tgchorus", "tgcursor", \
"tgheros", "tgpagella", "tgschola", "tgtermes"]
i = find_token(document.header, "\\font_roman", 0)
@ -1331,7 +1330,7 @@ def revert_ipadeco(document):
i = end
continue
substi = ["\\begin_inset ERT", "status collapsed", "",
"\\begin_layout Plain Layout", "", "", "\\backslash",
"\\begin_layout Plain Layout", "", "", "\\backslash",
decotype + "{", "\\end_layout", "", "\\end_inset"]
substj = ["\\size default", "", "\\begin_inset ERT", "status collapsed", "",
"\\begin_layout Plain Layout", "", "}", "\\end_layout", "", "\\end_inset"]
@ -1371,9 +1370,9 @@ def revert_ipachar(document):
def revert_minionpro(document):
" Revert native MinionPro font definition to LaTeX "
" Revert native MinionPro font definition to LaTeX "
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
i = find_token(document.header, "\\font_roman minionpro", 0)
if i != -1:
osf = False
@ -1391,12 +1390,12 @@ def revert_minionpro(document):
def revert_mathfonts(document):
" Revert native math font definitions to LaTeX "
" Revert native math font definitions to LaTeX "
i = find_token(document.header, "\\font_math", 0)
if i == -1:
return
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
val = get_value(document.header, "\\font_math", i)
if val == "eulervm":
add_to_preamble(document, "\\usepackage{eulervm}")
@ -1426,9 +1425,9 @@ def revert_mathfonts(document):
def revert_mdnomath(document):
" Revert mathdesign and fourier without math "
" Revert mathdesign and fourier without math "
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
mathdesign_dict = {
"md-charter": "mdbch",
"md-utopia": "mdput",
@ -1455,9 +1454,9 @@ def convert_mathfonts(document):
def convert_mdnomath(document):
" Change mathdesign font name "
" Change mathdesign font name "
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
mathdesign_dict = {
"mdbch": "md-charter",
"mdput": "md-utopia",
@ -1472,12 +1471,12 @@ def convert_mdnomath(document):
def revert_newtxmath(document):
" Revert native newtxmath definitions to LaTeX "
" Revert native newtxmath definitions to LaTeX "
i = find_token(document.header, "\\font_math", 0)
if i == -1:
return
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
val = get_value(document.header, "\\font_math", i)
mathfont_dict = {
"libertine-ntxm": "\\usepackage[libertine]{newtxmath}",
@ -1490,9 +1489,9 @@ def revert_newtxmath(document):
def revert_biolinum(document):
" Revert native biolinum font definition to LaTeX "
" Revert native biolinum font definition to LaTeX "
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
i = find_token(document.header, "\\font_sans biolinum", 0)
if i != -1:
osf = False
@ -1595,7 +1594,7 @@ def convert_latexargs(document):
document.body[i] = "\\begin_inset Argument 999"
i += 1
continue
# Find containing paragraph layout
parent = get_containing_layout(document.body, i)
if parent == False:
@ -2174,7 +2173,7 @@ def revert_literate(document):
def convert_literate(document):
" Convert Literate document to new format"
i = find_token(document.header, "\\textclass", 0)
i = find_token(document.header, "\\textclass", 0)
if (i != -1) and "literate-" in document.header[i]:
document.textclass = document.header[i].replace("\\textclass literate-", "")
j = find_token(document.header, "\\begin_modules", 0)
@ -2218,12 +2217,12 @@ def revert_itemargs(document):
def revert_garamondx_newtxmath(document):
" Revert native garamond newtxmath definition to LaTeX "
" Revert native garamond newtxmath definition to LaTeX "
i = find_token(document.header, "\\font_math", 0)
if i == -1:
return
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
val = get_value(document.header, "\\font_math", i)
if val == "garamondx-ntxm":
add_to_preamble(document, "\\usepackage[garamondx]{newtxmath}")
@ -2231,9 +2230,9 @@ def revert_garamondx_newtxmath(document):
def revert_garamondx(document):
" Revert native garamond font definition to LaTeX "
" Revert native garamond font definition to LaTeX "
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
i = find_token(document.header, "\\font_roman garamondx", 0)
if i != -1:
osf = False
@ -2250,7 +2249,7 @@ def revert_garamondx(document):
def convert_beamerargs(document):
" Converts beamer arguments to new layout "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
@ -2421,7 +2420,7 @@ def convert_againframe_args(document):
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
i = 0
while True:
i = find_token(document.body, "\\begin_layout AgainFrame", i)
@ -2443,11 +2442,11 @@ def convert_againframe_args(document):
def convert_corollary_args(document):
" Converts beamer corrolary-style ERT arguments native InsetArgs "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
corollary_layouts = ["Corollary", "Definition", "Definitions", "Example", "Examples", "Fact", "Proof", "Theorem"]
for lay in corollary_layouts:
i = 0
@ -2533,11 +2532,11 @@ def convert_corollary_args(document):
def convert_quote_args(document):
" Converts beamer quote style ERT args to native InsetArgs "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
quote_layouts = ["Uncover", "Only", "Quotation", "Quote", "Verse"]
for lay in quote_layouts:
i = 0
@ -2602,7 +2601,7 @@ def cleanup_beamerargs(document):
def revert_beamerargs(document):
" Reverts beamer arguments to old layout "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
@ -2793,13 +2792,13 @@ def revert_beamerargs(document):
del document.body[p : endInset + 1]
subst = put_cmd_in_ert("[") + content + put_cmd_in_ert("]")
document.body[realparbeg : realparbeg] = subst
i = realparend
def revert_beamerargs2(document):
" Reverts beamer arguments to old layout, step 2 "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
@ -2833,7 +2832,7 @@ def revert_beamerargs2(document):
if m:
argnr = m.group(1)
if argnr == "2":
document.body[p] = "\\begin_inset Argument 1"
document.body[p] = "\\begin_inset Argument 1"
if layoutname in corollary_layouts:
m = rx.match(document.body[p])
if m:
@ -2884,7 +2883,7 @@ def revert_beamerargs2(document):
def revert_beamerargs3(document):
" Reverts beamer arguments to old layout, step 3 "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
@ -2930,7 +2929,7 @@ def revert_beamerargs3(document):
def revert_beamerflex(document):
" Reverts beamer Flex insets "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
@ -3030,13 +3029,13 @@ def revert_beamerflex(document):
document.body[i : beginPlain + 1] = pre
post = put_cmd_in_ert("}")
document.body[z - 2 : z + 1] = post
i += 1
def revert_beamerblocks(document):
" Reverts beamer block arguments to ERT "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
@ -3096,11 +3095,11 @@ def revert_beamerblocks(document):
def convert_beamerblocks(document):
" Converts beamer block ERT args to native InsetArgs "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
blocks = ["Block", "ExampleBlock", "AlertBlock"]
for lay in blocks:
i = 0
@ -3211,7 +3210,7 @@ def convert_beamerblocks(document):
document.body[ertcontlastline : ertcontlastline + 1] = [
document.body[ertcontlastline], '\\end_layout', '', '\\end_inset']
document.body[ertcontdivline : ertcontdivlinetwo + 1] = [document.body[ertcontdivline][:tok],
'\\end_layout', '', '\\end_inset', '', '\\end_layout', '',
'\\end_layout', '', '\\end_inset', '', '\\end_layout', '',
'\\end_inset', '', '', '\\begin_inset Argument 2',
'status collapsed', '', '\\begin_layout Plain Layout',
'\\begin_inset ERT', '', 'status open' '', '\\begin_layout Plain Layout',
@ -3300,7 +3299,7 @@ def convert_beamerblocks(document):
document.body[ertcontlastline : ertcontlastline + 1] = [
document.body[ertcontlastline], '\\end_layout', '', '\\end_inset']
document.body[ertcontdivline : ertcontdivlinetwo + 1] = [document.body[ertcontdivline][:tok],
'\\end_layout', '', '\\end_inset', '', '\\end_layout', '',
'\\end_layout', '', '\\end_inset', '', '\\end_layout', '',
'\\end_inset', '', '', '\\begin_inset Argument 1',
'status collapsed', '', '\\begin_layout Plain Layout',
'\\begin_inset ERT', '', 'status open' '', '\\begin_layout Plain Layout',
@ -3346,7 +3345,7 @@ def convert_beamerblocks(document):
def convert_overprint(document):
" Convert old beamer overprint layouts to ERT "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
@ -3386,11 +3385,11 @@ def convert_overprint(document):
# Remove arg inset
del document.body[argbeg : argend + 1]
subst += put_cmd_in_ert("[") + content + put_cmd_in_ert("]")
endseq = endseq - len(document.body[i : i])
document.body[i : i] = subst + ["\\end_layout"]
endseq += len(subst)
for p in range(i, endseq):
if document.body[p] == "\\begin_layout Overprint":
document.body[p] = "\\begin_layout Standard"
@ -3400,7 +3399,7 @@ def convert_overprint(document):
def revert_overprint(document):
" Revert old beamer overprint layouts to ERT "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
@ -3452,11 +3451,11 @@ def revert_overprint(document):
# Remove arg inset
del document.body[argbeg : argend + 1]
subst += put_cmd_in_ert("[") + content + put_cmd_in_ert("]")
endseq = endseq - len(document.body[i : i])
document.body[i : i] = subst + ["\\end_layout"]
endseq += len(subst)
p = i
while True:
if p >= endseq:
@ -3492,7 +3491,7 @@ def revert_overprint(document):
def revert_frametitle(document):
" Reverts beamer frametitle layout to ERT "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
@ -3538,7 +3537,7 @@ def revert_frametitle(document):
# Remove arg inset
del document.body[p : endInset + 1]
subst += put_cmd_in_ert("[") + content + put_cmd_in_ert("]")
subst += put_cmd_in_ert("{")
document.body[i : i + 1] = subst
i = endlay
@ -3546,7 +3545,7 @@ def revert_frametitle(document):
def convert_epigraph(document):
" Converts memoir epigraph to new syntax "
if document.textclass != "memoir":
return
@ -3581,13 +3580,13 @@ def convert_epigraph(document):
endlay += len(begsubst) + len(endsubst)
endlay = endlay - len(document.body[ert : endInset + 1])
del document.body[ert : endInset + 1]
i = endlay
def revert_epigraph(document):
" Reverts memoir epigraph argument to ERT "
if document.textclass != "memoir":
return
@ -3616,14 +3615,14 @@ def revert_epigraph(document):
subst += put_cmd_in_ert("}{") + content
else:
subst += put_cmd_in_ert("}{")
document.body[j : j] = subst + document.body[j : j]
i = endlay
def convert_captioninsets(document):
" Converts caption insets to new syntax "
i = 0
while True:
i = find_token(document.body, "\\begin_inset Caption", i)
@ -3635,7 +3634,7 @@ def convert_captioninsets(document):
def revert_captioninsets(document):
" Reverts caption insets to old syntax "
i = 0
while True:
i = find_token(document.body, "\\begin_inset Caption Standard", i)
@ -3678,7 +3677,7 @@ def convert_captionlayouts(document):
def revert_captionlayouts(document):
" Revert caption insets to caption layouts. "
caption_dict = {
"Above" : "Captionabove",
"Below" : "Captionbelow",
@ -3687,7 +3686,7 @@ def revert_captionlayouts(document):
"Centered" : "CenteredCaption",
"Bicaption" : "Bicaption",
}
i = 0
rx = re.compile(r'^\\begin_inset Caption (\S+)$')
while True:
@ -3702,7 +3701,7 @@ def revert_captionlayouts(document):
if val not in list(caption_dict.keys()):
i += 1
continue
# We either need to delete the previous \begin_layout line, or we
# need to end the previous layout if this inset is not in the first
# position of the paragraph.
@ -3770,7 +3769,7 @@ def revert_captionlayouts(document):
def revert_fragileframe(document):
" Reverts beamer FragileFrame layout to ERT "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
@ -3852,14 +3851,14 @@ def revert_fragileframe(document):
subst += put_cmd_in_ert("{") + content + put_cmd_in_ert("}")
elif p == 3:
subst += put_cmd_in_ert("[fragile]")
document.body[i : i + 1] = subst
i = j
def revert_newframes(document):
" Reverts beamer Frame and PlainFrame layouts to old forms "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
@ -3954,7 +3953,7 @@ def revert_newframes(document):
# Remove arg inset
del document.body[arg : endInset + 1]
subst += content
document.body[i : i + 1] = subst
i = j
@ -4079,18 +4078,18 @@ def revert_IEEEtran_3(document):
def revert_kurier_fonts(document):
" Revert kurier font definition to LaTeX "
i = find_token(document.header, "\\font_math", 0)
if i != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
val = get_value(document.header, "\\font_math", i)
if val == "kurier-math":
add_to_preamble(document, "\\let\\Myrmdefault\\rmdefault\n" \
"\\usepackage[math]{kurier}\n" \
"\\renewcommand{\\rmdefault}{\\Myrmdefault}")
document.header[i] = "\\font_math auto"
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
kurier_fonts = ["kurier", "kurierc", "kurierl", "kurierlc"]
k = find_token(document.header, "\\font_sans kurier", 0)
if k != -1:
@ -4101,18 +4100,18 @@ def revert_kurier_fonts(document):
def revert_iwona_fonts(document):
" Revert iwona font definition to LaTeX "
i = find_token(document.header, "\\font_math", 0)
if i != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
val = get_value(document.header, "\\font_math", i)
if val == "iwona-math":
add_to_preamble(document, "\\let\\Myrmdefault\\rmdefault\n" \
"\\usepackage[math]{iwona}\n" \
"\\renewcommand{\\rmdefault}{\\Myrmdefault}")
document.header[i] = "\\font_math auto"
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
iwona_fonts = ["iwona", "iwonac", "iwonal", "iwonalc"]
k = find_token(document.header, "\\font_sans iwona", 0)
if k != -1:
@ -4124,7 +4123,7 @@ def revert_iwona_fonts(document):
def revert_new_libertines(document):
" Revert new libertine font definition to LaTeX "
if find_token(document.header, "\\use_non_tex_fonts true", 0) != -1:
return
@ -4140,7 +4139,7 @@ def revert_new_libertines(document):
preamble += "{libertineMono-type1}"
add_to_preamble(document, [preamble])
document.header[i] = "\\font_typewriter default"
k = find_token(document.header, "\\font_sans biolinum", 0)
if k != -1:
preamble = "\\usepackage"
@ -4165,11 +4164,11 @@ def revert_new_libertines(document):
def convert_lyxframes(document):
" Converts old beamer frames to new style "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
framebeg = ["BeginFrame", "BeginPlainFrame"]
frameend = ["Frame", "PlainFrame", "EndFrame", "BeginFrame", "BeginPlainFrame", "AgainFrame",
"Section", "Section*", "Subsection", "Subsection*", "Subsubsection", "Subsubsection*"]
@ -4238,11 +4237,11 @@ def convert_lyxframes(document):
def remove_endframes(document):
" Remove deprecated beamer endframes "
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
if document.textclass not in beamer_classes:
return
i = 0
while True:
i = find_token_exact(document.body, "\\begin_layout EndFrame", i)
@ -4258,7 +4257,7 @@ def remove_endframes(document):
def revert_powerdot_flexes(document):
" Reverts powerdot flex insets "
if document.textclass != "powerdot":
return
@ -4306,13 +4305,13 @@ def revert_powerdot_flexes(document):
z += len(pre)
document.body[i : beginPlain + 1] = pre
post = put_cmd_in_ert("}")
document.body[z - 2 : z + 1] = post
document.body[z - 2 : z + 1] = post
i += 1
def revert_powerdot_pause(document):
" Reverts powerdot pause layout to ERT "
if document.textclass != "powerdot":
return
@ -4342,14 +4341,14 @@ def revert_powerdot_pause(document):
# Remove arg inset
del document.body[p : endInset + 1]
subst += put_cmd_in_ert("[") + content + put_cmd_in_ert("]")
document.body[i : i + 1] = subst
i = endlay
def revert_powerdot_itemargs(document):
" Reverts powerdot item arguments to ERT "
if document.textclass != "powerdot":
return
@ -4398,7 +4397,7 @@ def revert_powerdot_itemargs(document):
del document.body[i:j+1]
subst = put_cmd_in_ert("<") + content + put_cmd_in_ert(">")
document.body[realparbeg : realparbeg] = subst
i = realparend
@ -4448,7 +4447,7 @@ def revert_powerdot_columns(document):
# Remove arg inset
del document.body[p : endInset + 1]
subst += put_cmd_in_ert("{") + content + put_cmd_in_ert("}")
subst += put_cmd_in_ert("{")
document.body[i : i + 1] = subst
i = endlay
@ -4485,7 +4484,7 @@ def revert_mbox_fbox(document):
def revert_starred_caption(document):
" Reverts unnumbered longtable caption insets "
i = 0
while True:
i = find_token(document.body, "\\begin_inset Caption LongTableNoNumber", i)
@ -4560,15 +4559,15 @@ def revert_aa2(document):
def revert_tibetan(document):
"Set the document language for Tibetan to English"
"Set the document language for Tibetan to English"
if document.language == "tibetan":
document.language = "english"
i = find_token(document.header, "\\language", 0)
if i != -1:
document.header[i] = "\\language english"
i = find_token(document.header, "\\language", 0)
if i != -1:
document.header[i] = "\\language english"
j = 0
while j < len(document.body):
while j < len(document.body):
j = find_token(document.body, "\\lang tibetan", j)
if j != -1:
document.body[j] = document.body[j].replace("\\lang tibetan", "\\lang english")
@ -4612,14 +4611,14 @@ def convert_chunks(document):
# there is no point continuing, as we will run into the same error again.
return
this_chunk = "".join(document.body[i + 1:j])
# there may be empty lines between chunks
# we just skip them.
if not chunk_started:
if this_chunk != "":
# new chunk starts
chunk_started = True
if chunk_started:
contents.append(document.body[i + 1:j])
@ -4666,7 +4665,7 @@ def convert_chunks(document):
# the first par (separated from the options by a newline).
# We collect such stuff to re-insert it later.
postoptstuff = []
match = first_re.search(optarg)
if match:
optarg = match.groups()[0]
@ -4806,7 +4805,7 @@ def revert_chunks(document):
# replace old content with new content
document.body[lstart : lend + 1] = newlines
i = lstart + len(newlines)
##
# Conversion hub

View File

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# This file is part of lyx2lyx
# -*- coding: utf-8 -*-
# Copyright (C) 2015 The LyX team
#
# This program is free software; you can redistribute it and/or
@ -78,7 +77,7 @@ def revert_Argument_to_TeX_brace(document, line, endline, n, nmax, environment,
if nolastopt == False:
document.body[endInset - 2 : endInset + 1] = put_cmd_in_ert("}{")
else:
document.body[endInset - 2 : endInset + 1] = put_cmd_in_ert("}")
document.body[endInset - 2 : endInset + 1] = put_cmd_in_ert("}")
del(document.body[lineArg : beginPlain + 1])
wasOpt = False
else:
@ -1196,7 +1195,7 @@ def revert_textcolor(document):
j = find_token(document.body, "\\color", i + 1)
k = find_token(document.body, "\\end_layout", i + 1)
if j == -1 and k != -1:
j = k +1
j = k +1
# output TeX code
# first output the closing brace
if k < j:
@ -1697,7 +1696,7 @@ def revert_tcolorbox_1(document):
i = find_token(document.header, "tcolorbox", i)
if i == -1:
break
else:
else:
flex = 0
flexEnd = -1
flex = find_token(document.body, "\\begin_inset Flex Subtitle", flex)
@ -1722,7 +1721,7 @@ def revert_tcolorbox_2(document):
i = find_token(document.header, "tcolorbox", i)
if i == -1:
break
else:
else:
flex = 0
flexEnd = -1
flex = find_token(document.body, "\\begin_inset Flex Raster Color Box", flex)
@ -1743,7 +1742,7 @@ def revert_tcolorbox_3(document):
i = find_token(document.header, "tcolorbox", i)
if i == -1:
break
else:
else:
flex = 0
flexEnd = -1
flex = find_token(document.body, "\\begin_inset Flex Custom Color Box 1", flex)
@ -1765,7 +1764,7 @@ def revert_tcolorbox_4(document):
i = find_token(document.header, "tcolorbox", i)
if i == -1:
break
else:
else:
flex = 0
flexEnd = -1
flex = find_token(document.body, "\\begin_inset Flex Custom Color Box 2", flex)
@ -1787,7 +1786,7 @@ def revert_tcolorbox_5(document):
i = find_token(document.header, "tcolorbox", i)
if i == -1:
break
else:
else:
flex = 0
flexEnd = -1
flex = find_token(document.body, "\\begin_inset Flex Custom Color Box 3", flex)
@ -1809,7 +1808,7 @@ def revert_tcolorbox_6(document):
i = find_token(document.header, "tcolorbox", i)
if i == -1:
break
else:
else:
flex = 0
flexEnd = -1
flex = find_token(document.body, "\\begin_inset Flex Custom Color Box 4", flex)
@ -1831,7 +1830,7 @@ def revert_tcolorbox_7(document):
i = find_token(document.header, "tcolorbox", i)
if i == -1:
break
else:
else:
flex = 0
flexEnd = -1
flex = find_token(document.body, "\\begin_inset Flex Custom Color Box 5", flex)
@ -1879,7 +1878,7 @@ def revert_tcolorbox_8(document):
def revert_moderncv_1(document):
" Reverts the new inset of moderncv to TeX-code in preamble "
if document.textclass != "moderncv":
return
i = 0
@ -1947,7 +1946,7 @@ def revert_moderncv_1(document):
def revert_moderncv_2(document):
" Reverts the phone inset of moderncv to the obsoleted mobile or fax "
if document.textclass != "moderncv":
return
i = 0
@ -2089,7 +2088,7 @@ def convert_moderncv_name(document):
def revert_achemso(document):
" Reverts the flex inset Latin to TeX code "
if document.textclass != "achemso":
return
i = 0

View File

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
# This file is part of lyx2lyx
# -*- coding: utf-8 -*-
# Copyright (C) 2016 The LyX team
#
# This program is free software; you can redistribute it and/or
@ -99,7 +98,7 @@ def convert_inputenc(document):
return
if get_value(document.header, "\\inputencoding", i) == "pt254":
document.header[i] = "\\inputencoding pt154"
def convert_ibranches(document):
' Add "inverted 0" to branch insets'
@ -129,7 +128,7 @@ def revert_ibranches(document):
else:
document.warning("Malformed LyX document: No selection indicator for branch " + branch)
selected = 1
# the value tells us whether the branch is selected
ourbranches[document.header[i][8:].strip()] = selected
i += 1
@ -582,7 +581,7 @@ def revert_quotes(document):
replace = "'"
document.body[k:l+1] = [replace]
i = l
def revert_iopart(document):
" Input new styles via local layout "
@ -1031,7 +1030,7 @@ def revert_cjkquotes(document):
def revert_crimson(document):
" Revert native Cochineal/Crimson font definition to LaTeX "
" Revert native Cochineal/Crimson font definition to LaTeX "
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
preamble = ""
@ -1051,9 +1050,9 @@ def revert_crimson(document):
def revert_cochinealmath(document):
" Revert cochineal newtxmath definitions to LaTeX "
" Revert cochineal newtxmath definitions to LaTeX "
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
i = find_token(document.header, "\\font_math \"cochineal-ntxm\"", 0)
if i != -1:
add_to_preamble(document, "\\usepackage[cochineal]{newtxmath}")
@ -1940,7 +1939,7 @@ def revert_dashligatures(document):
document.body[i] = document.body[i][:j+1] + u"\u200B" + after
start = j+1
i += 1
##
# Conversion hub