]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetListings.cpp
Pure HTML output for math macros.
[lyx.git] / src / insets / InsetListings.cpp
index 0174a977f875511590944fdf1edb944e82121ddd..de0e26ae45c4b04bc3b24dd8fa839eead056c1ee 100644 (file)
@@ -24,8 +24,9 @@
 #include "FuncStatus.h"
 #include "InsetCaption.h"
 #include "Language.h"
-#include "MetricsInfo.h"
+#include "Lexer.h"
 #include "output_latex.h"
+#include "output_xhtml.h"
 #include "TextClass.h"
 
 #include "support/debug.h"
@@ -70,7 +71,7 @@ Inset::DisplayType InsetListings::display() const
 }
 
 
-void InsetListings::updateLabels(ParIterator const & it, bool out)
+void InsetListings::updateBuffer(ParIterator const & it, UpdateType utype)
 {
        Counters & cnts = buffer().masterBuffer()->params().documentClass().counters();
        string const saveflt = cnts.current_float();
@@ -78,7 +79,7 @@ void InsetListings::updateLabels(ParIterator const & it, bool out)
        // Tell to captions what the current float is
        cnts.current_float("listing");
 
-       InsetCollapsable::updateLabels(it, out);
+       InsetCollapsable::updateBuffer(it, utype);
 
        //reset afterwards
        cnts.current_float(saveflt);
@@ -267,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 << html::CompTag("br");
        else {
-               out << "<div class='float float-listings'>\n";
+               out << html::StartTag("div", "class='float float-listings'");
                docstring caption = getCaptionHTML(rp);
                if (!caption.empty())
-                       out << "<div class='float-caption'>" << caption << "</div>\n";
+                       out << html::StartTag("div", "class='float-caption'") 
+                           << caption << html::EndTag("div");
        }
 
-       out << "<pre>\n";
+       out << html::StartTag("pre");
        OutputParams newrp = rp;
        newrp.html_disable_captions = true;
-       docstring def = InsetText::xhtml(out, newrp);
-       out << "\n</pre>\n";
+       docstring def = InsetText::insetAsXHTML(out, newrp, InsetText::JustText);
+       out << html::EndTag("pre");
 
        if (isInline) {
-               out << "<br />\n";
-               os << out.str();
+               out << html::CompTag("br");
+               // escaping will already have been done
+               os << XHTMLStream::NextRaw() << ods.str();
        } else {
-               out <<  "</div>";
+               out << html::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;
 }