From d8a1720d5656d1d1563cb64232a011d37dcad049 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Thu, 18 Mar 2010 20:35:08 +0000 Subject: [PATCH] Give ourselves a little more flexibility about math output under XHTML. I think it will be worth implementing a version of pure HTML output, for some uses, a la eLyXer. Note that at present none of this does anything, and there is no UI to set it. I just want to make sure it's in the file format, in case I do not get to this before 2.0. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33794 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/FORMAT | 5 +++++ lib/lyx2lyx/lyx_2_0.py | 36 ++++++++++++++++++++++++++++++++++-- src/Buffer.cpp | 2 +- src/BufferParams.cpp | 10 ++++++---- src/BufferParams.h | 9 +++++++-- 5 files changed, 53 insertions(+), 9 deletions(-) diff --git a/development/FORMAT b/development/FORMAT index e7c3fbd6ee..8ebcf5de22 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -1,6 +1,11 @@ LyX file-format changes ----------------------- +2010-03-18: Richard Heck + * Format incremented to 379: revise format 374 + Replace boolean \html_use_mathml with \html_math_output, + which at the moment can be: MathML, HTML, or Images. + 2010-02-12 Pavel Sanda * Format incremented to 378: support for revision InsetInfo. Various "vcs-*" strings could be argument of arg parameter diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index 8ad26ef938..64250f3109 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -1205,6 +1205,36 @@ def revert_multirow(document): add_to_preamble(document, ["\\usepackage{multirow}"]) +def convert_math_output(document): + " Convert \html_use_mathml to \html_math_output " + i = find_token(document.header, "\\html_use_mathml", 0) + if i == -1: + return + rgx = re.compile(r'\\html_use_mathml\s+(\w+)') + m = rgx.match(document.header[i]) + if rgx: + newval = "MathML" + val = m.group(1) + if val != "true": + newval = "Images" + document.header[i] = "\\html_math_output " + newval + + +def revert_math_output(document): + " Revert \html_math_output to \html_use_mathml " + i = find_token(document.header, "\\html_math_output", 0) + if i == -1: + return + rgx = re.compile(r'\\html_math_output\s+(\w+)') + m = rgx.match(document.header[i]) + if rgx: + newval = "false" + val = m.group(1) + if val != "MathML": + newval = "true" + document.header[i] = "\\html_use_mathml " + newval + + ## # Conversion hub # @@ -1242,10 +1272,12 @@ convert = [[346, []], [375, []], [376, []], [377, []], - [378, []] + [378, []], + [379, [convert_math_output]] ] -revert = [[377, []], +revert = [[378, [revert_math_output]], + [377, []], [376, [revert_multirow]], [375, [revert_includeall]], [374, [revert_includeonly]], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 1da4d9912a..cdea9e6496 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -126,7 +126,7 @@ namespace { // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -int const LYX_FORMAT = 378; // ps: rev insetinfo +int const LYX_FORMAT = 379; // rgh: xhtml math output type typedef map DepClean; typedef map > RefCache; diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 9a64ec6cf5..37fba33142 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -377,7 +377,7 @@ BufferParams::BufferParams() // default index indiceslist().addDefault(B_("Index")); html_be_strict = true; - html_use_mathml = true; + html_math_output = MathML; } @@ -775,8 +775,10 @@ string BufferParams::readToken(Lexer & lex, string const & token, toktmp << endl; return toktmp; } - } else if (token == "\\html_use_mathml") { - lex >> html_use_mathml; + } else if (token == "\\html_math_output") { + int temp; + lex >> temp; + html_math_output = static_cast(temp); } else if (token == "\\html_be_strict") { lex >> html_be_strict; } else { @@ -992,7 +994,7 @@ void BufferParams::writeFile(ostream & os) const os << "\\tracking_changes " << convert(trackChanges) << "\n" << "\\output_changes " << convert(outputChanges) << "\n" - << "\\html_use_mathml " << convert(html_use_mathml) << "\n" + << "\\html_math_output " << html_math_output << "\n" << "\\html_be_strict " << convert(html_be_strict) << "\n"; os << pimpl_->authorlist; diff --git a/src/BufferParams.h b/src/BufferParams.h index 5055790ab3..cbd1d70d4a 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -375,8 +375,13 @@ public: PDFOptions & pdfoptions(); PDFOptions const & pdfoptions() const; - /// whether to use MathML for math output, or instead images - bool html_use_mathml; + enum MathOutput { + MathML, + HTML, + Images + }; + /// what to use for math output. present choices are above + MathOutput html_math_output; /// whether to attempt to be XHTML 1.1 compliant or instead be /// a little more mellow bool html_be_strict; -- 2.39.2