From 1eb8311aff065f843e6d34bfa7f8e2d9757eb9ce Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Wed, 31 Mar 2010 21:33:33 +0000 Subject: [PATCH] HTML for binomials. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33995 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/InsetMathFrac.cpp | 45 ++++++++++++++++++++++++++++++++---- src/mathed/InsetMathFrac.h | 2 ++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/mathed/InsetMathFrac.cpp b/src/mathed/InsetMathFrac.cpp index 9ec6c7b086..e017b91d9a 100644 --- a/src/mathed/InsetMathFrac.cpp +++ b/src/mathed/InsetMathFrac.cpp @@ -578,12 +578,49 @@ void InsetMathBinom::mathmlize(MathStream & os) const } +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 InsetMathBinom::validate(LaTeXFeatures & features) const { - if (kind_ == BINOM) - features.require("binom"); - if (kind_ == DBINOM || kind_ == TBINOM) - features.require("amsmath"); + if (features.runparams().isLaTeX()) { + if (kind_ == BINOM) + features.require("binom"); + if (kind_ == DBINOM || kind_ == TBINOM) + features.require("amsmath"); + } else if (features.runparams().math_flavor == OutputParams::MathAsHTML) + features.addPreambleSnippet(""); InsetMathNest::validate(features); } diff --git a/src/mathed/InsetMathFrac.h b/src/mathed/InsetMathFrac.h index 3de485f2db..5030730647 100644 --- a/src/mathed/InsetMathFrac.h +++ b/src/mathed/InsetMathFrac.h @@ -125,6 +125,8 @@ public: /// void mathmlize(MathStream &) const; /// + void htmlize(HtmlStream &) const; + /// void validate(LaTeXFeatures & features) const; /// InsetCode lyxCode() const { return MATH_FRAC_CODE; } -- 2.39.2