]> git.lyx.org Git - features.git/blobdiff - src/tex2lyx/Preamble.cpp
tex2lyx: support for bibencoding argument of \addbibresource
[features.git] / src / tex2lyx / Preamble.cpp
index 924df1692941990dfb2b432344eb6f4cbb3293f8..b0ac77970b3ff30d33f0f57fff90c0c17dfd229d 100644 (file)
@@ -1752,7 +1752,28 @@ void Preamble::parse(Parser & p, string const & forceclass,
                }
 
                if (t.cs() == "addbibresource") {
-                       biblatex_bibliographies.push_back(removeExtension(p.getArg('{', '}')));
+                       string const options =  p.getArg('[', ']');
+                       string const arg = removeExtension(p.getArg('{', '}'));
+                       if (!options.empty()) {
+                               // check if the option contains a bibencoding, if yes, extract it
+                               string::size_type pos = options.find("bibencoding=");
+                               string encoding;
+                               if (pos != string::npos) {
+                                       string::size_type i = options.find(',', pos);
+                                       if (i == string::npos)
+                                               encoding = options.substr(pos + 1);
+                                       else
+                                               encoding = options.substr(pos, i - pos);
+                                       pos = encoding.find('=');
+                                       if (pos == string::npos)
+                                               encoding.clear();
+                                       else
+                                               encoding = encoding.substr(pos + 1);
+                               }
+                               if (!encoding.empty())
+                                       biblatex_encodings.push_back(normalize_filename(arg) + ' ' + encoding);
+                       }
+                       biblatex_bibliographies.push_back(arg);
                        continue;
                }