1 # -*- coding: utf-8 -*-
2 # This file is part of lyx2lyx
3 # -*- coding: utf-8 -*-
4 # Copyright (C) 2011 The LyX team
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 """ Convert files to the file format generated by lyx 2.1"""
26 # Uncomment only what you need to import, please.
28 from parser_tools import del_token, find_token, find_end_of, find_end_of_inset, \
29 find_end_of_layout, find_re, get_option_value, get_value, get_quoted_value, \
32 #from parser_tools import find_token, find_end_of, find_tokens, \
33 #find_token_exact, find_end_of_inset, find_end_of_layout, \
34 #find_token_backwards, is_in_inset, del_token, check_token
36 from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert, get_ert
38 #from lyx2lyx_tools import insert_to_preamble, \
39 # lyx2latex, latex_length, revert_flex_inset, \
40 # revert_font_attrs, hex2ratio, str2bool
42 ####################################################################
43 # Private helper functions
45 #def remove_option(lines, m, option):
46 #''' removes option from line m. returns whether we did anything '''
47 #l = lines[m].find(option)
50 #val = lines[m][l:].split('"')[1]
51 #lines[m] = lines[m][:l - 1] + lines[m][l+len(option + '="' + val + '"'):]
55 ###############################################################################
57 ### Conversion and reversion routines
59 ###############################################################################
61 def revert_visible_space(document):
62 "Revert InsetSpace visible into its ERT counterpart"
65 i = find_token(document.body, "\\begin_inset space \\textvisiblespace{}", i)
68 end = find_end_of_inset(document.body, i)
69 subst = put_cmd_in_ert("\\textvisiblespace{}")
70 document.body[i:end + 1] = subst
73 def convert_undertilde(document):
74 " Load undertilde automatically "
75 i = find_token(document.header, "\\use_mathdots" , 0)
77 i = find_token(document.header, "\\use_mhchem" , 0)
79 i = find_token(document.header, "\\use_esint" , 0)
81 document.warning("Malformed LyX document: Can't find \\use_mathdots.")
83 j = find_token(document.preamble, "\\usepackage{undertilde}", 0)
85 document.header.insert(i + 1, "\\use_undertilde 0")
87 document.header.insert(i + 1, "\\use_undertilde 2")
88 del document.preamble[j]
91 def revert_undertilde(document):
92 " Load undertilde if used in the document "
93 undertilde = find_token(document.header, "\\use_undertilde" , 0)
95 document.warning("No \\use_undertilde line. Assuming auto.")
97 val = get_value(document.header, "\\use_undertilde", undertilde)
98 del document.header[undertilde]
102 document.warning("Invalid \\use_undertilde value: " + val + ". Assuming auto.")
103 # probably usedots has not been changed, but be safe.
111 add_to_preamble(document, ["\\usepackage{undertilde}"])
114 # so we are in the auto case. we want to load undertilde if \utilde is used.
117 i = find_token(document.body, '\\begin_inset Formula', i)
120 j = find_end_of_inset(document.body, i)
122 document.warning("Malformed LyX document: Can't find end of Formula inset at line " + str(i))
125 code = "\n".join(document.body[i:j])
126 if code.find("\\utilde") != -1:
127 add_to_preamble(document, ["\\@ifundefined{utilde}{\\usepackage{undertilde}}"])
132 def revert_negative_space(document):
133 "Revert InsetSpace negmedspace and negthickspace into its TeX-code counterpart"
138 i = find_token(document.body, "\\begin_inset space \\negmedspace{}", i)
140 j = find_token(document.body, "\\begin_inset space \\negthickspace{}", j)
142 # load amsmath in the preamble if not already loaded if we are at the end of checking
144 i = find_token(document.header, "\\use_amsmath 2", 0)
146 add_to_preamble(document, ["\\@ifundefined{negthickspace}{\\usepackage{amsmath}}"])
150 end = find_end_of_inset(document.body, i)
151 subst = put_cmd_in_ert("\\negmedspace{}")
152 document.body[i:end + 1] = subst
153 j = find_token(document.body, "\\begin_inset space \\negthickspace{}", j)
156 end = find_end_of_inset(document.body, j)
157 subst = put_cmd_in_ert("\\negthickspace{}")
158 document.body[j:end + 1] = subst
162 def revert_math_spaces(document):
163 "Revert formulas with protected custom space and protected hfills to TeX-code"
166 i = find_token(document.body, "\\begin_inset Formula", i)
169 j = document.body[i].find("\\hspace*")
171 end = find_end_of_inset(document.body, i)
172 subst = put_cmd_in_ert(document.body[i][21:])
173 document.body[i:end + 1] = subst
177 def convert_japanese_encodings(document):
178 " Rename the japanese encodings to names understood by platex "
180 "EUC-JP-pLaTeX": "euc",
182 "SJIS-pLaTeX": "sjis"
184 i = find_token(document.header, "\\inputencoding" , 0)
187 val = get_value(document.header, "\\inputencoding", i)
188 if val in jap_enc_dict.keys():
189 document.header[i] = "\\inputencoding %s" % jap_enc_dict[val]
192 def revert_japanese_encodings(document):
193 " Revert the japanese encodings name changes "
195 "euc": "EUC-JP-pLaTeX",
197 "sjis": "SJIS-pLaTeX"
199 i = find_token(document.header, "\\inputencoding" , 0)
202 val = get_value(document.header, "\\inputencoding", i)
203 if val in jap_enc_dict.keys():
204 document.header[i] = "\\inputencoding %s" % jap_enc_dict[val]
207 def revert_justification(document):
208 " Revert the \\justification buffer param"
209 if not del_token(document.header, '\\justification', 0):
210 document.warning("Malformed LyX document: Missing \\justification.")
213 def revert_australian(document):
214 "Set English language variants Australian and Newzealand to English"
216 if document.language == "australian" or document.language == "newzealand":
217 document.language = "english"
218 i = find_token(document.header, "\\language", 0)
220 document.header[i] = "\\language english"
224 j = find_token(document.body, "\\lang australian", j)
226 j = find_token(document.body, "\\lang newzealand", 0)
230 document.body[j] = document.body[j].replace("\\lang newzealand", "\\lang english")
232 document.body[j] = document.body[j].replace("\\lang australian", "\\lang english")
236 def convert_biblio_style(document):
237 "Add a sensible default for \\biblio_style based on the citation engine."
238 i = find_token(document.header, "\\cite_engine", 0)
240 engine = get_value(document.header, "\\cite_engine", i).split("_")[0]
241 style = {"basic": "plain", "natbib": "plainnat", "jurabib": "jurabib"}
242 document.header.insert(i + 1, "\\biblio_style " + style[engine])
245 def revert_biblio_style(document):
246 "BibTeX insets with default option use the style defined by \\biblio_style."
247 i = find_token(document.header, "\\biblio_style" , 0)
249 document.warning("No \\biblio_style line. Nothing to do.")
252 default_style = get_value(document.header, "\\biblio_style", i)
253 del document.header[i]
255 # We are looking for bibtex insets having the default option
258 i = find_token(document.body, "\\begin_inset CommandInset bibtex", i)
261 j = find_end_of_inset(document.body, i)
263 document.warning("Malformed LyX document: Can't find end of bibtex inset at line " + str(i))
266 k = find_token(document.body, "options", i, j)
268 options = get_quoted_value(document.body, "options", k)
269 if "default" in options.split(","):
270 document.body[k] = 'options "%s"' \
271 % options.replace("default", default_style)
275 def handle_longtable_captions(document, forward):
278 begin_table = find_token(document.body, '<lyxtabular version=', begin_table)
279 if begin_table == -1:
281 end_table = find_end_of(document.body, begin_table, '<lyxtabular', '</lyxtabular>')
283 document.warning("Malformed LyX document: Could not find end of table.")
286 fline = find_token(document.body, "<features", begin_table, end_table)
288 document.warning("Can't find features for inset at line " + str(begin_table))
291 p = document.body[fline].find("islongtable")
296 numrows = get_option_value(document.body[begin_table], "rows")
298 numrows = int(numrows)
300 document.warning(document.body[begin_table])
301 document.warning("Unable to determine rows!")
302 begin_table = end_table
304 begin_row = begin_table
305 for row in range(numrows):
306 begin_row = find_token(document.body, '<row', begin_row, end_table)
308 document.warning("Can't find row " + str(row + 1))
310 end_row = find_end_of(document.body, begin_row, '<row', '</row>')
312 document.warning("Can't find end of row " + str(row + 1))
315 if (get_option_value(document.body[begin_row], 'caption') == 'true' and
316 get_option_value(document.body[begin_row], 'endfirsthead') != 'true' and
317 get_option_value(document.body[begin_row], 'endhead') != 'true' and
318 get_option_value(document.body[begin_row], 'endfoot') != 'true' and
319 get_option_value(document.body[begin_row], 'endlastfoot') != 'true'):
320 document.body[begin_row] = set_option_value(document.body[begin_row], 'caption', 'true", endfirsthead="true')
321 elif get_option_value(document.body[begin_row], 'caption') == 'true':
322 if get_option_value(document.body[begin_row], 'endfirsthead') == 'true':
323 document.body[begin_row] = set_option_value(document.body[begin_row], 'endfirsthead', 'false')
324 if get_option_value(document.body[begin_row], 'endhead') == 'true':
325 document.body[begin_row] = set_option_value(document.body[begin_row], 'endhead', 'false')
326 if get_option_value(document.body[begin_row], 'endfoot') == 'true':
327 document.body[begin_row] = set_option_value(document.body[begin_row], 'endfoot', 'false')
328 if get_option_value(document.body[begin_row], 'endlastfoot') == 'true':
329 document.body[begin_row] = set_option_value(document.body[begin_row], 'endlastfoot', 'false')
331 # since there could be a tabular inside this one, we
332 # cannot jump to end.
336 def convert_longtable_captions(document):
337 "Add a firsthead flag to caption rows"
338 handle_longtable_captions(document, True)
341 def revert_longtable_captions(document):
342 "remove head/foot flag from caption rows"
343 handle_longtable_captions(document, False)
346 def convert_use_packages(document):
347 "use_xxx yyy => use_package xxx yyy"
348 packages = ["amsmath", "esint", "mathdots", "mhchem", "undertilde"]
350 i = find_token(document.header, "\\use_%s" % p, 0)
352 value = get_value(document.header, "\\use_%s" % p, i)
353 document.header[i] = "\\use_package %s %s" % (p, value)
356 def revert_use_packages(document):
357 "use_package xxx yyy => use_xxx yyy"
358 packages = ["amsmath", "esint", "mathdots", "mhchem", "undertilde"]
359 # the order is arbitrary for the use_package version, and not all packages need to be given.
360 # Ensure a complete list and correct order (important for older LyX versions and especially lyx2lyx)
363 regexp = re.compile(r'(\\use_package\s+%s)' % p)
364 i = find_re(document.header, regexp, j)
366 value = get_value(document.header, "\\use_package %s" % p, i).split()[1]
367 del document.header[i]
369 document.header.insert(j, "\\use_%s %s" % (p, value))
373 def convert_use_mathtools(document):
374 "insert use_package mathtools"
375 i = find_token(document.header, "\\use_package", 0)
377 document.warning("Malformed LyX document: Can't find \\use_package.")
379 j = find_token(document.preamble, "\\usepackage{mathtools}", 0)
381 document.header.insert(i + 1, "\\use_package mathtools 0")
383 document.header.insert(i + 1, "\\use_package mathtools 2")
384 del document.preamble[j]
387 def revert_use_mathtools(document):
388 "remove use_package mathtools"
389 regexp = re.compile(r'(\\use_package\s+mathtools)')
390 i = find_re(document.header, regexp, 0)
391 value = "1" # default is auto
393 value = get_value(document.header, "\\use_package" , i).split()[1]
394 del document.header[i]
395 if value == "2": # on
396 add_to_preamble(document, ["\\usepackage{mathtools}"])
397 elif value == "1": # auto
398 commands = ["mathclap", "mathllap", "mathrlap", \
399 "lgathered", "rgathered", "vcentcolon", "dblcolon", \
400 "coloneqq", "Coloneqq", "coloneq", "Coloneq", "eqqcolon", \
401 "Eqqcolon", "eqcolon", "Eqcolon", "colonapprox", \
402 "Colonapprox", "colonsim", "Colonsim"]
405 i = find_token(document.body, '\\begin_inset Formula', i)
408 j = find_end_of_inset(document.body, i)
410 document.warning("Malformed LyX document: Can't find end of Formula inset at line " + str(i))
413 code = "\n".join(document.body[i:j])
415 if code.find("\\%s" % c) != -1:
416 add_to_preamble(document, ["\\usepackage{mathtools}"])
421 def convert_cite_engine_type(document):
422 "Determine the \\cite_engine_type from the citation engine."
423 i = find_token(document.header, "\\cite_engine", 0)
426 engine = get_value(document.header, "\\cite_engine", i)
428 engine, type = engine.split("_")
430 type = {"basic": "numerical", "jurabib": "authoryear"}[engine]
431 document.header[i] = "\\cite_engine " + engine
432 document.header.insert(i + 1, "\\cite_engine_type " + type)
435 def revert_cite_engine_type(document):
436 "Natbib had the type appended with an underscore."
437 engine_type = "numerical"
438 i = find_token(document.header, "\\cite_engine_type" , 0)
440 document.warning("No \\cite_engine_type line. Assuming numerical.")
442 engine_type = get_value(document.header, "\\cite_engine_type", i)
443 del document.header[i]
445 # We are looking for the natbib citation engine
446 i = find_token(document.header, "\\cite_engine natbib", 0)
449 document.header[i] = "\\cite_engine natbib_" + engine_type
452 def revert_cancel(document):
453 "add cancel to the preamble if necessary"
454 commands = ["cancelto", "cancel", "bcancel", "xcancel"]
457 i = find_token(document.body, '\\begin_inset Formula', i)
460 j = find_end_of_inset(document.body, i)
462 document.warning("Malformed LyX document: Can't find end of Formula inset at line " + str(i))
465 code = "\n".join(document.body[i:j])
467 if code.find("\\%s" % c) != -1:
468 add_to_preamble(document, ["\\usepackage{cancel}"])
473 def revert_verbatim(document):
474 " Revert verbatim einvironments completely to TeX-code. "
477 subst_end = ['\end_layout', '', '\\begin_layout Plain Layout',
479 '\\begin_layout Plain Layout', '', '',
482 '\\end_layout', '', '\\end_inset',
483 '', '', '\\end_layout']
484 subst_begin = ['\\begin_layout Standard', '\\noindent',
485 '\\begin_inset ERT', 'status collapsed', '',
486 '\\begin_layout Plain Layout', '', '', '\\backslash',
488 '\\end_layout', '', '\\begin_layout Plain Layout', '']
490 i = find_token(document.body, "\\begin_layout Verbatim", i)
493 j = find_end_of_layout(document.body, i)
495 document.warning("Malformed lyx document: Can't find end of Verbatim layout")
498 # delete all line breaks insets (there are no other insets)
501 n = find_token(document.body, "\\begin_inset Newline newline", l)
503 n = find_token(document.body, "\\begin_inset Newline linebreak", l)
506 m = find_end_of_inset(document.body, n)
507 del(document.body[m:m+1])
508 document.body[n:n+1] = ['\end_layout', '', '\\begin_layout Plain Layout']
511 # consecutive verbatim environments need to be connected
512 k = find_token(document.body, "\\begin_layout Verbatim", j)
513 if k == j + 2 and consecutive == False:
515 document.body[j:j+1] = ['\end_layout', '', '\\begin_layout Plain Layout']
516 document.body[i:i+1] = subst_begin
518 if k == j + 2 and consecutive == True:
519 document.body[j:j+1] = ['\end_layout', '', '\\begin_layout Plain Layout']
520 del(document.body[i:i+1])
522 if k != j + 2 and consecutive == True:
523 document.body[j:j+1] = subst_end
524 # the next paragraph must not be indented
525 document.body[j+19:j+19] = ['\\noindent']
526 del(document.body[i:i+1])
530 document.body[j:j+1] = subst_end
531 # the next paragraph must not be indented
532 document.body[j+19:j+19] = ['\\noindent']
533 document.body[i:i+1] = subst_begin
536 def revert_tipa(document):
537 " Revert native TIPA insets to mathed or ERT. "
540 i = find_token(document.body, "\\begin_inset IPA", i)
543 j = find_end_of_inset(document.body, i)
545 document.warning("Malformed lyx document: Can't find end of IPA inset")
549 n = find_token(document.body, "\\begin_layout", i, j)
551 document.warning("Malformed lyx document: IPA inset has no embedded layout")
554 m = find_end_of_layout(document.body, n)
556 document.warning("Malformed lyx document: Can't find end of embedded layout")
559 content = document.body[n+1:m]
560 p = find_token(document.body, "\\begin_layout", m, j)
561 if p != -1 or len(content) > 1:
563 content = document.body[i+1:j]
565 # IPA insets with multiple pars need to be wrapped by \begin{IPA}...\end{IPA}
566 document.body[i:j+1] = ['\\end_layout', '', '\\begin_layout Standard'] + put_cmd_in_ert("\\begin{IPA}") + ['\\end_layout'] + content + ['\\begin_layout Standard'] + put_cmd_in_ert("\\end{IPA}")
567 add_to_preamble(document, ["\\usepackage{tipa,tipx}"])
569 # single-par IPA insets can be reverted to mathed
570 document.body[i:j+1] = ["\\begin_inset Formula $\\text{\\textipa{" + content[0] + "}}$", "\\end_inset"]
574 def revert_cell_rotation(document):
575 "Revert cell rotations to TeX-code"
577 load_rotating = False
581 # first, let's find out if we need to do anything
582 i = find_token(document.body, '<cell ', i)
585 j = document.body[i].find('rotate="')
587 k = document.body[i].find('"', j + 8)
588 value = document.body[i][j + 8 : k]
590 rgx = re.compile(r' rotate="[^"]+?"')
591 # remove rotate option
592 document.body[i] = rgx.sub('', document.body[i])
594 rgx = re.compile(r' rotate="[^"]+?"')
595 document.body[i] = rgx.sub('rotate="true"', document.body[i])
597 rgx = re.compile(r' rotate="[^"]+?"')
599 # remove rotate option
600 document.body[i] = rgx.sub('', document.body[i])
602 document.body[i + 5 : i + 5] = \
603 put_cmd_in_ert("\\end{turn}")
604 document.body[i + 4 : i + 4] = \
605 put_cmd_in_ert("\\begin{turn}{" + value + "}")
611 add_to_preamble(document, ["\\@ifundefined{turnbox}{\usepackage{rotating}}{}"])
614 def convert_cell_rotation(document):
615 'Convert cell rotation statements from "true" to "90"'
619 # first, let's find out if we need to do anything
620 i = find_token(document.body, '<cell ', i)
623 j = document.body[i].find('rotate="true"')
625 rgx = re.compile(r'rotate="[^"]+?"')
626 # convert "true" to "90"
627 document.body[i] = rgx.sub('rotate="90"', document.body[i])
632 def revert_table_rotation(document):
633 "Revert table rotations to TeX-code"
635 load_rotating = False
639 # first, let's find out if we need to do anything
640 i = find_token(document.body, '<features ', i)
643 j = document.body[i].find('rotate="')
645 end_table = find_token(document.body, '</lyxtabular>', j)
646 k = document.body[i].find('"', j + 8)
647 value = document.body[i][j + 8 : k]
649 rgx = re.compile(r' rotate="[^"]+?"')
650 # remove rotate option
651 document.body[i] = rgx.sub('', document.body[i])
653 rgx = re.compile(r'rotate="[^"]+?"')
654 document.body[i] = rgx.sub('rotate="true"', document.body[i])
656 rgx = re.compile(r' rotate="[^"]+?"')
658 # remove rotate option
659 document.body[i] = rgx.sub('', document.body[i])
661 document.body[end_table + 3 : end_table + 3] = \
662 put_cmd_in_ert("\\end{turn}")
663 document.body[i - 2 : i - 2] = \
664 put_cmd_in_ert("\\begin{turn}{" + value + "}")
670 add_to_preamble(document, ["\\@ifundefined{turnbox}{\usepackage{rotating}}{}"])
673 def convert_table_rotation(document):
674 'Convert table rotation statements from "true" to "90"'
678 # first, let's find out if we need to do anything
679 i = find_token(document.body, '<features ', i)
682 j = document.body[i].find('rotate="true"')
684 rgx = re.compile(r'rotate="[^"]+?"')
685 # convert "true" to "90"
686 document.body[i] = rgx.sub('rotate="90"', document.body[i])
691 def convert_listoflistings(document):
692 'Convert ERT \lstlistoflistings to TOC lstlistoflistings inset'
693 # We can support roundtrip because the command is so simple
696 i = find_token(document.body, "\\begin_inset ERT", i)
699 j = find_end_of_inset(document.body, i)
701 document.warning("Malformed lyx document: Can't find end of ERT inset")
704 ert = get_ert(document.body, i)
705 if ert == "\\lstlistoflistings{}":
706 document.body[i:j] = ["\\begin_inset CommandInset toc", "LatexCommand lstlistoflistings", ""]
712 def revert_listoflistings(document):
713 'Convert TOC lstlistoflistings inset to ERT lstlistoflistings'
716 i = find_token(document.body, "\\begin_inset CommandInset toc", i)
719 if document.body[i+1] == "LatexCommand lstlistoflistings":
720 j = find_end_of_inset(document.body, i)
722 document.warning("Malformed lyx document: Can't find end of TOC inset")
725 subst = put_cmd_in_ert("\\lstlistoflistings{}")
726 document.body[i:j+1] = subst
727 add_to_preamble(document, ["\\usepackage{listings}"])
731 def convert_use_amssymb(document):
732 "insert use_package amssymb"
733 regexp = re.compile(r'(\\use_package\s+amsmath)')
734 i = find_re(document.header, regexp, 0)
736 document.warning("Malformed LyX document: Can't find \\use_package amsmath.")
738 value = get_value(document.header, "\\use_package" , i).split()[1]
741 useamsmath = int(value)
743 document.warning("Invalid \\use_package amsmath: " + value + ". Assuming auto.")
745 j = find_token(document.preamble, "\\usepackage{amssymb}", 0)
747 document.header.insert(i + 1, "\\use_package amssymb %d" % useamsmath)
749 document.header.insert(i + 1, "\\use_package amssymb 2")
750 del document.preamble[j]
753 def revert_use_amssymb(document):
754 "remove use_package amssymb"
755 regexp1 = re.compile(r'(\\use_package\s+amsmath)')
756 regexp2 = re.compile(r'(\\use_package\s+amssymb)')
757 i = find_re(document.header, regexp1, 0)
758 j = find_re(document.header, regexp2, 0)
759 value1 = "1" # default is auto
760 value2 = "1" # default is auto
762 value1 = get_value(document.header, "\\use_package" , i).split()[1]
764 value2 = get_value(document.header, "\\use_package" , j).split()[1]
765 del document.header[j]
766 if value1 != value2 and value2 == "2": # on
767 add_to_preamble(document, ["\\usepackage{amssymb}"])
774 supported_versions = ["2.1.0","2.1"]
777 [415, [convert_undertilde]],
779 [417, [convert_japanese_encodings]],
782 [420, [convert_biblio_style]],
783 [421, [convert_longtable_captions]],
784 [422, [convert_use_packages]],
785 [423, [convert_use_mathtools]],
786 [424, [convert_cite_engine_type]],
790 [428, [convert_cell_rotation]],
791 [429, [convert_table_rotation]],
792 [430, [convert_listoflistings]],
793 [431, [convert_use_amssymb]],
797 [430, [revert_use_amssymb]],
798 [429, [revert_listoflistings]],
799 [428, [revert_table_rotation]],
800 [427, [revert_cell_rotation]],
801 [426, [revert_tipa]],
802 [425, [revert_verbatim]],
803 [424, [revert_cancel]],
804 [423, [revert_cite_engine_type]],
805 [422, [revert_use_mathtools]],
806 [421, [revert_use_packages]],
807 [420, [revert_longtable_captions]],
808 [419, [revert_biblio_style]],
809 [418, [revert_australian]],
810 [417, [revert_justification]],
811 [416, [revert_japanese_encodings]],
812 [415, [revert_negative_space, revert_math_spaces]],
813 [414, [revert_undertilde]],
814 [413, [revert_visible_space]]
818 if __name__ == "__main__":