Пример #1
0
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';
}
Пример #2
0
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");
}
Пример #3
0
void InsetMathFrac::mathmlize(MathStream & os) const
{
	os << MTag("mfrac")
	   << MTag("mrow") << cell(0) << ETag("mrow")
		 << MTag("mrow") << cell(1) << ETag("mrow")
		 << ETag("mfrac");
}
Пример #4
0
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");
}
Пример #5
0
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';
}
Пример #6
0
void InsetMathSqrt::htmlize(HtmlStream & os) const
{
	os << MTag("span", "class='sqrt'")
	   << from_ascii("&radic;") 
	   << MTag("span", "class='sqrtof'")	<< cell(0) << ETag("span") 
		 << ETag("span");
}
Пример #7
0
void InsetMathXArrow::htmlize(HtmlStream & os) const
{
	char const * const arrow = name_ == "xleftarrow" 
			? "&larr;" : "&rarr;";
	os << MTag("span", "class='xarrow'")
		 << MTag("span", "class='xatop'") << cell(0) << ETag("span")
		 << MTag("span", "class='xabottom'") << arrow << ETag("span")
		 << ETag("span");
}
Пример #8
0
void InsetMathChar::htmlize(HtmlStream & ms) const
{
	std::string entity;
	switch (char_) {
		case '<': entity = "&lt;"; break;
		case '>': entity = "&gt;"; break;
		case '&': entity = "&amp;"; break;
		case ' ': entity = "&nbsp;"; 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_) << " ";
}
Пример #9
0
void InsetMathEnsureMath::mathmlize(MathStream & os) const
{
	SetMode mathmode(os, false);
	os << MTag("mstyle", "class='math'")
	   << cell(0)
	   << ETag("mstyle");
}
Пример #10
0
void InsetMathEnsureMath::htmlize(HtmlStream & os) const
{
	SetHTMLMode mathmode(os, false);
	os << MTag("span", "class='math'")
	   << cell(0)
	   << ETag("span");
}
Пример #11
0
void InsetMathXArrow::htmlize(HtmlStream & os) const
{
	char const * arrow;

	if (name_ == "xleftarrow")
		arrow = "&larr;";
	else if (name_ == "xrightarrow")
		arrow = "&rarr;";
	else if (name_ == "xhookleftarrow")
		arrow = "&larrhk;";
	else if (name_ == "xhookrightarrow")
		arrow = "&rarrhk;";
	else if (name_ == "xLeftarrow")
		arrow = "&lArr;";
	else if (name_ == "xRightarrow")
		arrow = "&rArr;";
	else if (name_ == "xleftrightarrow")
		arrow = "&leftrightarrow;";
	else if (name_ == "xLeftrightarrow")
		arrow = "&Leftrightarrow;";
	else if (name_ == "xleftharpoondown")
		arrow = "&leftharpoondown;";
	else if (name_ == "xleftharpoonup")
		arrow = "&leftharpoonup;";
	else if (name_ == "xleftrightharpoons")
		arrow = "&leftrightharpoons;";
	else if (name_ == "xrightharpoondown")
		arrow = "&rightharpoondown;";
	else if (name_ == "xrightharpoonup")
		arrow = "&rightharpoonup;";
	else if (name_ == "xrightleftharpoons")
		arrow = "&rightleftharpoons;";
	else if (name_ == "xmapsto")
		arrow = "&mapsto;";
	else {
		lyxerr << "htmlize conversion for '" << name_ << "' not implemented" << endl;
		LASSERT(false, arrow = "&rarr;");
	}
	os << MTag("span", "class='xarrow'")
		 << MTag("span", "class='xatop'") << cell(0) << ETag("span")
		 << MTag("span", "class='xabottom'") << arrow << ETag("span")
		 << ETag("span");
}
Пример #12
0
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 << "&par;";
	else if (delim_ == "\\\\" || delim_ == "\\backslash")
		os <<" \\";
	else if (delim_ == "\\langle")
		os << "&lt;";
	else if (delim_ == "\\rangle")
		os << "&gt;";
	else if (delim_ == "\\lceil")
		os << "&lceil;";
	else if (delim_ == "\\rceil")
		os << "&rceil;";
	else if (delim_ == "\\lfloor")
		os << "&lfloor;";
	else if (delim_ == "\\rfloor")
		os << "&rfloor;";
	else if (delim_ == "\\downarrow")
		os << "&darr;";
	else if (delim_ == "\\uparrow")
		os << "&uarr;";
	else if (delim_ == "\\Downarrow")
		os << "&dArr;";
	else if (delim_ == "\\Uparrow")
		os << "&uArr;";
	else if (delim_ == "\\updownarrow")
		os << "&varr;";
	else if (delim_ == "\\Updownarrow")
		os << "&vArr;";
	os << ETag("span");
}
Пример #13
0
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>";
}
Пример #14
0
// 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");
}
Пример #15
0
void InsetMathBrace::mathmlize(MathStream & os) const
{
	os << MTag("mrow") << cell(0) << ETag("mrow");
}
Пример #16
0
void InsetMathComment::mathmlize(MathStream & os) const
{
	os << MTag("comment") << cell(0) << ETag("comment");
}
Пример #17
0
void InsetMathSize::htmlize(HtmlStream & os) const
{
	string const & name = to_utf8(key_->name);
	os <<	MTag("span", "class='" + name + "'")
			<< cell(0) << ETag("span");
}
Пример #18
0
void InsetMathSqrt::mathmlize(MathStream & os) const
{
	os << MTag("msqrt") << cell(0) << ETag("msqrt");
}