Dear LyX Developers,

I've spent some time today working on a patch to support exporting the LyX CSS 
stylesheet as a separate file. This is what I've come up with so far. Would you 
mind having a look and letting me know if there is amore efficient way to do it?

++ Line 1773, Buffer.cpp

if (params().html_css_as_file) {
                        lyxerr << "Export Separate CSS: True";
                        // Create a Link to the Stylesheet
                        os << "<link rel='stylesheet' href='docstyle.css' 
type='text/css'>\n";
                        // Create a New Stream for CSS
                        ofdocstream ocss;
                        string const fcssname = filePath() + "docstyle.css";
                        // Check to see if it is open
                        if (!openFileWrite(ocss, FileName(fcssname)))
                                return;
                        // Write Styles
                        docstring const styleinfo = 
features.getTClassHTMLStyles();
                        if (!styleinfo.empty()) {
                                ocss << styleinfo
                                        << "\n";
                        }
                        if (needfg)
                           ocss << "  color: "
                                        << 
from_ascii(X11hexname(params().fontcolor))
                                        << ";\n";
                        if (needbg)
                           ocss << "  background-color: "
                                        << 
from_ascii(X11hexname(params().backgroundcolor))
                                        << ";\n";
                        ocss.close();
                        if (ocss.fail())
                                lyxerr << "File '" << fcssname << "' was not 
closed properly." << endl;
                }
                else  {
                        lyxerr << "Export Separate CSS: False";
                        os << "\n<!-- Layout-provided Styles -->\n";
                        docstring const styleinfo = 
features.getTClassHTMLStyles();
                        if (!styleinfo.empty()) {
                                os << "<style type='text/css'>\n"
                                        << styleinfo << "\n";
                        }
                        if (needfg || needbg) {
                                        os << "<style type='text/css'>\nbody 
{\n";
                                        if (needfg)
                                           os << "  color: "
                                                        << 
from_ascii(X11hexname(params().fontcolor))
                                                        << ";\n";
                                        if (needbg)
                                           os << "  background-color: "
                                                        << 
from_ascii(X11hexname(params().backgroundcolor))
                                                        << ";\n";
                                        os << "}\n</style>\n";
                        }
                }
                os << "</head>\n";
        }

Cheers,

Rob

Reply via email to