HTML output code for a handful of easy insets.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29951 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2009-06-05 17:48:14 +00:00
parent 92a69bb790
commit f61bebd7fb
22 changed files with 175 additions and 10 deletions

View File

@ -484,6 +484,16 @@ int InsetBox::docbook(odocstream & os, OutputParams const & runparams) const
}
int InsetBox::xhtml(odocstream & os, OutputParams const & runparams) const
{
// FIXME We also want to do something with the length info, etc,
// presumably as "style='...'".
os << from_ascii("<span class='" + params_.type + "'>\n");
InsetText::xhtml(os, runparams);
os << "</span>\n";
}
void InsetBox::validate(LaTeXFeatures & features) const
{
BoxType btype = boxtranslator().find(params_.type);

View File

@ -119,6 +119,8 @@ private:
///
int docbook(odocstream &, OutputParams const &) const;
///
int xhtml(odocstream &, OutputParams const &) const;
///
void validate(LaTeXFeatures &) const;
///
InsetBoxParams const & params() const { return params_; }

View File

@ -235,6 +235,13 @@ int InsetBranch::docbook(odocstream & os,
}
int InsetBranch::xhtml(odocstream & os,
OutputParams const & runparams) const
{
return isBranchSelected() ? InsetText::xhtml(os, runparams) : 0;
}
void InsetBranch::tocString(odocstream & os) const
{
if (isBranchSelected())

View File

@ -74,6 +74,8 @@ private:
///
int docbook(odocstream &, OutputParams const &) const;
///
int xhtml(odocstream &, OutputParams const &) const;
///
void tocString(odocstream &) const;
///
void validate(LaTeXFeatures &) const;

View File

@ -181,6 +181,18 @@ int InsetHyperlink::docbook(odocstream & os, OutputParams const &) const
}
int InsetHyperlink::xhtml(odocstream & os, OutputParams const &) const
{
os << "<a href=\""
// FIXME Do we need to do more escaping than this?
<< subst(getParam("target"), from_ascii("&"), from_ascii("&amp;"))
<< "\">"
<< getParam("name")
<< "</a>";
return 0;
}
void InsetHyperlink::tocString(odocstream & os) const
{
plaintext(os, OutputParams(0));

View File

@ -40,6 +40,8 @@ public:
int plaintext(odocstream &, OutputParams const &) const;
///
int docbook(odocstream &, OutputParams const &) const;
///
int xhtml(odocstream &, OutputParams const &) const;
/// the string that is passed to the TOC
void tocString(odocstream &) const;
///

View File

@ -218,4 +218,11 @@ int InsetLabel::docbook(odocstream & os, OutputParams const & runparams) const
}
int InsetLabel::xhtml(odocstream & os, OutputParams const & runparams) const
{
// FIXME Does this need to be escaped?
os << "<a name=\"" << getParam("name") << "\"></a>";
return 0;
}
} // namespace lyx

View File

@ -44,6 +44,8 @@ public:
///
int docbook(odocstream &, OutputParams const &) const;
///
int xhtml(odocstream &, OutputParams const &) const;
///
static ParamInfo const & findInfo(std::string const &);
///
static std::string defaultCommand() { return "label"; };

View File

