void InsetMathBinom::htmlize(HtmlStream & os) const { char ldelim = ' '; char rdelim = ' '; switch (kind_) { case BINOM: case TBINOM: case DBINOM: case CHOOSE: ldelim = '('; rdelim = ')'; break; case BRACE: ldelim = '{'; rdelim = '}'; break; case BRACK: ldelim = '['; rdelim = ']'; break; } os << MTag("span", "class='binomdelim'") << ldelim << ETag("span") << '\n' << MTag("span", "class='binom'") << '\n' << MTag("span") << cell(0) << ETag("span") << '\n' << MTag("span") << cell(1) << ETag("span") << '\n' << ETag("span") << '\n' << MTag("span", "class='binomdelim'") << rdelim << ETag("span") << '\n'; }
void InsetMathUnderset::htmlize(HtmlStream & os) const { os << MTag("span", "class='underset'") << MTag("span") << cell(0) << ETag("span") << MTag("span", "class='bottom'") << cell(1) << ETag("span") << ETag("span"); }
void InsetMathFrac::mathmlize(MathStream & os) const { os << MTag("mfrac") << MTag("mrow") << cell(0) << ETag("mrow") << MTag("mrow") << cell(1) << ETag("mrow") << ETag("mfrac"); }
void InsetMathFrac::htmlize(HtmlStream & os) const { os << MTag("span", "class='frac'") << MTag("span", "class='numer'") << cell(0) << ETag("span") << MTag("span", "class='denom'") << cell(1) << ETag("span") << ETag("span"); }
void InsetMathMatrix::htmlize(HtmlStream & os) const { os << MTag("table", "class='matrix'") << '\n'; // we do not print the delimiters but instead try to hack them string const rows = convert<string>(nrows()); string const lattrib = "class='ldelim' rowspan='" + rows + "'"; string const rattrib = "class='rdelim' rowspan='" + rows + "'"; for (row_type row = 0; row < nrows(); ++row) { os << MTag("tr") << '\n'; if (row == 0) os << MTag("td", lattrib) << ETag("td") << '\n'; for (col_type col = 0; col < ncols(); ++col) { idx_type const i = index(row, col); if (cellinfo_[i].multi_ != CELL_PART_OF_MULTICOLUMN) { col_type const cellcols = ncellcols(i); ostringstream attr; if (cellcols > 1) attr << "colspan='" << cellcols << '\''; os << MTag("td", attr.str()) << cell(i) << ETag("td") << '\n'; } } if (row == 0) os << MTag("td", rattrib) << ETag("td") << '\n'; os << ETag("tr") << '\n'; } os << ETag("table") << '\n'; }
void InsetMathSqrt::htmlize(HtmlStream & os) const { os << MTag("span", "class='sqrt'") << from_ascii("√") << MTag("span", "class='sqrtof'") << cell(0) << ETag("span") << ETag("span"); }
void InsetMathXArrow::htmlize(HtmlStream & os) const { char const * const arrow = name_ == "xleftarrow" ? "←" : "→"; os << MTag("span", "class='xarrow'") << MTag("span", "class='xatop'") << cell(0) << ETag("span") << MTag("span", "class='xabottom'") << arrow << ETag("span") << ETag("span"); }
void InsetMathChar::htmlize(HtmlStream & ms) const { std::string entity; switch (char_) { case '<': entity = "<"; break; case '>': entity = ">"; break; case '&': entity = "&"; break; case ' ': entity = " "; break; default: break; } bool have_entity = !entity.empty(); if (ms.inText()) { if (have_entity) ms << from_ascii(entity); else ms.os().put(char_); return; } if (have_entity) { // an operator, so give some space ms << ' ' << from_ascii(entity) << ' '; return; } if (isalpha(char_) || Encodings::isMathAlpha(char_)) // we don't use MTag and ETag because we do not want the spacing ms << MTag("i") << char_type(char_) << ETag("i"); else // an operator, so give some space ms << " " << char_type(char_) << " "; }
void InsetMathEnsureMath::mathmlize(MathStream & os) const { SetMode mathmode(os, false); os << MTag("mstyle", "class='math'") << cell(0) << ETag("mstyle"); }
void InsetMathEnsureMath::htmlize(HtmlStream & os) const { SetHTMLMode mathmode(os, false); os << MTag("span", "class='math'") << cell(0) << ETag("span"); }
void InsetMathXArrow::htmlize(HtmlStream & os) const { char const * arrow; if (name_ == "xleftarrow") arrow = "←"; else if (name_ == "xrightarrow") arrow = "→"; else if (name_ == "xhookleftarrow") arrow = "↩"; else if (name_ == "xhookrightarrow") arrow = "↪"; else if (name_ == "xLeftarrow") arrow = "⇐"; else if (name_ == "xRightarrow") arrow = "⇒"; else if (name_ == "xleftrightarrow") arrow = "↔"; else if (name_ == "xLeftrightarrow") arrow = "⇔"; else if (name_ == "xleftharpoondown") arrow = "↽"; else if (name_ == "xleftharpoonup") arrow = "↼"; else if (name_ == "xleftrightharpoons") arrow = "⇋"; else if (name_ == "xrightharpoondown") arrow = "⇁"; else if (name_ == "xrightharpoonup") arrow = "⇀"; else if (name_ == "xrightleftharpoons") arrow = "⇌"; else if (name_ == "xmapsto") arrow = "↦"; else { lyxerr << "htmlize conversion for '" << name_ << "' not implemented" << endl; LASSERT(false, arrow = "→"); } os << MTag("span", "class='xarrow'") << MTag("span", "class='xatop'") << cell(0) << ETag("span") << MTag("span", "class='xabottom'") << arrow << ETag("span") << ETag("span"); }
void InsetMathBig::htmlize(HtmlStream & os) const { std::string name; switch (size()) { case 0: case 1: name = "big"; break; case 2: case 3: name = "bigg"; break; case 4: case 5: name = "biggg"; break; default: name = "big"; break; } os << MTag("span", "class='" + name + "symbol'"); if (delim_ == "(" || delim_ == ")" || delim_ == "[" || delim_ == "]" || delim_ == "|" || delim_ == "/") os << delim_; else if (delim_ == "\\{" || delim_ == "\\lbrace") os << "{"; else if (delim_ == "\\}" || delim_ == "\\rbrace") os << "}"; else if (delim_ == "\\slash") os << "/"; else if (delim_ == "\\|" || delim_ == "\\vert") os << "|"; else if (delim_ == "\\Vert") os << "∥"; else if (delim_ == "\\\\" || delim_ == "\\backslash") os <<" \\"; else if (delim_ == "\\langle") os << "<"; else if (delim_ == "\\rangle") os << ">"; else if (delim_ == "\\lceil") os << "⌈"; else if (delim_ == "\\rceil") os << "⌉"; else if (delim_ == "\\lfloor") os << "⌊"; else if (delim_ == "\\rfloor") os << "⌋"; else if (delim_ == "\\downarrow") os << "↓"; else if (delim_ == "\\uparrow") os << "↑"; else if (delim_ == "\\Downarrow") os << "⇓"; else if (delim_ == "\\Uparrow") os << "⇑"; else if (delim_ == "\\updownarrow") os << "↕"; else if (delim_ == "\\Updownarrow") os << "⇕"; os << ETag("span"); }
void InsetMathMatrix::mathmlize(MathStream & os) const { os << "<mo form='prefix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>" << left_ << "</mo>"; os << MTag("mtable"); for (row_type row = 0; row < nrows(); ++row) { os << MTag("mtr"); for (col_type col = 0; col < ncols(); ++col) { idx_type const i = index(row, col); if (cellinfo_[i].multi_ != CELL_PART_OF_MULTICOLUMN) { col_type const cellcols = ncellcols(i); ostringstream attr; if (cellcols > 1) attr << "columnspan='" << cellcols << '\''; os << MTag("mtd", attr.str()) << cell(i) << ETag("mtd"); } } os << ETag("mtr"); } os << ETag("mtable"); os << "<mo form='postfix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>" << right_ << "</mo>"; }
// From the MathML documentation: // MathML uses two attributes, displaystyle and scriptlevel, to control // orthogonal presentation features that TeX encodes into one "style" // attribute with values \displaystyle, \textstyle, \scriptstyle, and // \scriptscriptstyle. The corresponding values of displaystyle and scriptlevel // for those TeX styles would be "true" and "0", "false" and "0", "false" and "1", // and "false" and "2", respectively. void InsetMathSize::mathmlize(MathStream & ms) const { string const & name = to_utf8(key_->name); bool dispstyle = (name == "displaystyle"); int scriptlevel = 0; if (name == "scriptstyle") scriptlevel = 1; else if (name == "scriptscriptstyle") scriptlevel = 2; stringstream attrs; attrs << "displaystyle='" << (dispstyle ? "true" : "false") << "' scriptlevel='" << scriptlevel << "'"; ms << MTag("mstyle", attrs.str()) << ">" << cell(0) << ETag("mstyle"); }
void InsetMathBrace::mathmlize(MathStream & os) const { os << MTag("mrow") << cell(0) << ETag("mrow"); }
void InsetMathComment::mathmlize(MathStream & os) const { os << MTag("comment") << cell(0) << ETag("comment"); }
void InsetMathSize::htmlize(HtmlStream & os) const { string const & name = to_utf8(key_->name); os << MTag("span", "class='" + name + "'") << cell(0) << ETag("span"); }
void InsetMathSqrt::mathmlize(MathStream & os) const { os << MTag("msqrt") << cell(0) << ETag("msqrt"); }