}
+string const Length::asHTMLString() const
+{
+ ostringstream os;
+ switch (unit_) {
+ case PT:
+ case BP:
+ case DD:
+ // close enough
+ os << val_ << "pt";
+ break;
+ case MM:
+ case CM:
+ case PC:
+ case IN:
+ case EX:
+ case EM:
+ os << val_ << unit_name[unit_];
+ break;
+ case CC:
+ os << val_/12.0 << "pt";
+ break;
+ case MU:
+ os << val_/18.0 << "em";
+ break;
+ case PTW:
+ case PPW:
+ case PLW:
+ case PCW:
+ case PTH:
+ case PPH:
+ // what it's a percentage of probably won't make sense for HTML,
+ // so we'll assume people have chosen these appropriately
+ os << val_ << '%';
+ break;
+ case SP:
+ case UNIT_NONE:
+ break;
+ }
+ return os.str();
+}
+
+
double Length::value() const
{
return val_;
docstring const asDocstring() const;
/// return string representation for LaTeX
std::string const asLatexString() const;
+ /// return string representation for HTML
+ std::string const asHTMLString() const;
/// return the on-screen size of this length
int inPixels(int text_width, int em_width = 0) const;
/// return the value in Big Postscript points.
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");
- int ret = InsetText::xhtml(os, runparams);
+ string style;
+ if (!params_.width.empty())
+ style += ("width: " + params_.width.asHTMLString() + ";");
+ if (!params_.height.empty())
+ style += ("height: " + params_.height.asHTMLString() + ";");
+
+ os << from_ascii("<span class='" + params_.type + "'");
+ if (!style.empty())
+ os << from_ascii(" style='" + style + "'");
+ os << ">\n";
+ InsetText::xhtml(os, runparams);
os << "</span>\n";
- return ret;
+ return 0;
}