mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
Export ' (straight) as ’ (curly) in DocBook
This is similar to what LaTeX does in its output.
See the (long) discussion in ticket #11244. Port of ad3e6c69b2
for DocBook.
This patch requires delaying entire strings instead of just characters, so that the DocBook code path can be as similar to the XHTML one as possible.
This commit is contained in:
parent
126f516efc
commit
d4095dc0e6
@ -3552,7 +3552,7 @@ std::tuple<std::vector<docstring>, std::vector<docstring>, std::vector<docstring
|
|||||||
// State variables for the main loop.
|
// State variables for the main loop.
|
||||||
auto xs = new XMLStream(os); // XMLStream has no copy constructor: to create a new object, the only solution
|
auto xs = new XMLStream(os); // XMLStream has no copy constructor: to create a new object, the only solution
|
||||||
// is to hold a pointer to the XMLStream (xs = XMLStream(os) is not allowed once the first object is built).
|
// is to hold a pointer to the XMLStream (xs = XMLStream(os) is not allowed once the first object is built).
|
||||||
std::vector<char_type> delayedChars; // When a font tag ends with a space, output it after the closing font tag.
|
std::vector<docstring> delayedChars; // When a font tag ends with a space, output it after the closing font tag.
|
||||||
// This requires to store delayed characters at some point.
|
// This requires to store delayed characters at some point.
|
||||||
|
|
||||||
DocBookFontState fs; // Track whether we have opened font tags
|
DocBookFontState fs; // Track whether we have opened font tags
|
||||||
@ -3610,8 +3610,8 @@ std::tuple<std::vector<docstring>, std::vector<docstring>, std::vector<docstring
|
|||||||
|
|
||||||
// Deal with the delayed characters *after* closing font tags.
|
// Deal with the delayed characters *after* closing font tags.
|
||||||
if (!delayedChars.empty()) {
|
if (!delayedChars.empty()) {
|
||||||
for (char_type c: delayedChars)
|
for (const docstring& c: delayedChars)
|
||||||
*xs << c;
|
*xs << XMLStream::ESCAPE_NONE << c;
|
||||||
delayedChars.clear();
|
delayedChars.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3642,10 +3642,18 @@ std::tuple<std::vector<docstring>, std::vector<docstring>, std::vector<docstring
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
char_type c = getUChar(buf.masterBuffer()->params(), rp, i);
|
char_type c = getUChar(buf.masterBuffer()->params(), rp, i);
|
||||||
if (lyx::isSpace(c) && !ignore_fonts)
|
if (lyx::isSpace(c) && !ignore_fonts) { // Delay spaces *after* the font-tag closure for cleaner output.
|
||||||
delayedChars.push_back(c);
|
if (c == ' ' && (style.free_spacing || rp.free_spacing)) {
|
||||||
else
|
delayedChars.push_back(from_ascii(" "));
|
||||||
*xs << c;
|
} else {
|
||||||
|
delayedChars.emplace_back(1, c);
|
||||||
|
}
|
||||||
|
} else { // No need to delay the character.
|
||||||
|
if (c == '\'')
|
||||||
|
*xs << XMLStream::ESCAPE_NONE << "’";
|
||||||
|
else
|
||||||
|
*xs << c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
font_old = font.fontInfo();
|
font_old = font.fontInfo();
|
||||||
}
|
}
|
||||||
@ -3657,9 +3665,11 @@ std::tuple<std::vector<docstring>, std::vector<docstring>, std::vector<docstring
|
|||||||
xs->closeFontTags();
|
xs->closeFontTags();
|
||||||
|
|
||||||
// Deal with the delayed characters *after* closing font tags.
|
// Deal with the delayed characters *after* closing font tags.
|
||||||
if (!delayedChars.empty())
|
if (!delayedChars.empty()) {
|
||||||
for (char_type c: delayedChars)
|
for (const docstring &c: delayedChars)
|
||||||
*xs << c;
|
*xs << XMLStream::ESCAPE_NONE << c;
|
||||||
|
delayedChars.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// In listings, new lines (i.e. \n characters in the output) are very important. Avoid generating one for the
|
// In listings, new lines (i.e. \n characters in the output) are very important. Avoid generating one for the
|
||||||
// last line to get a clean output.
|
// last line to get a clean output.
|
||||||
|
Loading…
Reference in New Issue
Block a user