X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=lib%2Fscripts%2Fprefs2prefs_prefs.py;h=5ce10511bce434564cb85dde500db2c19ccb39e9;hb=c0bbc020a56e0e55fe4a07230ab6d9851fef0c24;hp=5a0970bbfd00c48092c6b1de31331d741b78d568;hpb=14f0e155734cf1f1e58edd06b45c71c85e057f24;p=lyx.git diff --git a/lib/scripts/prefs2prefs_prefs.py b/lib/scripts/prefs2prefs_prefs.py index 5a0970bbfd..5ce10511bc 100644 --- a/lib/scripts/prefs2prefs_prefs.py +++ b/lib/scripts/prefs2prefs_prefs.py @@ -16,6 +16,23 @@ # where the Bool says if we've modified anything and the NewLine is # the new line, if so, which will be used to replace the old line. +# Incremented to format 2, r39670 by jrioux +# Support for multiple file extensions per format. +# No conversion necessary. + +# Incremented to format 3, r39705 by tommaso +# Support for file formats that are natively (g)zipped. +# We must add the flag zipped=native to formats that +# were previously hardcoded in the C++ source: dia. + +# Incremented to format 4, r40028 by vfr +# Remove support for default paper size. + +# Incremented to format 5, r40030 by vfr +# Add a default length unit. +# No conversion necessary. + + import re @@ -49,7 +66,7 @@ def remove_obsolete(line): def language_use_babel(line): if not line.startswith("\language_use_babel"): return no_match - re_lub = re.compile(r'^\\language_use_babel\s+(true|false)') + re_lub = re.compile(r'^\\language_use_babel\s+"?(true|false)') m = re_lub.match(line) val = m.group(1) newval = '0' @@ -71,21 +88,63 @@ def latex_flavor(line): conv = m.group(1) fmat = m.group(2) args = m.group(3) - flavor = "pdflatex" - if conv in ("platex", "xetex", "luatex"): + conv2fl = { + "luatex": "lualatex", + "pplatex": "latex", + "xetex": "xelatex", + } + if conv in conv2fl.keys(): + flavor = conv2fl[conv] + else: flavor = conv - return (True, + if flavor == "latex": + return no_match + return (True, "\\converter \"%s\" \"%s\" \"%s\" \"latex=%s\"" % (conv, fmat, args, flavor)) +emre = re.compile(r'^\\[Ff]ormat\s+(.*)\s+"(document[^"]*?)"') +def export_menu(line): + if not line.lower().startswith("\\format"): + return no_match + m = emre.match(line) + if not m: + return no_match + fmat = m.group(1) + opts = m.group(2) + return (True, + "\\Format %s \"%s,menu=export\"" % (fmat, opts)) + +zipre = re.compile(r'^\\[Ff]ormat\s+("?dia"?\s+.*)\s+"([^"]*?)"') +def zipped_native(line): + if not line.lower().startswith("\\format"): + return no_match + m = zipre.match(line) + if not m: + return no_match + fmat = m.group(1) + opts = m.group(2) + return (True, + "\\Format %s \"%s,zipped=native\"" % (fmat, opts)) + +def remove_default_papersize(line): + if not line.startswith("\\default_papersize"): + return no_match + return (True, "") + ######################## conversions = [ - [ # this will be a long list of conversions for format 0 + [ 1, [ # this will be a long list of conversions to format 1 + export_menu, latex_flavor, remove_obsolete, language_use_babel, language_package - ] # end conversions for format 0 + ]], + [ 2, []], + [ 3, [ zipped_native ]], + [ 4, [ remove_default_papersize ]], + [ 5, []], ]