+docstring InsetInclude::xhtml(XHTMLStream & xs, OutputParams const &rp) const
+{
+ if (rp.inComment)
+ return docstring();
+
+ // For verbatim and listings, we just include the contents of the file as-is.
+ // In the case of listings, we wrap it in <pre>.
+ bool const listing = isListings(params());
+ if (listing || isVerbatim(params())) {
+ if (listing)
+ xs << html::StartTag("pre");
+ // FIXME: We don't know the encoding of the file, default to UTF-8.
+ xs << includedFilename(buffer(), params()).fileContents("UTF-8");
+ if (listing)
+ xs << html::EndTag("pre");
+ return docstring();
+ }
+
+ // We don't (yet) know how to Input or Include non-LyX files.
+ // (If we wanted to get really arcane, we could run some tex2html
+ // converter on the included file. But that's just masochistic.)
+ FileName const included_file = includedFilename(buffer(), params());
+ if (!isLyXFilename(included_file.absFileName())) {
+ frontend::Alert::warning(_("Unsupported Inclusion"),
+ bformat(_("LyX does not know how to include non-LyX files when "
+ "generating HTML output. Offending file:\n%1$s"),
+ params()["filename"]));
+ return docstring();
+ }
+
+ // In the other cases, we will generate the HTML and include it.
+
+ // Check we're not trying to include ourselves.
+ // FIXME RECURSIVE INCLUDE
+ if (buffer().absFileName() == included_file.absFileName()) {
+ Alert::error(_("Recursive input"),
+ bformat(_("Attempted to include file %1$s in itself! "
+ "Ignoring inclusion."), params()["filename"]));
+ return docstring();
+ }
+
+ Buffer const * const ibuf = loadIfNeeded();
+ if (!ibuf)
+ return docstring();
+ ibuf->writeLyXHTMLSource(xs.os(), rp, true);
+ return docstring();
+}
+
+
+int InsetInclude::plaintext(odocstream & os, OutputParams const &) const