@ -85,6 +85,13 @@ int InsetLine::docbook(odocstream & os, OutputParams const &) const
}
int InsetLine::xhtml(odocstream & os, OutputParams const &) const
{
os << "<hr />\n";
return 0;
}
void InsetLine::validate(LaTeXFeatures & features) const
{
features.require("lyxline");

View File

@ -20,27 +20,29 @@ namespace lyx {
class InsetLine : public Inset {
public:
///
InsetLine() {}
///
InsetCode lyxCode() const { return LINE_CODE; }
///
void metrics(MetricsInfo &, Dimension &) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///
int latex(odocstream &, OutputParams const &) const;
///
int plaintext(odocstream &, OutputParams const &) const;
///
int docbook(odocstream &, OutputParams const &) const;
///
int xhtml(odocstream &, OutputParams const &) const;
///
void read(Lexer & lex);
///
void write(std::ostream & os) const;
/// We don't need \begin_inset and \end_inset
bool directWrite() const { return true; }
///
DisplayType display() const { return AlignCenter; }
///
void validate(LaTeXFeatures & features) const;

View File

@ -173,6 +173,13 @@ int InsetNewline::docbook(odocstream & os, OutputParams const &) const
}
int InsetNewline::xhtml(odocstream & os, OutputParams const &) const
{
os << "<br />\n";
return 0;
}
void InsetNewline::draw(PainterInfo & pi, int x, int y) const
{
FontInfo font;

View File

@ -65,6 +65,8 @@ private:
///
int docbook(odocstream &, OutputParams const &) const;
///
int xhtml(odocstream &, OutputParams const &) const;
///
void read(Lexer & lex);
///
void write(std::ostream & os) const;

View File

@ -247,6 +247,13 @@ int InsetNewpage::docbook(odocstream & os, OutputParams const &) const
}
int InsetNewpage::xhtml(odocstream & os, OutputParams const &) const
{
os << "<br />\n";
return 0;
}
docstring InsetNewpage::contextMenu(BufferView const &, int, int) const
{
return from_ascii("context-newpage");

View File

@ -69,6 +69,8 @@ private:
///
int docbook(odocstream &, OutputParams const &) const;
///
int xhtml(odocstream &, OutputParams const &) const;
///
void read(Lexer & lex);
///
void write(std::ostream & os) const;

View File

@ -312,6 +312,12 @@ int InsetQuotes::docbook(odocstream & os, OutputParams const &) const
}
int InsetQuotes::xhtml(odocstream & os, OutputParams const & op) const
{
return docbook(os, op);
}
void InsetQuotes::tocString(odocstream & os) const
{
os << displayString();

View File

@ -83,6 +83,8 @@ public:
int plaintext(odocstream &, OutputParams const &) const;
///
int docbook(odocstream &, OutputParams const &) const;
///
int xhtml(odocstream &, OutputParams const &) const;
/// the string that is passed to the TOC
void tocString(odocstream &) const;

View File

@ -680,6 +680,52 @@ int InsetSpace::docbook(odocstream & os, OutputParams const &) const
}
int InsetSpace::xhtml(odocstream & os, OutputParams const &) const
{
switch (params_.kind) {
case InsetSpaceParams::NORMAL:
os << " ";
break;
case InsetSpaceParams::ENSKIP:
case InsetSpaceParams::ENSPACE:
os << "&ensp;";
break;
case InsetSpaceParams::QQUAD:
os << "&emsp;";
case InsetSpaceParams::THICK:
case InsetSpaceParams::QUAD:
os << "&emsp;";
break;
case InsetSpaceParams::THIN:
os << "&thinsp;";
break;
case InsetSpaceParams::PROTECTED:
case InsetSpaceParams::MEDIUM:
case InsetSpaceParams::NEGTHIN:
case InsetSpaceParams::NEGMEDIUM:
case InsetSpaceParams::NEGTHICK:
os << "&nbsp;";
break;
case InsetSpaceParams::HFILL:
case InsetSpaceParams::HFILL_PROTECTED:
case InsetSpaceParams::DOTFILL:
case InsetSpaceParams::HRULEFILL:
case InsetSpaceParams::LEFTARROWFILL:
case InsetSpaceParams::RIGHTARROWFILL:
case InsetSpaceParams::UPBRACEFILL:
case InsetSpaceParams::DOWNBRACEFILL:
// FIXME Can we do anything with those in HTML?
os << '\n';
break;
case InsetSpaceParams::CUSTOM:
case InsetSpaceParams::CUSTOM_PROTECTED:
// FIXME Probably we could do some sort of blank span?
os << '\n';
}
return 0;
}
void InsetSpace::validate(LaTeXFeatures & features) const
{
if (params_.kind == InsetSpaceParams::NEGMEDIUM ||

View File

@ -129,6 +129,8 @@ public:
///
int docbook(odocstream &, OutputParams const &) const;
///
int xhtml(odocstream &, OutputParams const &) const;
///
void validate(LaTeXFeatures & features) const;
/// the string that is passed to the TOC
void tocString(odocstream &) const;

View File

@ -291,6 +291,32 @@ int InsetSpecialChar::docbook(odocstream & os, OutputParams const &) const
}
int InsetSpecialChar::xhtml(odocstream & os, OutputParams const &) const
{
switch (kind_) {
case HYPHENATION:
case LIGATURE_BREAK:
break;
case END_OF_SENTENCE:
os << '.';
break;
case LDOTS:
os << "&hellip;";
break;
case MENU_SEPARATOR:
os << "&rArr;";
break;
case SLASH:
os << "&frasl;";
break;
case NOBREAKDASH:
os << '-';
break;
}
return 0;
}
void InsetSpecialChar::tocString(odocstream & os) const
{
plaintext(os, OutputParams(0));

View File

@ -64,6 +64,8 @@ public:
int plaintext(odocstream &, OutputParams const &) const;
///
int docbook(odocstream &, OutputParams const &) const;
///
int xhtml(odocstream &, OutputParams const &) const;
/// the string that is passed to the TOC
void tocString(odocstream &) const;
///

View File

@ -34,6 +34,7 @@
#include "MetricsInfo.h"
#include "output_docbook.h"
#include "output_latex.h"
#include "output_xhtml.h"
#include "OutputParams.h"
#include "output_plaintext.h"
#include "paragraph_funcs.h"
@ -367,6 +368,13 @@ int InsetText::docbook(odocstream & os, OutputParams const & runparams) const
}
int InsetText::xhtml(odocstream & os, OutputParams const & runparams) const
{
xhtmlParagraphs(paragraphs(), buffer(), os, runparams);
return 0;
}
void InsetText::validate(LaTeXFeatures & features) const
{
for_each(paragraphs().begin(), paragraphs().end(),

View File

@ -81,6 +81,8 @@ public:
///
int docbook(odocstream &, OutputParams const &) const;
///
int xhtml(odocstream &, OutputParams const &) const;
///
void validate(LaTeXFeatures & features) const;
/// return x,y of given position relative to the inset's baseline