[LyX/master] InsetIPAMacro: refactor code between DocBook and XHTML.
Thibaut Cuvelier
tcuvelier at lyx.org
Mon Dec 26 18:25:57 UTC 2022
commit df025d15df89dac100a368eed7c86a5b754e9f7c
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date: Mon Dec 26 20:23:05 2022 +0100
InsetIPAMacro: refactor code between DocBook and XHTML.
---
src/insets/InsetIPAMacro.cpp | 67 +++++++++++++----------------------------
1 files changed, 21 insertions(+), 46 deletions(-)
diff --git a/src/insets/InsetIPAMacro.cpp b/src/insets/InsetIPAMacro.cpp
index a529d04..5aeaf84 100644
--- a/src/insets/InsetIPAMacro.cpp
+++ b/src/insets/InsetIPAMacro.cpp
@@ -553,59 +553,34 @@ int InsetIPAChar::plaintext(odocstringstream & os, OutputParams const &, size_t)
}
+namespace {
+std::string ipaCharToXMLEntity(InsetIPAChar::Kind kind) {
+ switch (kind) {
+ case InsetIPAChar::Kind::TONE_FALLING:
+ return "˥˩";
+ case InsetIPAChar::Kind::TONE_RISING:
+ return "˩˥";
+ case InsetIPAChar::Kind::TONE_HIGH_RISING:
+ return "˧˥";
+ case InsetIPAChar::Kind::TONE_LOW_RISING:
+ return "˩˧";
+ case InsetIPAChar::Kind::TONE_HIGH_RISING_FALLING:
+ return "˨˥˨";
+ }
+ return "";
+}
+}
+
+
void InsetIPAChar::docbook(XMLStream & xs, OutputParams const &) const
{
- switch (kind_) {
- case TONE_FALLING:
- xs << XMLStream::ESCAPE_NONE << "˥";
- xs << XMLStream::ESCAPE_NONE << "˩";
- break;
- case TONE_RISING:
- xs << XMLStream::ESCAPE_NONE << "˩";
- xs << XMLStream::ESCAPE_NONE << "˥";
- break;
- case TONE_HIGH_RISING:
- xs << XMLStream::ESCAPE_NONE << "˧";
- xs << XMLStream::ESCAPE_NONE << "˥";
- break;
- case TONE_LOW_RISING:
- xs << XMLStream::ESCAPE_NONE << "˩";
- xs << XMLStream::ESCAPE_NONE << "˧";
- break;
- case TONE_HIGH_RISING_FALLING:
- xs << XMLStream::ESCAPE_NONE << "˨";
- xs << XMLStream::ESCAPE_NONE << "˥";
- xs << XMLStream::ESCAPE_NONE << "˨";
- break;
- }
+ xs << XMLStream::ESCAPE_NONE << from_ascii(ipaCharToXMLEntity(kind()));
}
docstring InsetIPAChar::xhtml(XMLStream & xs, OutputParams const &) const
{
- switch (kind_) {
- case TONE_FALLING:
- xs << XMLStream::ESCAPE_NONE << "˥"
- << XMLStream::ESCAPE_NONE << "˩";
- break;
- case TONE_RISING:
- xs << XMLStream::ESCAPE_NONE << "˩"
- << XMLStream::ESCAPE_NONE << "˥";
- break;
- case TONE_HIGH_RISING:
- xs << XMLStream::ESCAPE_NONE << "˧"
- << XMLStream::ESCAPE_NONE << "˥";
- break;
- case TONE_LOW_RISING:
- xs << XMLStream::ESCAPE_NONE << "˩"
- << XMLStream::ESCAPE_NONE << "˧";
- break;
- case TONE_HIGH_RISING_FALLING:
- xs << XMLStream::ESCAPE_NONE << "˨"
- << XMLStream::ESCAPE_NONE << "˥"
- << XMLStream::ESCAPE_NONE << "˨";
- break;
- }
+ xs << XMLStream::ESCAPE_NONE << from_ascii(ipaCharToXMLEntity(kind()));
return docstring();
}
More information about the lyx-cvs
mailing list