]> git.lyx.org Git - features.git/commitdiff
tex2lyx: add bib encoding support.
authorJuergen Spitzmueller <spitz@lyx.org>
Tue, 21 Aug 2018 06:19:24 +0000 (08:19 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Tue, 21 Aug 2018 06:19:24 +0000 (08:19 +0200)
src/tex2lyx/Preamble.cpp
src/tex2lyx/Preamble.h
src/tex2lyx/TODO.txt
src/tex2lyx/tex2lyx.cpp
src/tex2lyx/text.cpp

index f87ee6f853bc00bdaf2aa779690ff9029f6e06d7..924df1692941990dfb2b432344eb6f4cbb3293f8 100644 (file)
@@ -1211,6 +1211,9 @@ void Preamble::handle_package(Parser &p, string const & name,
                                cerr << "Ignoring unkown refesection value '"
                                     << opt << "'.";
                }
+               opt = process_keyval_opt(options, "bibencoding");
+               if (!opt.empty())
+                       bibencoding = opt;
                if (!options.empty()) {
                        h_biblio_options = join(options, ",");
                        options.clear();
index 0d3ff0113fa191b272d4cec14439fa0c6527017c..ebc60c7d6dd3a0ea80315c71925047ce66a8f07a 100644 (file)
@@ -108,6 +108,10 @@ public:
        static const char * const coded_polyglossia_languages[];
        ///
        std::vector<std::string> biblatex_bibliographies;
+       ///
+       std::string bibencoding;
+       ///
+       std::string docencoding;
 
 private:
        ///
index 82411c58b25ae168816f689042cc2f28d753456b..dfda94001cd8af5086cd326017cd4ab866791cca 100644 (file)
@@ -45,9 +45,6 @@ Format LaTeX feature                        LyX feature
       \begin{landscape}...\end{landscape}  \begin_inset Flex Landscape
       with longtable content:              <features rotate ="90"...>
 555   V column type (varwidth package)     Automatically detected with newlines, paragraph breaks and environment content in cells of rows
-556   Bib files encoding
-      \begin_inset CommandInset bibtex     Biblatex: bibencoding=<encoding> [latex name]
-      encoding=<encoding> [lyx name]       BibTeX: \bgroup\inputencoding{<encoding>}...\egroup
 563   InsetArgument listpreamble:<nr>      All content between \begin{env} and first \item of a list 
 
 
index 89589ef706e9a0a16609422038d2547535e97b14..6437d9902de82e68162cc4b5677fe643edcfa5a6 100644 (file)
@@ -960,6 +960,8 @@ bool tex2lyx(FileName const & infilename, ostream & os, string encoding,
                        encoding = enc->iconvName();
                else
                        encoding = "ISO-8859-1";
+               // store
+               preamble.docencoding = encoding;
        }
 
        ifdocstream is(setEncoding(encoding));
index 54db8f63f5138855eb655b97d87967569b410acb..d242731b79b189657fb5e9d077f7c7352a2a0579 100644 (file)
@@ -5091,6 +5091,15 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                                bibliographystyle.clear();
                        }
                        os << "options " << '"' << BibOpts << '"' << "\n";
+                       if (p.getEncoding() != preamble.docencoding) {
+                               Encoding const * const enc = encodings.fromIconvName(
+                                       p.getEncoding(), Encoding::inputenc, true);
+                               if (!enc) {
+                                       cerr << "Unknown bib encoding " << p.getEncoding()
+                                            << ". Ignoring." << std::endl;
+                               } else
+                                       os << "encoding " << '"' << enc->name() << '"' << "\n";
+                       }
                        end_inset(os);
                        continue;
                }
@@ -5131,6 +5140,15 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        os << "options " << '"' << BibOpts << '"' << "\n";
                        if (!bbloptions.empty())
                                os << "biblatexopts " << '"' << bbloptions << '"' << "\n";
+                       if (!preamble.bibencoding.empty()) {
+                               Encoding const * const enc = encodings.fromLaTeXName(
+                                       preamble.bibencoding, Encoding::inputenc, true);
+                               if (!enc) {
+                                       cerr << "Unknown bib encoding " << preamble.bibencoding
+                                            << ". Ignoring." << std::endl;
+                               } else
+                                       os << "encoding " << '"' << enc->name() << '"' << "\n";
+                       }
                        end_inset(os);
                        need_commentbib = false;
                        continue;