mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
InsetIPAMacro: implement the XHTML conversion, refactor plaintext and DocBook to share more code.
This commit is contained in:
parent
f1bb623fb2
commit
b2fdc04f96
@ -283,14 +283,27 @@ void InsetIPADeco::latex(otexstream & os, OutputParams const & runparams) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int InsetIPADeco::plaintext(odocstringstream & os,
|
namespace {
|
||||||
OutputParams const & runparams, size_t max_length) const
|
std::pair<docstring, docstring> splitPlainTextInHalves(
|
||||||
|
const InsetIPADeco * inset, OutputParams const & runparams,
|
||||||
|
size_t max_length = INT_MAX)
|
||||||
{
|
{
|
||||||
odocstringstream ods;
|
odocstringstream ods;
|
||||||
int h = InsetCollapsible::plaintext(ods, runparams, max_length) / 2;
|
int h = inset->InsetCollapsible::plaintext(ods, runparams, max_length) / 2;
|
||||||
docstring result = ods.str();
|
docstring result = ods.str();
|
||||||
docstring const before = result.substr(0, h);
|
docstring const before = result.substr(0, h);
|
||||||
docstring const after = result.substr(h, result.size());
|
docstring const after = result.substr(h, result.size());
|
||||||
|
return {before, after};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int InsetIPADeco::plaintext(odocstringstream & os,
|
||||||
|
OutputParams const & runparams, size_t max_length) const
|
||||||
|
{
|
||||||
|
docstring before;
|
||||||
|
docstring after;
|
||||||
|
tie(before, after) = splitPlainTextInHalves(this, runparams, max_length);
|
||||||
|
|
||||||
if (params_.type == InsetIPADecoParams::Toptiebar) {
|
if (params_.type == InsetIPADecoParams::Toptiebar) {
|
||||||
os << before;
|
os << before;
|
||||||
@ -302,7 +315,7 @@ int InsetIPADeco::plaintext(odocstringstream & os,
|
|||||||
os.put(0x035c);
|
os.put(0x035c);
|
||||||
os << after;
|
os << after;
|
||||||
}
|
}
|
||||||
return result.size();
|
return before.size() + after.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -310,11 +323,9 @@ void InsetIPADeco::docbook(XMLStream & xs, OutputParams const & runparams) const
|
|||||||
{
|
{
|
||||||
// The special combining character must be put in the middle, between the two other characters.
|
// The special combining character must be put in the middle, between the two other characters.
|
||||||
// It will not work if there is anything else than two pure characters, so going back to plaintext.
|
// It will not work if there is anything else than two pure characters, so going back to plaintext.
|
||||||
odocstringstream ods;
|
docstring before;
|
||||||
int h = InsetText::plaintext(ods, runparams) / 2;
|
docstring after;
|
||||||
docstring result = ods.str();
|
tie(before, after) = splitPlainTextInHalves(this, runparams);
|
||||||
docstring const before = result.substr(0, h);
|
|
||||||
docstring const after = result.substr(h, result.size());
|
|
||||||
|
|
||||||
xs << XMLStream::ESCAPE_NONE << before;
|
xs << XMLStream::ESCAPE_NONE << before;
|
||||||
if (params_.type == InsetIPADecoParams::Toptiebar)
|
if (params_.type == InsetIPADecoParams::Toptiebar)
|
||||||
@ -327,10 +338,10 @@ void InsetIPADeco::docbook(XMLStream & xs, OutputParams const & runparams) const
|
|||||||
|
|
||||||
docstring InsetIPADeco::xhtml(XMLStream & xs, OutputParams const & runparams) const
|
docstring InsetIPADeco::xhtml(XMLStream & xs, OutputParams const & runparams) const
|
||||||
{
|
{
|
||||||
// FIXME: Like in plaintext, the combining characters "͡" (toptiebar)
|
// The DocBook encoding for this inset has no DocBook tag, but sheer XML (relying on a plaintext
|
||||||
// or "͜" (bottomtiebar) would need to be inserted just in the mid
|
// transformation of the inset).
|
||||||
// of the text string. (How) can this be done with the xhtml stream?
|
docbook(xs, runparams);
|
||||||
return InsetCollapsible::xhtml(xs, runparams);
|
return docstring();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user