]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetListings.cpp
Restore XHTML output for InsetListings.
[lyx.git] / src / insets / InsetListings.cpp
index 42f02825b800244a9403f87d7df126689bae31a0..e20d3c76df477b23ce7415066d4d7dfde29d152c 100644 (file)
@@ -26,6 +26,7 @@
 #include "Language.h"
 #include "MetricsInfo.h"
 #include "output_latex.h"
+#include "output_xhtml.h"
 #include "TextClass.h"
 
 #include "support/debug.h"
@@ -51,7 +52,7 @@ using boost::regex;
 char const lstinline_delimiters[] =
        "!*()-=+|;:'\"`,<.>/?QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm";
 
-InsetListings::InsetListings(Buffer const & buf, InsetListingsParams const & par)
+InsetListings::InsetListings(Buffer * buf, InsetListingsParams const & par)
        : InsetCollapsable(buf)
 {
        status_ = par.status();
@@ -70,7 +71,7 @@ Inset::DisplayType InsetListings::display() const
 }
 
 
-void InsetListings::updateLabels(ParIterator const & it)
+void InsetListings::updateLabels(ParIterator const & it, bool out)
 {
        Counters & cnts = buffer().masterBuffer()->params().documentClass().counters();
        string const saveflt = cnts.current_float();
@@ -78,7 +79,7 @@ void InsetListings::updateLabels(ParIterator const & it)
        // Tell to captions what the current float is
        cnts.current_float("listing");
 
-       InsetCollapsable::updateLabels(it);
+       InsetCollapsable::updateLabels(it, out);
 
        //reset afterwards
        cnts.current_float(saveflt);
@@ -123,12 +124,6 @@ void InsetListings::read(Lexer & lex)
 }
 
 
-docstring InsetListings::editMessage() const
-{
-       return _("Opened Listing Inset");
-}
-
-
 int InsetListings::latex(odocstream & os, OutputParams const & runparams) const
 {
        string param_string = params().params();
@@ -273,34 +268,37 @@ int InsetListings::latex(odocstream & os, OutputParams const & runparams) const
 }
 
 
-docstring InsetListings::xhtml(odocstream & os, OutputParams const & rp) const
+docstring InsetListings::xhtml(XHTMLStream & os, OutputParams const & rp) const
 {
-       odocstringstream out;
+       odocstringstream ods;
+       XHTMLStream out(ods);
 
        bool const isInline = params().isInline();
        if (isInline) 
-               out << "<br />\n";
+               out << CompTag("br");
        else {
-               out << "<div class='float float-listings'>\n";
+               out << StartTag("div", "class='float float-listings'");
                docstring caption = getCaptionHTML(rp);
                if (!caption.empty())
-                       out << "<div class='float-caption'>" << caption << "</div>\n";
+                       out << StartTag("div", "class='float-caption'") 
+                           << caption << EndTag("div");
        }
 
-       out << "<pre>\n";
+       out << StartTag("pre");
        OutputParams newrp = rp;
-       newrp.disable_captions = true;
+       newrp.html_disable_captions = true;
        docstring def = InsetText::xhtml(out, newrp);
-       out << "\n</pre>\n";
+       out << EndTag("pre");
 
        if (isInline) {
-               out << "<br />\n";
-               os << out.str();
+               out << CompTag("br");
+               // escaping will already have been done
+               os << XHTMLStream::NextRaw() << ods.str();
        } else {
-               out <<  "</div>";
+               out << EndTag("div");
                // In this case, this needs to be deferred, but we'll put it
                // before anything the text itself deferred.
-               def = out.str() + '\n' + def;
+               def = ods.str() + '\n' + def;
        }
        return def;
 }