mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
XHTML output for InsetInclude.
Here's the deal: * With verbatim, we include it verbatim. This would allow the inclusion of other HTML files. * With listings, we include it verbatim, wrapped in <pre>. * With Input and Include, we check if it's a LyX file. If not, we don't do anything, since we don't know how to include (say) a TeX file in the HTML output. (Wanna call tex4ht, anyone?) If it is a LyX file, we let it write itself as HTML, and include it. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30191 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1898db6aca
commit
16f119cab5
@ -14,8 +14,9 @@ Known issues:
|
||||
|
||||
These insets are basically done, though there are probably issues here and there,
|
||||
and there are even some FIXMEs:
|
||||
Bibitem, Branch, Caption, Collapsable, Footnote, Hyperlink, Info, Label, Line,
|
||||
Listings, Marginal, Note, Newline, Newpage, Quotes, Space, SpecialChar, Wrap
|
||||
Bibitem, Branch, Caption, Collapsable, Footnote, Hyperlink, Include, Info,
|
||||
Label, Line, Listings, Marginal, Note, Newline, Newpage, Quotes, Space,
|
||||
SpecialChar, Wrap
|
||||
|
||||
These insets do nothing for XHTML:
|
||||
ERT, OptArg, Phantom
|
||||
@ -63,9 +64,6 @@ These do not yet work and need some attention:
|
||||
about export formats, etc, to get it completely right. We'll also want to make
|
||||
some use of the params, eg, on width and height. I guess there is also some
|
||||
issue about converting the graphics formats?
|
||||
InsetInclude: I think we just want to include it, straightforwardly. Probably will
|
||||
base this more on the latex() routine, then. Another possibility, maybe with a
|
||||
flag of some sort, would be to do it as a separate file, to which we link.
|
||||
InsetRef: Presumably, this is an internal link. But what should the text be, and how
|
||||
should we get it? Probably some validation thing again, where labels tell us where
|
||||
they are. Alternatively, we could parse the aux file.
|
||||
|
@ -377,7 +377,7 @@ Buffer * InsetInclude::getChildBuffer() const
|
||||
Buffer * InsetInclude::loadIfNeeded() const
|
||||
{
|
||||
// Don't try to load it again if we failed before.
|
||||
if (failedtoload_)
|
||||
if (failedtoload_ || isVerbatim(params()) || isListings(params()))
|
||||
return 0;
|
||||
|
||||
// Use cached Buffer if possible.
|
||||
@ -388,13 +388,9 @@ Buffer * InsetInclude::loadIfNeeded() const
|
||||
child_buffer_ = 0;
|
||||
}
|
||||
|
||||
InsetCommandParams const & p = params();
|
||||
if (isVerbatim(p) || isListings(p))
|
||||
return 0;
|
||||
|
||||
string const parent_filename = buffer().absFileName();
|
||||
FileName const included_file =
|
||||
makeAbsPath(to_utf8(p["filename"]), onlyPath(parent_filename));
|
||||
makeAbsPath(to_utf8(params()["filename"]), onlyPath(parent_filename));
|
||||
|
||||
if (!isLyXFilename(included_file.absFilename()))
|
||||
return 0;
|
||||
@ -626,6 +622,57 @@ int InsetInclude::latex(odocstream & os, OutputParams const & runparams) const
|
||||
}
|
||||
|
||||
|
||||
docstring InsetInclude::xhtml(odocstream & os, 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)
|
||||
os << "<pre>\n";
|
||||
// FIXME: We don't know the encoding of the file, default to UTF-8.
|
||||
os << includedFilename(buffer(), params()).fileContents("UTF-8");
|
||||
if (listing)
|
||||
os << "</pre>\n";
|
||||
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.)
|
||||
if (!isLyXFilename(included_file.absFilename())) {
|
||||
frontend::Alert::warning(_("Unsupported Inclusion"),
|
||||
_("LyX does not know how to include non-LyX files when"
|
||||
"generating HTML output. Offending file: ") +
|
||||
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
|
||||
string const parent_filename = buffer().absFileName();
|
||||
FileName const included_file =
|
||||
makeAbsPath(to_utf8(params()["filename"]), onlyPath(parent_filename));
|
||||
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(os, rp, true);
|
||||
return docstring();
|
||||
}
|
||||
|
||||
|
||||
int InsetInclude::plaintext(odocstream & os, OutputParams const &) const
|
||||
{
|
||||
if (isVerbatim(params()) || isListings(params())) {
|
||||
|
@ -80,6 +80,8 @@ public:
|
||||
///
|
||||
int docbook(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
docstring xhtml(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
void validate(LaTeXFeatures &) const;
|
||||
///
|
||||
void addPreview(graphics::PreviewLoader &) const;
|
||||
|
Loading…
Reference in New Issue
Block a user