]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
Differentiate backups from autosave files (#12659)
[lyx.git] / src / Buffer.cpp
index 07287221685cbc37769c1a4f4e0699608160c9e2..4d7adc3534bc4e1b41f6268605458f49e17d7ddc 100644 (file)
@@ -2172,8 +2172,14 @@ Buffer::ExportStatus Buffer::writeDocBookSource(odocstream & os,
                        mathmlNamespace = + " xmlns:" + mathmlPrefix + "=\"http://www.w3.org/1998/Math/MathML\"";
                }
 
+               // XML-compatible language code: in lib/languages, language codes are
+               // given as dictionary file names; HTML5 expects to follow BCP47. This
+               // function implements a simple heuristic that does the conversion.
+               std::string htmlCode = params().language->code();
+               std::replace(htmlCode.begin(), htmlCode.end(), '_', '-');
+
                // Directly output the root tag, based on the current type of document.
-               string attributes = "xml:lang=\"" + params().language->code() + '"'
+               string attributes = "xml:lang=\"" + htmlCode + '"'
                                                    + " xmlns=\"http://docbook.org/ns/docbook\""
                                                    + " xmlns:xlink=\"http://www.w3.org/1999/xlink\""
                                                    + mathmlNamespace
@@ -2239,13 +2245,16 @@ Buffer::ExportStatus Buffer::writeLyXHTMLSource(odocstream & os,
          output == FullSource || output == OnlyBody || output == IncludedFile;
 
        if (output_preamble) {
+               // HTML5-compatible language code: in lib/languages, language codes are
+               // given as dictionary file names; HTML5 expects to follow BCP47. This
+               // function implements a simple heuristic that does the conversion.
+               std::string htmlCode = params().language->code();
+               std::replace(htmlCode.begin(), htmlCode.end(), '_', '-');
+
                os << "<!DOCTYPE html>\n"
-                  << "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"" << from_ascii(params().language->code()) << "\">\n"
+                  << "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"" << from_ascii(htmlCode) << "\">\n"
                   << "<head>\n"
-                  << "<meta name=\"GENERATOR\" content=\"" << PACKAGE_STRING << "\" />\n"
-                  << "<meta charset=\"UTF-8\" />\n"
-                  // FIXME Presumably need to set this right
-                  << "<meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\" />\n";
+                  << "<meta name=\"generator\" content=\"" << PACKAGE_STRING << "\" />\n";
 
                docstring const & doctitle = features.htmlTitle();
                os << "<title>"
@@ -2305,7 +2314,7 @@ Buffer::ExportStatus Buffer::writeLyXHTMLSource(odocstream & os,
                        // we are here if the CSS is supposed to be written to the header
                        // or if we failed to write it to an external file.
                        if (!written) {
-                               os << "<style type='text/css'>\n"
+                               os << "<style>\n"
                                         << dstyles
                                         << "\n</style>\n";
                        }