1 # -*- coding: utf-8 -*-
2 # This file is part of lyx2lyx
3 # Copyright (C) 2018 The LyX team
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 """ Convert files to the file format generated by lyx 2.4"""
25 from datetime import (datetime, date, time)
27 # Uncomment only what you need to import, please.
29 from parser_tools import (count_pars_in_inset, find_end_of_inset, find_end_of_layout,
30 find_token, find_re, get_bool_value, get_option_value, get_value, get_quoted_value)
31 # del_token, del_value, del_complete_lines,
32 # find_complete_lines, find_end_of,
33 # find_re, find_substring, find_token_backwards,
34 # get_containing_inset, get_containing_layout,
35 # is_in_inset, set_bool_value
36 # find_tokens, find_token_exact, check_token
38 from lyx2lyx_tools import (put_cmd_in_ert, add_to_preamble)
39 # revert_font_attrs, insert_to_preamble, latex_length
40 # get_ert, lyx2latex, lyx2verbatim, length_in_bp, convert_info_insets
41 # revert_flex_inset, hex2ratio, str2bool
43 ####################################################################
44 # Private helper functions
46 def convert_fonts(document, font_list, font_type, scale_type):
47 " Handle font definition to LaTeX "
49 rpkg = re.compile(r'^\\usepackage(\[scaled=([^\]]*)\])?\{([^\}]+)\}')
51 if scale_type == None:
54 fontscale = "\\font_" + scale_type + "_scale"
56 while i < len(document.preamble):
57 i = find_re(document.preamble, rpkg, i)
60 mo = rpkg.search(document.preamble[i])
63 if not pkg in font_list:
66 del document.preamble[i]
67 if i > 0 and document.preamble[i-1] == "% Added by lyx2lyx":
68 del document.preamble[i-1]
70 j = find_token(document.header, fontscale, 0)
72 val = get_value(document.header, fontscale, j)
76 scale = "%03d" % int(float(option) * 100)
77 document.header[j] = fontscale + " " + scale + " " + vals[1]
78 j = find_token(document.header, ft, 0)
80 val = get_value(document.header, ft, j)
82 document.header[j] = ft + ' "' + pkg + '" ' + vals[1]
84 def revert_fonts(document, font_list):
85 " Revert native font definition to LaTeX "
87 if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
88 font_types = ["\\font_roman", "\\font_sans,sf", "\\font_typewriter,tt"]
89 for ft1 in font_types:
92 i = find_token(document.header, ft, 0)
94 val = get_value(document.header, ft, i)
96 val = words[0].replace('"', '')
99 document.header[i] = ft + ' "default" ' + words[1]
101 xval = get_value(document.header, "\\font_" + fts[1] + "_scale", 0)
105 xoption = "[scaled=" + format(float(xval) / 100, '.2f') + "]"
106 preamble = "\\usepackage" + xoption + "{%s}" % val
107 add_to_preamble(document, [preamble])
109 ###############################################################################
111 ### Conversion and reversion routines
113 ###############################################################################
115 def convert_dejavu(document):
116 " Handle DejaVu font definition to LaTeX "
118 dejavu_fonts_roman = ['DejaVuSerif', 'DejaVuSerifCondensed']
119 dejavu_fonts_sans = ['DejaVuSans','DejaVuSansCondensed']
120 dejavu_fonts_typewriter = ['DejaVuSansMono']
122 convert_fonts(document, dejavu_fonts_roman, "\\font_roman", None)
123 convert_fonts(document, dejavu_fonts_sans, "\\font_sans", "sf")
124 convert_fonts(document, dejavu_fonts_typewriter, "\\font_typewriter", "tt")
126 def revert_dejavu(document):
127 " Revert native DejaVu font definition to LaTeX "
129 dejavu_fonts = ['DejaVuSerif', 'DejaVuSerifCondensed', 'DejaVuSans',
130 'DejaVuSansMono', 'DejaVuSansCondensed']
131 revert_fonts(document, dejavu_fonts)
133 def removeFrontMatterStyles(document):
134 " Remove styles Begin/EndFrontmatter"
136 layouts = ['BeginFrontmatter', 'EndFrontmatter']
137 for layout in layouts:
140 i = find_token(document.body, '\\begin_layout ' + layout, i)
143 j = find_end_of_layout(document.body, i)
145 document.warning("Malformed LyX document: Can't find end of layout at line %d" % i)
148 while i > 0 and document.body[i-1].strip() == '':
150 while document.body[j+1].strip() == '':
152 document.body[i:j+1] = ['']
154 def addFrontMatterStyles(document):
155 " Use styles Begin/EndFrontmatter for elsarticle"
157 def insertFrontmatter(prefix, line):
159 while above > 0 and document.body[above-1].strip() == '':
162 while document.body[below].strip() == '':
164 document.body[above:below] = ['', '\\begin_layout ' + prefix + 'Frontmatter',
165 '\\begin_inset Note Note',
167 '\\begin_layout Plain Layout',
170 '\\end_inset', '', '',
173 if document.textclass == "elsarticle":
174 layouts = ['Title', 'Title footnote', 'Author', 'Author footnote',
175 'Corresponding author', 'Address', 'Email', 'Abstract', 'Keywords']
178 for layout in layouts:
181 i = find_token(document.body, '\\begin_layout ' + layout, i)
184 k = find_end_of_layout(document.body, i)
186 document.warning("Malformed LyX document: Can't find end of layout at line %d" % i)
189 if first == -1 or i < first:
191 if last == -1 or last <= k:
196 insertFrontmatter('End', last)
197 insertFrontmatter('Begin', first)
199 def convert_lst_literalparam(document):
200 " Add param literal to include inset "
204 i = find_token(document.body, '\\begin_inset CommandInset include', i)
207 j = find_end_of_inset(document.body, i)
209 document.warning("Malformed LyX document: Can't find end of command inset at line %d" % i)
212 while i < j and document.body[i].strip() != '':
214 document.body.insert(i, "literal \"true\"")
217 def revert_lst_literalparam(document):
218 " Remove param literal from include inset "
222 i = find_token(document.body, '\\begin_inset CommandInset include', i)
225 j = find_end_of_inset(document.body, i)
227 document.warning("Malformed LyX document: Can't find end of include inset at line %d" % i)
230 k = find_token(document.body, 'literal', i, j)
237 def revert_paratype(document):
238 " Revert ParaType font definitions to LaTeX "
240 if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
242 i1 = find_token(document.header, "\\font_roman \"PTSerif-TLF\"", 0)
243 i2 = find_token(document.header, "\\font_sans \"default\"", 0)
244 i3 = find_token(document.header, "\\font_typewriter \"default\"", 0)
245 j = find_token(document.header, "\\font_sans \"PTSans-TLF\"", 0)
246 sfval = get_value(document.header, "\\font_sf_scale", 0)
251 sfoption = "scaled=" + format(float(sfval) / 100, '.2f')
252 k = find_token(document.header, "\\font_typewriter \"PTMono-TLF\"", 0)
253 ttval = get_value(document.header, "\\font_tt_scale", 0)
258 ttoption = "scaled=" + format(float(ttval) / 100, '.2f')
259 if i1 != -1 and i2 != -1 and i3!= -1:
260 add_to_preamble(document, ["\\usepackage{paratype}"])
263 add_to_preamble(document, ["\\usepackage{PTSerif}"])
264 document.header[i1] = document.header[i1].replace("PTSerif-TLF", "default")
267 add_to_preamble(document, ["\\usepackage[" + sfoption + "]{PTSans}"])
269 add_to_preamble(document, ["\\usepackage{PTSans}"])
270 document.header[j] = document.header[j].replace("PTSans-TLF", "default")
273 add_to_preamble(document, ["\\usepackage[" + ttoption + "]{PTMono}"])
275 add_to_preamble(document, ["\\usepackage{PTMono}"])
276 document.header[k] = document.header[k].replace("PTMono-TLF", "default")
279 def revert_xcharter(document):
280 " Revert XCharter font definitions to LaTeX "
282 i = find_token(document.header, "\\font_roman \"xcharter\"", 0)
286 # replace unsupported font setting
287 document.header[i] = document.header[i].replace("xcharter", "default")
288 # no need for preamble code with system fonts
289 if get_bool_value(document.header, "\\use_non_tex_fonts"):
292 # transfer old style figures setting to package options
293 j = find_token(document.header, "\\font_osf true")
296 document.header[j] = "\\font_osf false"
300 add_to_preamble(document, ["\\usepackage%s{XCharter}"%options])
303 def revert_lscape(document):
304 " Reverts the landscape environment (Landscape module) to TeX-code "
306 if not "landscape" in document.get_module_list():
311 i = find_token(document.body, "\\begin_inset Flex Landscape", i)
314 j = find_end_of_inset(document.body, i)
316 document.warning("Malformed LyX document: Can't find end of Landscape inset")
320 if document.body[i] == "\\begin_inset Flex Landscape (Floating)":
321 document.body[j - 2 : j + 1] = put_cmd_in_ert("\\end{landscape}}")
322 document.body[i : i + 4] = put_cmd_in_ert("\\afterpage{\\begin{landscape}")
323 add_to_preamble(document, ["\\usepackage{afterpage}"])
325 document.body[j - 2 : j + 1] = put_cmd_in_ert("\\end{landscape}")
326 document.body[i : i + 4] = put_cmd_in_ert("\\begin{landscape}")
328 add_to_preamble(document, ["\\usepackage{pdflscape}"])
332 def convert_fontenc(document):
333 " Convert default fontenc setting "
335 i = find_token(document.header, "\\fontencoding global", 0)
339 document.header[i] = document.header[i].replace("global", "auto")
342 def revert_fontenc(document):
343 " Revert default fontenc setting "
345 i = find_token(document.header, "\\fontencoding auto", 0)
349 document.header[i] = document.header[i].replace("auto", "global")
352 def revert_nospellcheck(document):
353 " Remove nospellcheck font info param "
357 i = find_token(document.body, '\\nospellcheck', i)
363 def revert_floatpclass(document):
364 " Remove float placement params 'document' and 'class' "
367 i = find_token(document.header, "\\float_placement class", 0)
369 del document.header[i]
373 i = find_token(document.body, '\\begin_inset Float', i)
376 j = find_end_of_inset(document.body, i)
377 k = find_token(document.body, 'placement class', i, i + 2)
379 k = find_token(document.body, 'placement document', i, i + 2)
387 def revert_floatalignment(document):
388 " Remove float alignment params "
391 i = find_token(document.header, "\\float_alignment", 0)
394 galignment = get_value(document.header, "\\float_alignment", i)
395 del document.header[i]
399 i = find_token(document.body, '\\begin_inset Float', i)
402 j = find_end_of_inset(document.body, i)
404 document.warning("Malformed LyX document: Can't find end of inset at line " + str(i))
406 k = find_token(document.body, 'alignment', i, i + 4)
410 alignment = get_value(document.body, "alignment", k)
411 if alignment == "document":
412 alignment = galignment
414 l = find_token(document.body, "\\begin_layout Plain Layout", i, j)
416 document.warning("Can't find float layout!")
420 if alignment == "left":
421 alcmd = put_cmd_in_ert("\\raggedright{}")
422 elif alignment == "center":
423 alcmd = put_cmd_in_ert("\\centering{}")
424 elif alignment == "right":
425 alcmd = put_cmd_in_ert("\\raggedleft{}")
427 document.body[l+1:l+1] = alcmd
431 def revert_tuftecite(document):
432 " Revert \cite commands in tufte classes "
434 tufte = ["tufte-book", "tufte-handout"]
435 if document.textclass not in tufte:
440 i = find_token(document.body, "\\begin_inset CommandInset citation", i)
443 j = find_end_of_inset(document.body, i)
445 document.warning("Can't find end of citation inset at line %d!!" %(i))
448 k = find_token(document.body, "LatexCommand", i, j)
450 document.warning("Can't find LatexCommand for citation inset at line %d!" %(i))
453 cmd = get_value(document.body, "LatexCommand", k)
457 pre = get_quoted_value(document.body, "before", i, j)
458 post = get_quoted_value(document.body, "after", i, j)
459 key = get_quoted_value(document.body, "key", i, j)
461 document.warning("Citation inset at line %d does not have a key!" %(i))
463 # Replace command with ERT
466 res += "[" + pre + "]"
468 res += "[" + post + "]"
471 res += "{" + key + "}"
472 document.body[i:j+1] = put_cmd_in_ert([res])
476 def revert_stretchcolumn(document):
477 " We remove the column varwidth flags or everything else will become a mess. "
480 i = find_token(document.body, "\\begin_inset Tabular", i)
483 j = find_end_of_inset(document.body, i + 1)
485 document.warning("Malformed LyX document: Could not find end of tabular.")
487 for k in range(i, j):
488 if re.search('^<column.*varwidth="[^"]+".*>$', document.body[k]):
489 document.warning("Converting 'tabularx'/'xltabular' table to normal table.")
490 document.body[k] = document.body[k].replace(' varwidth="true"', '')
494 def revert_vcolumns(document):
495 " Revert standard columns with line breaks etc. "
501 i = find_token(document.body, "\\begin_inset Tabular", i)
504 j = find_end_of_inset(document.body, i)
506 document.warning("Malformed LyX document: Could not find end of tabular.")
510 # Collect necessary column information
512 nrows = int(document.body[i+1].split('"')[3])
513 ncols = int(document.body[i+1].split('"')[5])
515 for k in range(ncols):
516 m = find_token(document.body, "<column", m)
517 width = get_option_value(document.body[m], 'width')
518 varwidth = get_option_value(document.body[m], 'varwidth')
519 alignment = get_option_value(document.body[m], 'alignment')
520 special = get_option_value(document.body[m], 'special')
521 col_info.append([width, varwidth, alignment, special, m])
526 for row in range(nrows):
527 for col in range(ncols):
528 m = find_token(document.body, "<cell", m)
529 multicolumn = get_option_value(document.body[m], 'multicolumn')
530 multirow = get_option_value(document.body[m], 'multirow')
531 width = get_option_value(document.body[m], 'width')
532 rotate = get_option_value(document.body[m], 'rotate')
533 # Check for: linebreaks, multipars, non-standard environments
535 endcell = find_token(document.body, "</cell>", begcell)
537 if find_token(document.body, "\\begin_inset Newline", begcell, endcell) != -1:
539 elif count_pars_in_inset(document.body, begcell + 2) > 1:
541 elif get_value(document.body, "\\begin_layout", begcell) != "Plain Layout":
543 if vcand and rotate == "" and ((multicolumn == "" and multirow == "") or width == ""):
544 if col_info[col][0] == "" and col_info[col][1] == "" and col_info[col][3] == "":
546 alignment = col_info[col][2]
547 col_line = col_info[col][4]
549 if alignment == "center":
550 vval = ">{\\centering}"
551 elif alignment == "left":
552 vval = ">{\\raggedright}"
553 elif alignment == "right":
554 vval = ">{\\raggedleft}"
557 vval += "V{\\linewidth}"
559 document.body[col_line] = document.body[col_line][:-1] + " special=\"" + vval + "\">"
560 # ERT newlines and linebreaks (since LyX < 2.4 automatically inserts parboxes
561 # with newlines, and we do not want that)
563 endcell = find_token(document.body, "</cell>", begcell)
565 nl = find_token(document.body, "\\begin_inset Newline newline", begcell, endcell)
567 nl = find_token(document.body, "\\begin_inset Newline linebreak", begcell, endcell)
571 nle = find_end_of_inset(document.body, nl)
572 del(document.body[nle:nle+1])
574 document.body[nl:nl+1] = put_cmd_in_ert("\\linebreak{}")
576 document.body[nl:nl+1] = put_cmd_in_ert("\\\\")
582 if needarray == True:
583 add_to_preamble(document, ["\\usepackage{array}"])
584 if needvarwidth == True:
585 add_to_preamble(document, ["\\usepackage{varwidth}"])
588 def revert_bibencoding(document):
589 " Revert bibliography encoding "
593 i = find_token(document.header, "\\cite_engine", 0)
595 document.warning("Malformed document! Missing \\cite_engine")
597 engine = get_value(document.header, "\\cite_engine", i)
601 if engine in ["biblatex", "biblatex-natbib"]:
604 # Map lyx to latex encoding names
608 "armscii8" : "armscii8",
609 "iso8859-1" : "latin1",
610 "iso8859-2" : "latin2",
611 "iso8859-3" : "latin3",
612 "iso8859-4" : "latin4",
613 "iso8859-5" : "iso88595",
614 "iso8859-6" : "8859-6",
615 "iso8859-7" : "iso-8859-7",
616 "iso8859-8" : "8859-8",
617 "iso8859-9" : "latin5",
618 "iso8859-13" : "latin7",
619 "iso8859-15" : "latin9",
620 "iso8859-16" : "latin10",
621 "applemac" : "applemac",
623 "cp437de" : "cp437de",
640 "utf8-platex" : "utf8",
647 i = find_token(document.body, "\\begin_inset CommandInset bibtex", i)
650 j = find_end_of_inset(document.body, i)
652 document.warning("Can't find end of bibtex inset at line %d!!" %(i))
655 encoding = get_quoted_value(document.body, "encoding", i, j)
659 # remove encoding line
660 k = find_token(document.body, "encoding", i, j)
663 # Re-find inset end line
664 j = find_end_of_inset(document.body, i)
667 h = find_token(document.header, "\\biblio_options", 0)
669 biblio_options = get_value(document.header, "\\biblio_options", h)
670 if not "bibencoding" in biblio_options:
671 document.header[h] += ",bibencoding=%s" % encodings[encoding]
673 bs = find_token(document.header, "\\biblatex_bibstyle", 0)
675 # this should not happen
676 document.warning("Malformed LyX document! No \\biblatex_bibstyle header found!")
678 document.header[bs-1 : bs-1] = ["\\biblio_options bibencoding=" + encodings[encoding]]
680 document.body[j+1:j+1] = put_cmd_in_ert("\\egroup")
681 document.body[i:i] = put_cmd_in_ert("\\bgroup\\inputencoding{" + encodings[encoding] + "}")
687 def convert_vcsinfo(document):
688 " Separate vcs Info inset from buffer Info inset. "
691 "vcs-revision" : "revision",
692 "vcs-tree-revision" : "tree-revision",
693 "vcs-author" : "author",
699 i = find_token(document.body, "\\begin_inset Info", i)
702 j = find_end_of_inset(document.body, i + 1)
704 document.warning("Malformed LyX document: Could not find end of Info inset.")
707 tp = find_token(document.body, 'type', i, j)
708 tpv = get_quoted_value(document.body, "type", tp)
712 arg = find_token(document.body, 'arg', i, j)
713 argv = get_quoted_value(document.body, "arg", arg)
714 if argv not in list(types.keys()):
717 document.body[tp] = "type \"vcs\""
718 document.body[arg] = "arg \"" + types[argv] + "\""
722 def revert_vcsinfo(document):
723 " Merge vcs Info inset to buffer Info inset. "
725 args = ["revision", "tree-revision", "author", "time", "date" ]
728 i = find_token(document.body, "\\begin_inset Info", i)
731 j = find_end_of_inset(document.body, i + 1)
733 document.warning("Malformed LyX document: Could not find end of Info inset.")
736 tp = find_token(document.body, 'type', i, j)
737 tpv = get_quoted_value(document.body, "type", tp)
741 arg = find_token(document.body, 'arg', i, j)
742 argv = get_quoted_value(document.body, "arg", arg)
744 document.warning("Malformed Info inset. Invalid vcs arg.")
747 document.body[tp] = "type \"buffer\""
748 document.body[arg] = "arg \"vcs-" + argv + "\""
752 def revert_dateinfo(document):
753 " Revert date info insets to static text. "
755 # FIXME This currently only considers the main language and uses the system locale
756 # Ideally, it should honor context languages and switch the locale accordingly.
758 # The date formats for each language using strftime syntax:
759 # long, short, loclong, locmedium, locshort
761 "afrikaans" : ["%A, %d %B %Y", "%Y-%m-%d", "%d %B %Y", "%d %b %Y", "%Y/%m/%d"],
762 "albanian" : ["%A, %d %B %Y", "%d.%m.%y", "%d %B %Y", "%d %b %Y", "%d/%m/%Y"],
763 "american" : ["%A, %B %d, %Y", "%m/%d/%y", "%B %d, %Y", "%b %d, %Y", "%m/%d/%Y"],
764 "amharic" : ["%A ፣%d %B %Y", "%d/%m/%Y", "%d %B %Y", "%d %b %Y", "%d/%m/%Y"],
765 "ancientgreek" : ["%A, %d %B %Y", "%d %b %Y", "%d %B %Y", "%d %b %Y", "%d/%m/%Y"],
766 "arabic_arabi" : ["%A، %d %B، %Y", "%d/%m/%Y", "%d %B، %Y", "%d/%m/%Y", "%d/%m/%Y"],
767 "arabic_arabtex" : ["%A، %d %B، %Y", "%d/%m/%Y", "%d %B، %Y", "%d/%m/%Y", "%d/%m/%Y"],
768 "armenian" : ["%Y թ. %B %d, %A", "%d.%m.%y", "%d %B، %Y", "%d %b، %Y", "%d/%m/%Y"],
769 "asturian" : ["%A, %d %B de %Y", "%d/%m/%y", "%d de %B de %Y", "%d %b %Y", "%d/%m/%Y"],
770 "australian" : ["%A, %d %B %Y", "%d/%m/%y", "%d %B %Y", "%d %b %Y", "%d/%m/%Y"],
771 "austrian" : ["%A, %d. %B %Y", "%d.%m.%y", "%d. %B %Y", "%d. %b %Y", "%d.%m.%Y"],
772 "bahasa" : ["%A, %d %B %Y", "%d/%m/%y", "%d %B %Y", "%d %b %Y", "%d/%m/%Y"],
773 "bahasam" : ["%A, %d %B %Y", "%d/%m/%y", "%d %B %Y", "%d %b %Y", "%d/%m/%Y"],
774 "basque" : ["%Y(e)ko %B %d, %A", "%y/%m/%d", "%Y %B %d", "%Y %b %d", "%Y/%m/%d"],
775 "belarusian" : ["%A, %d %B %Y г.", "%d.%m.%y", "%d %B %Y", "%d %b %Y", "%d.%m.%Y"],
776 "bosnian" : ["%A, %d. %B %Y.", "%d.%m.%y.", "%d. %B %Y", "%d. %b %Y", "%Y-%m-%d"],
777 "brazilian" : ["%A, %d de %B de %Y", "%d/%m/%Y", "%d de %B de %Y", "%d de %b de %Y", "%d/%m/%Y"],
778 "breton" : ["%Y %B %d, %A", "%Y-%m-%d", "%d %B %Y", "%d %b %Y", "%Y-%m-%d"],
779 "british" : ["%A, %d %B %Y", "%d/%m/%Y", "%d %B %Y", "%d %b %Y", "%d/%m/%Y"],
780 "bulgarian" : ["%A, %d %B %Y г.", "%d.%m.%y г.", "%d %B %Y", "%d %b %Y", "%Y-%m-%d"],
781 "canadian" : ["%A, %B %d, %Y", "%Y-%m-%d", "%B %d, %Y", "%d %b %Y", "%Y-%m-%d"],
782 "canadien" : ["%A %d %B %Y", "%y-%m-%d", "%d %B %Y", "%d %b %Y", "%Y-%m-%d"],
783 "catalan" : ["%A, %d %B de %Y", "%d/%m/%y", "%d / %B / %Y", "%d / %b / %Y", "%d/%m/%Y"],
784 "chinese-simplified" : ["%Y年%m月%d日%A", "%Y/%m/%d", "%Y年%m月%d日", "%Y-%m-%d", "%y-%m-%d"],
785 "chinese-traditional" : ["%Y年%m月%d日 %A", "%Y/%m/%d", "%Y年%m月%d日", "%Y年%m月%d日", "%y年%m月%d日"],
786 "coptic" : ["%A, %d %B %Y", "%d %b %Y", "%B %d, %Y", "%b %d, %Y", "%m/%d/%Y"],
787 "croatian" : ["%A, %d. %B %Y.", "%d. %m. %Y.", "%d. %B %Y.", "%d. %b. %Y.", "%d.%m.%Y."],
788 "czech" : ["%A %d. %B %Y", "%d.%m.%y", "%d. %B %Y", "%d. %b. %Y", "%d.%m.%Y"],
789 "danish" : ["%A den %d. %B %Y", "%d/%m/%Y", "%d. %B %Y", "%d. %b %Y", "%d/%m/%Y"],
790 "divehi" : ["%Y %B %d, %A", "%Y-%m-%d", "%Y %B %d", "%Y %b %d", "%d/%m/%Y"],
791 "dutch" : ["%A %d %B %Y", "%d-%m-%y", "%d %B %Y", "%d %b %Y", "%d-%m-%Y"],
792 "english" : ["%A, %B %d, %Y", "%m/%d/%y", "%B %d, %Y", "%b %d, %Y", "%m/%d/%Y"],
793 "esperanto" : ["%A, %d %B %Y", "%d %b %Y", "la %d de %B %Y", "la %d de %b %Y", "%m/%d/%Y"],
794 "estonian" : ["%A, %d. %B %Y", "%d.%m.%y", "%d %B %Y", "%d %b %Y", "%d.%m.%Y"],
795 "farsi" : ["%A %d %B %Y", "%Y/%m/%d", "%d %B %Y", "%d %b %Y", "%Y/%m/%d"],
796 "finnish" : ["%A %d. %B %Y", "%d.%m.%Y", "%d. %B %Y", "%d. %b %Y", "%d.%m.%Y"],
797 "french" : ["%A %d %B %Y", "%d/%m/%Y", "%d %B %Y", "%d %b %Y", "%d/%m/%Y"],
798 "friulan" : ["%A %d di %B dal %Y", "%d/%m/%y", "%d di %B dal %Y", "%d di %b dal %Y", "%d/%m/%Y"],
799 "galician" : ["%A, %d de %B de %Y", "%d/%m/%y", "%d de %B de %Y", "%d de %b de %Y", "%d/%m/%Y"],
800 "georgian" : ["%A, %d %B, %Y", "%d.%m.%y", "%B %d, %Y", "%b %d, %Y", "%m/%d/%Y"],
801 "german" : ["%A, %d. %B %Y", "%d.%m.%y", "%d. %B %Y", "%d. %b %Y", "%d.%m.%Y"],
802 "german-ch" : ["%A, %d. %B %Y", "%d.%m.%y", "%d. %B %Y", "%d. %b %Y", "%d.%m.%Y"],
803 "german-ch-old" : ["%A, %d. %B %Y", "%d.%m.%y", "%d. %B %Y", "%d. %b %Y", "%d.%m.%Y"],
804 "greek" : ["%A, %d %B %Y", "%d/%m/%y", "%d %B %Y", "%d %b %Y", "%d/%m/%Y"],
805 "hebrew" : ["%A, %d ב%B %Y", "%d.%m.%Y", "%d %B %Y", "%d %b %Y", "%d/%m/%Y"],
806 "hindi" : ["%A, %d %B %Y", "%d/%m/%y", "%d %B %Y", "%d %b %Y", "%d-%m-%Y"],
807 "icelandic" : ["%A, %d. %B %Y", "%d.%m.%Y", "%d. %B %Y", "%d. %b %Y", "%d.%m.%Y"],
808 "interlingua" : ["%Y %B %d, %A", "%Y-%m-%d", "le %d de %B %Y", "le %d de %b %Y", "%Y-%m-%d"],
809 "irish" : ["%A %d %B %Y", "%d/%m/%Y", "%d. %B %Y", "%d. %b %Y", "%d/%m/%Y"],
810 "italian" : ["%A %d %B %Y", "%d/%m/%y", "%d %B %Y", "%d/%b/%Y", "%d/%m/%Y"],
811 "japanese" : ["%Y年%m月%d日%A", "%Y/%m/%d", "%Y年%m月%d日", "%Y/%m/%d", "%y/%m/%d"],
812 "japanese-cjk" : ["%Y年%m月%d日%A", "%Y/%m/%d", "%Y年%m月%d日", "%Y/%m/%d", "%y/%m/%d"],
813 "kannada" : ["%A, %B %d, %Y", "%d/%m/%y", "%d %B %Y", "%d %B %Y", "%d-%m-%Y"],
814 "kazakh" : ["%Y ж. %d %B, %A", "%d.%m.%y", "%d %B %Y", "%d %B %Y", "%Y-%d-%m"],
815 "khmer" : ["%A %d %B %Y", "%d/%m/%y", "%d %B %Y", "%d %B %Y", "%d/%m/%Y"],
816 "korean" : ["%Y년 %m월 %d일 %A", "%y. %m. %d.", "%Y년 %m월 %d일", "%Y. %m. %d.", "%y. %m. %d."],
817 "kurmanji" : ["%A, %d %B %Y", "%d %b %Y", "%d. %B %Y", "%d. %m. %Y", "%Y-%m-%d"],
818 "lao" : ["%A ທີ %d %B %Y", "%d/%m/%Y", "%d %B %Y", "%d %B %Y", "%d/%m/%Y"],
819 "latin" : ["%A, %d %B %Y", "%d %b %Y", "%B %d, %Y", "%b %d, %Y", "%m/%d/%Y"],
820 "latvian" : ["%A, %Y. gada %d. %B", "%d.%m.%y", "%Y. gada %d. %B", "%Y. gada %d. %b", "%d.%m.%Y"],
821 "lithuanian" : ["%Y m. %B %d d., %A", "%Y-%m-%d", "%Y m. %B %d d.", "%Y m. %B %d d.", "%Y-%m-%d"],
822 "lowersorbian" : ["%A, %d. %B %Y", "%d.%m.%y", "%d %B %Y", "%d %b %Y", "%d.%m.%Y"],
823 "macedonian" : ["%A, %d %B %Y", "%d.%m.%y", "%d %B %Y", "%d %b %Y", "%d.%m.%Y"],
824 "magyar" : ["%Y. %B %d., %A", "%Y. %m. %d.", "%Y. %B %d.", "%Y. %b %d.", "%Y.%m.%d."],
825 "marathi" : ["%A, %d %B, %Y", "%d/%m/%y", "%d %B %Y", "%d %b %Y", "%d-%m-%Y"],
826 "mongolian" : ["%A, %Y оны %m сарын %d", "%Y-%m-%d", "%Y оны %m сарын %d", "%d-%m-%Y", "%d-%m-%Y"],
827 "naustrian" : ["%A, %d. %B %Y", "%d.%m.%y", "%d. %B %Y", "%d. %b %Y", "%d.%m.%Y"],
828 "newzealand" : ["%A, %d %B %Y", "%d/%m/%y", "%d %B %Y", "%d %b %Y", "%d/%m/%Y"],
829 "ngerman" : ["%A, %d. %B %Y", "%d.%m.%y", "%d. %B %Y", "%d. %b %Y", "%d.%m.%Y"],
830 "norsk" : ["%A %d. %B %Y", "%d.%m.%Y", "%d. %B %Y", "%d. %b %Y", "%d.%m.%Y"],
831 "nynorsk" : ["%A %d. %B %Y", "%d.%m.%Y", "%d. %B %Y", "%d. %b %Y", "%d.%m.%Y"],
832 "occitan" : ["%Y %B %d, %A", "%Y-%m-%d", "%d %B %Y", "%d %b %Y", "%d/%m/%Y"],
833 "piedmontese" : ["%A, %d %B %Y", "%d %b %Y", "%B %d, %Y", "%b %d, %Y", "%m/%d/%Y"],
834 "polish" : ["%A, %d %B %Y", "%d.%m.%Y", "%d %B %Y", "%d %b %Y", "%Y-%m-%d"],
835 "polutonikogreek" : ["%A, %d %B %Y", "%d/%m/%y", "%d %B %Y", "%d %b %Y", "%d/%m/%Y"],
836 "portuguese" : ["%A, %d de %B de %Y", "%d/%m/%y", "%d de %B de %Y", "%d de %b de %Y", "%Y/%m/%d"],
837 "romanian" : ["%A, %d %B %Y", "%d.%m.%Y", "%d %B %Y", "%d %b %Y", "%d.%m.%Y"],
838 "romansh" : ["%A, ils %d da %B %Y", "%d-%m-%y", "%d %B %Y", "%d %b %Y", "%d.%m.%Y"],
839 "russian" : ["%A, %d %B %Y г.", "%d.%m.%Y", "%d %B %Y г.", "%d %b %Y г.", "%d.%m.%Y"],
840 "samin" : ["%Y %B %d, %A", "%Y-%m-%d", "%B %d. b. %Y", "%b %d. b. %Y", "%d.%m.%Y"],
841 "sanskrit" : ["%Y %B %d, %A", "%Y-%m-%d", "%d %B %Y", "%d %b %Y", "%d-%m-%Y"],
842 "scottish" : ["%A, %dmh %B %Y", "%d/%m/%Y", "%d %B %Y", "%d %b %Y", "%d/%m/%Y"],
843 "serbian" : ["%A, %d. %B %Y.", "%d.%m.%y.", "%d. %B %Y", "%d. %b %Y", "%d.%m.%Y"],
844 "serbian-latin" : ["%A, %d. %B %Y.", "%d.%m.%y.", "%d. %B %Y", "%d. %b %Y", "%d.%m.%Y"],
845 "slovak" : ["%A, %d. %B %Y", "%d. %m. %Y", "%d. %B %Y", "%d. %b %Y", "%d.%m.%Y"],
846 "slovene" : ["%A, %d. %B %Y", "%d. %m. %y", "%d. %B %Y", "%d. %b %Y", "%d.%m.%Y"],
847 "spanish" : ["%A, %d de %B de %Y", "%d/%m/%y", "%d de %B %de %Y", "%d %b %Y", "%d/%m/%Y"],
848 "spanish-mexico" : ["%A, %d de %B %de %Y", "%d/%m/%y", "%d de %B de %Y", "%d %b %Y", "%d/%m/%Y"],
849 "swedish" : ["%A %d %B %Y", "%Y-%m-%d", "%d %B %Y", "%d %b %Y", "%Y-%m-%d"],
850 "syriac" : ["%Y %B %d, %A", "%Y-%m-%d", "%d %B %Y", "%d %b %Y", "%d/%m/%Y"],
851 "tamil" : ["%A, %d %B, %Y", "%d/%m/%y", "%d %B %Y", "%d %b %Y", "%d-%m-%Y"],
852 "telugu" : ["%d, %B %Y, %A", "%d-%m-%y", "%d %B %Y", "%d %b %Y", "%d-%m-%Y"],
853 "thai" : ["%Aที่ %d %B %Y", "%d/%m/%y", "%d %B %Y", "%d %b %Y", "%d/%m/%Y"],
854 "tibetan" : ["%Y %Bའི་ཚེས་%d, %A", "%Y-%m-%d", "%B %d, %Y", "%b %d, %Y", "%m/%d/%Y"],
855 "turkish" : ["%d %B %Y %A", "%d.%m.%Y", "%d %B %Y", "%d.%b.%Y", "%d.%m.%Y"],
856 "turkmen" : ["%d %B %Y %A", "%d.%m.%Y", "%Y ý. %B %d", "%d.%m.%Y ý.", "%d.%m.%y ý."],
857 "ukrainian" : ["%A, %d %B %Y р.", "%d.%m.%y", "%d %B %Y", "%d %m %Y", "%d.%m.%Y"],
858 "uppersorbian" : ["%A, %d. %B %Y", "%d.%m.%y", "%d %B %Y", "%d %b %Y", "%d.%m.%Y"],
859 "urdu" : ["%A، %d %B، %Y", "%d/%m/%y", "%d %B, %Y", "%d %b %Y", "%d/%m/%Y"],
860 "vietnamese" : ["%A, %d %B, %Y", "%d/%m/%Y", "%d tháng %B %Y", "%d-%m-%Y", "%d/%m/%Y"],
861 "welsh" : ["%A, %d %B %Y", "%d/%m/%y", "%d %B %Y", "%d %b %Y", "%d/%m/%Y"],
864 types = ["date", "fixdate", "moddate" ]
866 i = find_token(document.header, "\\language", 0)
868 # this should not happen
869 document.warning("Malformed LyX document! No \\language header found!")
871 lang = get_value(document.header, "\\language", i)
875 i = find_token(document.body, "\\begin_inset Info", i)
878 j = find_end_of_inset(document.body, i + 1)
880 document.warning("Malformed LyX document: Could not find end of Info inset.")
883 tp = find_token(document.body, 'type', i, j)
884 tpv = get_quoted_value(document.body, "type", tp)
888 arg = find_token(document.body, 'arg', i, j)
889 argv = get_quoted_value(document.body, "arg", arg)
893 datecomps = argv.split('@')
894 if len(datecomps) > 1:
896 isodate = datecomps[1]
897 m = re.search('(\d\d\d\d)-(\d\d)-(\d\d)', isodate)
899 dte = date(int(m.group(1)), int(m.group(2)), int(m.group(3)))
900 # FIXME if we had the path to the original document (not the one in the tmp dir),
901 # we could use the mtime.
902 # elif tpv == "moddate":
903 # dte = date.fromtimestamp(os.path.getmtime(document.dir))
906 result = dte.isodate()
908 result = dte.strftime(dateformats[lang][0])
909 elif argv == "short":
910 result = dte.strftime(dateformats[lang][1])
911 elif argv == "loclong":
912 result = dte.strftime(dateformats[lang][2])
913 elif argv == "locmedium":
914 result = dte.strftime(dateformats[lang][3])
915 elif argv == "locshort":
916 result = dte.strftime(dateformats[lang][4])
918 fmt = argv.replace("MMMM", "%b").replace("MMM", "%b").replace("MM", "%m").replace("M", "%m")
919 fmt = fmt.replace("yyyy", "%Y").replace("yy", "%y")
920 fmt = fmt.replace("dddd", "%A").replace("ddd", "%a").replace("dd", "%d")
921 fmt = re.sub('[^\'%]d', '%d', fmt)
922 fmt = fmt.replace("'", "")
923 result = dte.strftime(fmt)
924 document.body[i : j+1] = result
928 def revert_timeinfo(document):
929 " Revert time info insets to static text. "
931 # FIXME This currently only considers the main language and uses the system locale
932 # Ideally, it should honor context languages and switch the locale accordingly.
933 # Also, the time object is "naive", i.e., it does not know of timezones (%Z will
936 # The time formats for each language using strftime syntax:
939 "afrikaans" : ["%H:%M:%S %Z", "%H:%M"],
940 "albanian" : ["%I:%M:%S %p, %Z", "%I:%M %p"],
941 "american" : ["%I:%M:%S %p %Z", "%I:%M %p"],
942 "amharic" : ["%I:%M:%S %p %Z", "%I:%M %p"],
943 "ancientgreek" : ["%H:%M:%S %Z", "%H:%M:%S"],
944 "arabic_arabi" : ["%I:%M:%S %p %Z", "%I:%M %p"],
945 "arabic_arabtex" : ["%I:%M:%S %p %Z", "%I:%M %p"],
946 "armenian" : ["%H:%M:%S %Z", "%H:%M"],
947 "asturian" : ["%H:%M:%S %Z", "%H:%M"],
948 "australian" : ["%I:%M:%S %p %Z", "%I:%M %p"],
949 "austrian" : ["%H:%M:%S %Z", "%H:%M"],
950 "bahasa" : ["%H.%M.%S %Z", "%H.%M"],
951 "bahasam" : ["%I:%M:%S %p %Z", "%I:%M %p"],
952 "basque" : ["%H:%M:%S (%Z)", "%H:%M"],
953 "belarusian" : ["%H:%M:%S, %Z", "%H:%M"],
954 "bosnian" : ["%H:%M:%S %Z", "%H:%M"],
955 "brazilian" : ["%H:%M:%S %Z", "%H:%M"],
956 "breton" : ["%H:%M:%S %Z", "%H:%M"],
957 "british" : ["%H:%M:%S %Z", "%H:%M"],
958 "bulgarian" : ["%H:%M:%S %Z", "%H:%M"],
959 "canadian" : ["%I:%M:%S %p %Z", "%I:%M %p"],
960 "canadien" : ["%H:%M:%S %Z", "%H h %M"],
961 "catalan" : ["%H:%M:%S %Z", "%H:%M"],
962 "chinese-simplified" : ["%Z %p%I:%M:%S", "%p%I:%M"],
963 "chinese-traditional" : ["%p%I:%M:%S [%Z]", "%p%I:%M"],
964 "coptic" : ["%H:%M:%S %Z", "%H:%M:%S"],
965 "croatian" : ["%H:%M:%S (%Z)", "%H:%M"],
966 "czech" : ["%H:%M:%S %Z", "%H:%M"],
967 "danish" : ["%H.%M.%S %Z", "%H.%M"],
968 "divehi" : ["%H:%M:%S %Z", "%H:%M"],
969 "dutch" : ["%H:%M:%S %Z", "%H:%M"],
970 "english" : ["%I:%M:%S %p %Z", "%I:%M %p"],
971 "esperanto" : ["%H:%M:%S %Z", "%H:%M:%S"],
972 "estonian" : ["%H:%M:%S %Z", "%H:%M"],
973 "farsi" : ["%H:%M:%S (%Z)", "%H:%M"],
974 "finnish" : ["%H.%M.%S %Z", "%H.%M"],
975 "french" : ["%H:%M:%S %Z", "%H:%M"],
976 "friulan" : ["%H:%M:%S %Z", "%H:%M"],
977 "galician" : ["%H:%M:%S %Z", "%H:%M"],
978 "georgian" : ["%H:%M:%S %Z", "%H:%M"],
979 "german" : ["%H:%M:%S %Z", "%H:%M"],
980 "german-ch" : ["%H:%M:%S %Z", "%H:%M"],
981 "german-ch-old" : ["%H:%M:%S %Z", "%H:%M"],
982 "greek" : ["%I:%M:%S %p %Z", "%I:%M %p"],
983 "hebrew" : ["%H:%M:%S %Z", "%H:%M"],
984 "hindi" : ["%I:%M:%S %p %Z", "%I:%M %p"],
985 "icelandic" : ["%H:%M:%S %Z", "%H:%M"],
986 "interlingua" : ["%H:%M:%S %Z", "%H:%M"],
987 "irish" : ["%H:%M:%S %Z", "%H:%M"],
988 "italian" : ["%H:%M:%S %Z", "%H:%M"],
989 "japanese" : ["%H時%M分%S秒 %Z", "%H:%M"],
990 "japanese-cjk" : ["%H時%M分%S秒 %Z", "%H:%M"],
991 "kannada" : ["%I:%M:%S %p %Z", "%I:%M %p"],
992 "kazakh" : ["%H:%M:%S %Z", "%H:%M"],
993 "khmer" : ["%I:%M:%S %p %Z", "%I:%M %p"],
994 "korean" : ["%p %I시%M분 %S초 %Z", "%p %I:%M"],
995 "kurmanji" : ["%H:%M:%S %Z", "%H:%M:%S"],
996 "lao" : ["%H ໂມງ%M ນາທີ %S ວິນາທີ %Z", "%H:%M"],
997 "latin" : ["%H:%M:%S %Z", "%H:%M:%S"],
998 "latvian" : ["%H:%M:%S %Z", "%H:%M"],
999 "lithuanian" : ["%H:%M:%S %Z", "%H:%M"],
1000 "lowersorbian" : ["%H:%M:%S %Z", "%H:%M"],
1001 "macedonian" : ["%H:%M:%S %Z", "%H:%M"],
1002 "magyar" : ["%H:%M:%S %Z", "%H:%M"],
1003 "marathi" : ["%I:%M:%S %p %Z", "%I:%M %p"],
1004 "mongolian" : ["%H:%M:%S %Z", "%H:%M"],
1005 "naustrian" : ["%H:%M:%S %Z", "%H:%M"],
1006 "newzealand" : ["%I:%M:%S %p %Z", "%I:%M %p"],
1007 "ngerman" : ["%H:%M:%S %Z", "%H:%M"],
1008 "norsk" : ["%H:%M:%S %Z", "%H:%M"],
1009 "nynorsk" : ["kl. %H:%M:%S %Z", "%H:%M"],
1010 "occitan" : ["%H:%M:%S %Z", "%H:%M"],
1011 "piedmontese" : ["%H:%M:%S %Z", "%H:%M:%S"],
1012 "polish" : ["%H:%M:%S %Z", "%H:%M"],
1013 "polutonikogreek" : ["%I:%M:%S %p %Z", "%I:%M %p"],
1014 "portuguese" : ["%H:%M:%S %Z", "%H:%M"],
1015 "romanian" : ["%H:%M:%S %Z", "%H:%M"],
1016 "romansh" : ["%H:%M:%S %Z", "%H:%M"],
1017 "russian" : ["%H:%M:%S %Z", "%H:%M"],
1018 "samin" : ["%H:%M:%S %Z", "%H:%M"],
1019 "sanskrit" : ["%H:%M:%S %Z", "%H:%M"],
1020 "scottish" : ["%H:%M:%S %Z", "%H:%M"],
1021 "serbian" : ["%H:%M:%S %Z", "%H:%M"],
1022 "serbian-latin" : ["%H:%M:%S %Z", "%H:%M"],
1023 "slovak" : ["%H:%M:%S %Z", "%H:%M"],
1024 "slovene" : ["%H:%M:%S %Z", "%H:%M"],
1025 "spanish" : ["%H:%M:%S (%Z)", "%H:%M"],
1026 "spanish-mexico" : ["%H:%M:%S %Z", "%H:%M"],
1027 "swedish" : ["kl. %H:%M:%S %Z", "%H:%M"],
1028 "syriac" : ["%H:%M:%S %Z", "%H:%M"],
1029 "tamil" : ["%p %I:%M:%S %Z", "%p %I:%M"],
1030 "telugu" : ["%I:%M:%S %p %Z", "%I:%M %p"],
1031 "thai" : ["%H นาฬิกา %M นาที %S วินาที %Z", "%H:%M"],
1032 "tibetan" : ["%I:%M:%S %p %Z", "%I:%M %p"],
1033 "turkish" : ["%H:%M:%S %Z", "%H:%M"],
1034 "turkmen" : ["%H:%M:%S %Z", "%H:%M"],
1035 "ukrainian" : ["%H:%M:%S %Z", "%H:%M"],
1036 "uppersorbian" : ["%H:%M:%S %Z", "%H:%M hodź."],
1037 "urdu" : ["%I:%M:%S %p %Z", "%I:%M %p"],
1038 "vietnamese" : ["%H:%M:%S %Z", "%H:%M"],
1039 "welsh" : ["%H:%M:%S %Z", "%H:%M"]
1042 types = ["time", "fixtime", "modtime" ]
1044 i = find_token(document.header, "\\language", 0)
1046 # this should not happen
1047 document.warning("Malformed LyX document! No \\language header found!")
1049 lang = get_value(document.header, "\\language", i)
1053 i = find_token(document.body, "\\begin_inset Info", i)
1056 j = find_end_of_inset(document.body, i + 1)
1058 document.warning("Malformed LyX document: Could not find end of Info inset.")
1061 tp = find_token(document.body, 'type', i, j)
1062 tpv = get_quoted_value(document.body, "type", tp)
1063 if tpv not in types:
1066 arg = find_token(document.body, 'arg', i, j)
1067 argv = get_quoted_value(document.body, "arg", arg)
1069 dtme = datetime.now()
1071 if tpv == "fixtime":
1072 timecomps = argv.split('@')
1073 if len(timecomps) > 1:
1075 isotime = timecomps[1]
1076 m = re.search('(\d\d):(\d\d):(\d\d)', isotime)
1078 tme = time(int(m.group(1)), int(m.group(2)), int(m.group(3)))
1080 m = re.search('(\d\d):(\d\d)', isotime)
1082 tme = time(int(m.group(1)), int(m.group(2)))
1083 # FIXME if we had the path to the original document (not the one in the tmp dir),
1084 # we could use the mtime.
1085 # elif tpv == "moddate":
1086 # dte = date.fromtimestamp(os.path.getmtime(document.dir))
1089 result = tme.isoformat()
1090 elif argv == "long":
1091 result = tme.strftime(timeformats[lang][0])
1092 elif argv == "short":
1093 result = tme.strftime(timeformats[lang][1])
1095 fmt = argv.replace("HH", "%H").replace("H", "%H").replace("hh", "%I").replace("h", "%I")
1096 fmt = fmt.replace("mm", "%M").replace("m", "%M").replace("ss", "%S").replace("s", "%S")
1097 fmt = fmt.replace("zzz", "%f").replace("z", "%f").replace("t", "%Z")
1098 fmt = fmt.replace("AP", "%p").replace("ap", "%p").replace("A", "%p").replace("a", "%p")
1099 fmt = fmt.replace("'", "")
1100 result = dte.strftime(fmt)
1101 document.body[i : j+1] = result
1105 def revert_namenoextinfo(document):
1106 " Merge buffer Info inset type name-noext to name. "
1110 i = find_token(document.body, "\\begin_inset Info", i)
1113 j = find_end_of_inset(document.body, i + 1)
1115 document.warning("Malformed LyX document: Could not find end of Info inset.")
1118 tp = find_token(document.body, 'type', i, j)
1119 tpv = get_quoted_value(document.body, "type", tp)
1123 arg = find_token(document.body, 'arg', i, j)
1124 argv = get_quoted_value(document.body, "arg", arg)
1125 if argv != "name-noext":
1128 document.body[arg] = "arg \"name\""
1136 supported_versions = ["2.4.0", "2.4"]
1138 [545, [convert_lst_literalparam]],
1143 [550, [convert_fontenc]],
1150 [557, [convert_vcsinfo]],
1151 [558, [removeFrontMatterStyles]],
1154 [561, [convert_dejavu]]
1158 [560, [revert_dejavu]],
1159 [559, [revert_timeinfo, revert_namenoextinfo]],
1160 [558, [revert_dateinfo]],
1161 [557, [addFrontMatterStyles]],
1162 [556, [revert_vcsinfo]],
1163 [555, [revert_bibencoding]],
1164 [554, [revert_vcolumns]],
1165 [553, [revert_stretchcolumn]],
1166 [552, [revert_tuftecite]],
1167 [551, [revert_floatpclass, revert_floatalignment]],
1168 [550, [revert_nospellcheck]],
1169 [549, [revert_fontenc]],
1170 [548, []],# dummy format change
1171 [547, [revert_lscape]],
1172 [546, [revert_xcharter]],
1173 [545, [revert_paratype]],
1174 [544, [revert_lst_literalparam]]
1178 if __name__ == "__main__":