mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +00:00
Matrix output via HTML. I have to say, this one took some work.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33978 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
db1d81f03a
commit
edff97cb30
@ -634,26 +634,37 @@ bool InsetMathHull::numberedType() const
|
|||||||
|
|
||||||
void InsetMathHull::validate(LaTeXFeatures & features) const
|
void InsetMathHull::validate(LaTeXFeatures & features) const
|
||||||
{
|
{
|
||||||
if (ams())
|
if (features.runparams().isLaTeX()) {
|
||||||
features.require("amsmath");
|
if (ams())
|
||||||
|
features.require("amsmath");
|
||||||
if (type_ == hullRegexp) {
|
|
||||||
features.require("color");
|
if (type_ == hullRegexp) {
|
||||||
string frcol = lcolor.getLaTeXName(Color_regexpframe);
|
features.require("color");
|
||||||
string bgcol = "white";
|
string frcol = lcolor.getLaTeXName(Color_regexpframe);
|
||||||
features.addPreambleSnippet(
|
string bgcol = "white";
|
||||||
string("\\newcommand{\\regexp}[1]{\\fcolorbox{")
|
features.addPreambleSnippet(
|
||||||
+ frcol + string("}{")
|
string("\\newcommand{\\regexp}[1]{\\fcolorbox{")
|
||||||
+ bgcol + string("}{\\texttt{#1}}}"));
|
+ frcol + string("}{")
|
||||||
|
+ bgcol + string("}{\\texttt{#1}}}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validation is necessary only if not using AMS math.
|
||||||
|
// To be safe, we will always run mathedvalidate.
|
||||||
|
//if (features.amsstyle)
|
||||||
|
// return;
|
||||||
|
|
||||||
|
//features.binom = true;
|
||||||
|
} else if (features.runparams().math_flavor == OutputParams::MathAsHTML) {
|
||||||
|
// it would be better to do this elsewhere, but we can't validate in
|
||||||
|
// InsetMathMatrix and we have no way, outside MathExtern, to know if
|
||||||
|
// we even have any matrices.
|
||||||
|
features.addPreambleSnippet("<style type=\"text/css\">\n"
|
||||||
|
"table.matrix{display: inline-block; vertical-align: middle; text-align:center;}\n"
|
||||||
|
"table.matrix td{padding: 0.25px;}\n"
|
||||||
|
"td.ldelim{width: 0.5ex; border: thin solid black; border-right: none;}\n"
|
||||||
|
"td.rdelim{width: 0.5ex; border: thin solid black; border-left: none;}\n"
|
||||||
|
"</style>");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validation is necessary only if not using AMS math.
|
|
||||||
// To be safe, we will always run mathedvalidate.
|
|
||||||
//if (features.amsstyle)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
//features.binom = true;
|
|
||||||
|
|
||||||
InsetMathGrid::validate(features);
|
InsetMathGrid::validate(features);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,9 @@
|
|||||||
#include "MathData.h"
|
#include "MathData.h"
|
||||||
#include "MathStream.h"
|
#include "MathStream.h"
|
||||||
|
|
||||||
|
#include "support/convert.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
@ -106,6 +109,31 @@ void InsetMathMatrix::mathmlize(MathStream & os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
os << MTag("td") << cell(index(row, col)) << ETag("td") << '\n';
|
||||||
|
if (row == 0)
|
||||||
|
os << MTag("td", rattrib) << ETag("td") << '\n';
|
||||||
|
os << ETag("tr") << '\n';
|
||||||
|
}
|
||||||
|
os << ETag("table") << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetMathMatrix::octave(OctaveStream & os) const
|
void InsetMathMatrix::octave(OctaveStream & os) const
|
||||||
{
|
{
|
||||||
os << '[';
|
os << '[';
|
||||||
|
Loading…
Reference in New Issue
Block a user