mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Second step towards a more generic package off/auto/on handling:
File format change git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40563 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6be6d9a947
commit
bf3f3f9816
@ -11,6 +11,14 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
|
||||
|
||||
-----------------------
|
||||
|
||||
2012-01-03 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
* Format incremented to 422 (r40563)
|
||||
\use_amsmath 0/1/2 => \use_package amsmath 0/1/2
|
||||
\use_esint 0/1/2 => \use_package esint 0/1/2
|
||||
\use_mhchem 0/1/2 => \use_package mhchem 0/1/2
|
||||
\use_mathdots 0/1/2 => \use_package mathdots 0/1/2
|
||||
\use_undertilde 0/1/2 => \use_package undertilde 0/1/2
|
||||
|
||||
2011-12-18 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
* Format incremented to 421 (r40522)
|
||||
The caption flag of longtable rows is no longer exclusive to the head
|
||||
|
@ -26,12 +26,12 @@ import sys, os
|
||||
# Uncomment only what you need to import, please.
|
||||
|
||||
from parser_tools import del_token, find_token, find_end_of, find_end_of_inset, \
|
||||
get_option_value, get_value, get_quoted_value, set_option_value
|
||||
find_re, get_option_value, get_value, get_quoted_value, set_option_value
|
||||
|
||||
#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
|
||||
#del_token, check_token
|
||||
|
||||
from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert
|
||||
|
||||
@ -332,6 +332,27 @@ def revert_longtable_captions(document):
|
||||
handle_longtable_captions(document, False)
|
||||
|
||||
|
||||
def convert_use_packages(document):
|
||||
"use_xxx yyy => use_package xxx yyy"
|
||||
packages = ["amsmath", "esint", "mathdots", "mhchem", "undertilde"]
|
||||
for p in packages:
|
||||
i = find_token(document.header, "\\use_%s" % p , 0)
|
||||
if i != -1:
|
||||
value = get_value(document.header, "\\use_%s" % p , i)
|
||||
document.header[i] = "\\use_package %s %s" % (p, value)
|
||||
|
||||
|
||||
def revert_use_packages(document):
|
||||
"use_package xxx yyy => use_xxx yyy"
|
||||
packages = ["amsmath", "esint", "mathdots", "mhchem", "undertilde"]
|
||||
for p in packages:
|
||||
regexp = re.compile(r'(\\use_package\s+%s)' % p)
|
||||
i = find_re(document.header, regexp, 0)
|
||||
if i != -1:
|
||||
values = get_value(document.header, "\\use_package" , i)
|
||||
document.header[i] = "\\use_%s" % values
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -346,9 +367,11 @@ convert = [
|
||||
[419, []],
|
||||
[420, [convert_biblio_style]],
|
||||
[421, [convert_longtable_captions]],
|
||||
[422, [convert_use_packages]],
|
||||
]
|
||||
|
||||
revert = [
|
||||
[421, [revert_use_packages]],
|
||||
[420, [revert_longtable_captions]],
|
||||
[419, [revert_biblio_style]],
|
||||
[418, [revert_australian]],
|
||||
|
@ -700,26 +700,12 @@ string BufferParams::readToken(Lexer & lex, string const & token,
|
||||
papersize = papersizetranslator().find(ppsize);
|
||||
} else if (token == "\\use_geometry") {
|
||||
lex >> use_geometry;
|
||||
} else if (token == "\\use_amsmath") {
|
||||
int use_ams;
|
||||
lex >> use_ams;
|
||||
use_package("amsmath", packagetranslator().find(use_ams));
|
||||
} else if (token == "\\use_esint") {
|
||||
int useesint;
|
||||
lex >> useesint;
|
||||
use_package("esint", packagetranslator().find(useesint));
|
||||
} else if (token == "\\use_mhchem") {
|
||||
int usemhchem;
|
||||
lex >> usemhchem;
|
||||
use_package("mhchem", packagetranslator().find(usemhchem));
|
||||
} else if (token == "\\use_mathdots") {
|
||||
int usemathdots;
|
||||
lex >> usemathdots;
|
||||
use_package("mathdots", packagetranslator().find(usemathdots));
|
||||
} else if (token == "\\use_undertilde") {
|
||||
int useundertilde;
|
||||
lex >> useundertilde;
|
||||
use_package("undertilde", packagetranslator().find(useundertilde));
|
||||
} else if (token == "\\use_package") {
|
||||
string package;
|
||||
int use;
|
||||
lex >> package;
|
||||
lex >> use;
|
||||
use_package(package, packagetranslator().find(use));
|
||||
} else if (token == "\\cite_engine") {
|
||||
string engine;
|
||||
lex >> engine;
|
||||
@ -1023,13 +1009,12 @@ void BufferParams::writeFile(ostream & os) const
|
||||
pdfoptions().writeFile(os);
|
||||
|
||||
os << "\\papersize " << string_papersize[papersize]
|
||||
<< "\n\\use_geometry " << convert<string>(use_geometry)
|
||||
<< "\n\\use_amsmath " << use_package("amsmath")
|
||||
<< "\n\\use_esint " << use_package("esint")
|
||||
<< "\n\\use_mhchem " << use_package("mhchem")
|
||||
<< "\n\\use_mathdots " << use_package("mathdots")
|
||||
<< "\n\\use_undertilde " << use_package("undertilde")
|
||||
<< "\n\\cite_engine " << citeenginetranslator().find(cite_engine_)
|
||||
<< "\n\\use_geometry " << convert<string>(use_geometry);
|
||||
vector<string> const & packages = auto_packages();
|
||||
for (size_t i = 0; i < packages.size(); ++i)
|
||||
os << "\n\\use_package " << packages[i] << ' '
|
||||
<< use_package(packages[i]);
|
||||
os << "\n\\cite_engine " << citeenginetranslator().find(cite_engine_)
|
||||
<< "\n\\biblio_style " << biblio_style
|
||||
<< "\n\\use_bibtopic " << convert<string>(use_bibtopic)
|
||||
<< "\n\\use_indices " << convert<string>(use_indices)
|
||||
|
@ -926,11 +926,11 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc)
|
||||
}
|
||||
os << "\\papersize " << h_papersize << "\n"
|
||||
<< "\\use_geometry " << h_use_geometry << "\n"
|
||||
<< "\\use_amsmath " << h_use_amsmath << "\n"
|
||||
<< "\\use_esint " << h_use_esint << "\n"
|
||||
<< "\\use_mhchem " << h_use_mhchem << "\n"
|
||||
<< "\\use_mathdots " << h_use_mathdots << "\n"
|
||||
<< "\\use_undertilde " << h_use_undertilde << "\n"
|
||||
<< "\\use_package amsmath " << h_use_amsmath << '\n'
|
||||
<< "\\use_package esint " << h_use_esint << '\n'
|
||||
<< "\\use_package mhchem " << h_use_mhchem << '\n'
|
||||
<< "\\use_package mathdots " << h_use_mathdots << '\n'
|
||||
<< "\\use_package undertilde " << h_use_undertilde << '\n'
|
||||
<< "\\cite_engine " << h_cite_engine << "\n"
|
||||
<< "\\biblio_style " << h_biblio_style << "\n"
|
||||
<< "\\use_bibtopic " << h_use_bibtopic << "\n"
|
||||
|
@ -30,8 +30,8 @@ extern char const * const lyx_version_info;
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// independent branches. Instead add your own.
|
||||
#define LYX_FORMAT_LYX 421 // baum : longtable captions
|
||||
#define LYX_FORMAT_TEX2LYX 421
|
||||
#define LYX_FORMAT_LYX 422 // baum : \\use_package
|
||||
#define LYX_FORMAT_TEX2LYX 422
|
||||
|
||||
#if LYX_FORMAT_FOR_TEX2LYX != LYX_FORMAT_FOR_LYX
|
||||
#warning "tex2lyx produces an out of date file format."
|
||||
|
Loading…
Reference in New Issue
Block a user