2 # -*- coding: utf-8 -*-
4 # file prefs2prefs-lfuns.py
5 # This file is part of LyX, the document processor.
6 # Licence details can be found in the file COPYING.
10 # Full author contact details are available in file CREDITS
12 # This file houses conversion information for the preferences file.
14 # The converter functions take a line as argument and return a list:
16 # where the Bool says if we've modified anything and the NewLine is
17 # the new line, if so, which will be used to replace the old line.
22 ###########################################################
26 def simple_renaming(line, old, new):
27 if line.find(old) == -1:
29 line = line.replace(old, new)
32 no_match = (False, [])
34 ########################
35 ### Format 1 conversions
37 def remove_obsolete(line):
38 tags = ("\\use_tempdir", "\\spell_command", "\\personal_dictionary",
39 "\\plaintext_roff_command", "\\use_alt_language",
40 "\\use_escape_chars", "\\use_input_encoding",
41 "\\use_personal_dictionary", "\\use_pspell",
45 if line.startswith(tag):
49 def language_use_babel(line):
50 if not line.startswith("\language_use_babel"):
52 re_lub = re.compile(r'^\\language_use_babel\s+"?(true|false)')
53 m = re_lub.match(line)
58 newline = "\\language_package_selection " + newval
59 return (True, newline)
61 def language_package(line):
62 return simple_renaming(line, "\\language_package", "\\language_custom_package")
64 lfre = re.compile(r'^\\converter\s+"?(\w+)"?\s+"?(\w+)"?\s+"([^"]*?)"\s+"latex"')
65 def latex_flavor(line):
66 if not line.startswith("\\converter"):
75 if conv in ("platex", "xetex", "luatex"):
78 "\\converter \"%s\" \"%s\" \"%s\" \"latex=%s\"" % (conv, fmat, args, flavor))
80 emre = re.compile(r'^\\[Ff]ormat\s+(.*)\s+"(document[^"]*?)"')
81 def export_menu(line):
82 if not line.lower().startswith("\\format"):
90 "\\Format %s \"%s,menu=export\"" % (fmat, opts))
92 ########################
96 [ # this will be a long list of conversions for format 0
102 ] # end conversions for format 0