Whitespace

This commit is contained in:
Richard Kimberly Heck 2020-07-08 12:15:34 -04:00
parent eeaea7cbbb
commit 8ae0841826
13 changed files with 906 additions and 881 deletions

View File

@ -1594,74 +1594,74 @@ string citationStyleToString(const CitationStyle & cs, bool const latex)
docstring authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream & xs, Buffer const & buf)
{
// This function closely mimics getAuthorList, but produces DocBook instead of text.
// It has been greatly simplified, as the complete list of authors is always produced. No separators are required,
// as the output has a database-like shape.
// constructName has also been merged within, as it becomes really simple and leads to no copy-paste.
// This function closely mimics getAuthorList, but produces DocBook instead of text.
// It has been greatly simplified, as the complete list of authors is always produced. No separators are required,
// as the output has a database-like shape.
// constructName has also been merged within, as it becomes really simple and leads to no copy-paste.
if (authorsString.empty()) {
return docstring();
}
if (authorsString.empty()) {
return docstring();
}
// Split the input list of authors into individual authors.
vector<docstring> const authors = getAuthors(authorsString);
// Split the input list of authors into individual authors.
vector<docstring> const authors = getAuthors(authorsString);
// Retrieve the "et al." variation.
string const etal = buf.params().documentClass().getCiteMacro(buf.params().citeEngineType(), "_etal");
// Retrieve the "et al." variation.
string const etal = buf.params().documentClass().getCiteMacro(buf.params().citeEngineType(), "_etal");
// Output the list of authors.
xs << xml::StartTag("authorgroup");
auto it = authors.cbegin();
auto en = authors.cend();
for (size_t i = 0; it != en; ++it, ++i) {
xs << xml::StartTag("author");
xs << xml::CR();
xs << xml::StartTag("personname");
xs << xml::CR();
docstring name = *it;
// Output the list of authors.
xs << xml::StartTag("authorgroup");
auto it = authors.cbegin();
auto en = authors.cend();
for (size_t i = 0; it != en; ++it, ++i) {
xs << xml::StartTag("author");
xs << xml::CR();
xs << xml::StartTag("personname");
xs << xml::CR();
docstring name = *it;
// All authors go in a <personname>. If more structure is known, use it; otherwise (just "et al."), print it as such.
if (name == "others") {
xs << buf.B_(etal);
} else {
name_parts parts = nameParts(name);
if (! parts.prefix.empty()) {
xs << xml::StartTag("honorific");
xs << parts.prefix;
xs << xml::EndTag("honorific");
xs << xml::CR();
}
if (! parts.prename.empty()) {
xs << xml::StartTag("firstname");
xs << parts.prename;
xs << xml::EndTag("firstname");
xs << xml::CR();
}
if (! parts.surname.empty()) {
xs << xml::StartTag("surname");
xs << parts.surname;
xs << xml::EndTag("surname");
xs << xml::CR();
}
if (! parts.suffix.empty()) {
xs << xml::StartTag("othername", "role=\"suffix\"");
xs << parts.suffix;
xs << xml::EndTag("othername");
xs << xml::CR();
}
}
// All authors go in a <personname>. If more structure is known, use it; otherwise (just "et al."), print it as such.
if (name == "others") {
xs << buf.B_(etal);
} else {
name_parts parts = nameParts(name);
if (! parts.prefix.empty()) {
xs << xml::StartTag("honorific");
xs << parts.prefix;
xs << xml::EndTag("honorific");
xs << xml::CR();
}
if (! parts.prename.empty()) {
xs << xml::StartTag("firstname");
xs << parts.prename;
xs << xml::EndTag("firstname");
xs << xml::CR();
}
if (! parts.surname.empty()) {
xs << xml::StartTag("surname");
xs << parts.surname;
xs << xml::EndTag("surname");
xs << xml::CR();
}
if (! parts.suffix.empty()) {
xs << xml::StartTag("othername", "role=\"suffix\"");
xs << parts.suffix;
xs << xml::EndTag("othername");
xs << xml::CR();
}
}
xs << xml::EndTag("personname");
xs << xml::CR();
xs << xml::EndTag("author");
xs << xml::CR();
xs << xml::EndTag("personname");
xs << xml::CR();
xs << xml::EndTag("author");
xs << xml::CR();
// Could add an affiliation after <personname>, but not stored in BibTeX.
}
xs << xml::EndTag("authorgroup");
xs << xml::CR();
// Could add an affiliation after <personname>, but not stored in BibTeX.
}
xs << xml::EndTag("authorgroup");
xs << xml::CR();
return docstring();
return docstring();
}
} // namespace lyx

View File

@ -2143,22 +2143,22 @@ Buffer::ExportStatus Buffer::writeDocBookSource(odocstream & os,
XMLStream xs(os);
if (output_preamble) {
// XML preamble, no doctype needed.
// XML preamble, no doctype needed.
// Not using XMLStream for this, as the root tag would be in the tag stack and make troubles with the error
// detection mechanisms (these are called before the end tag is output, and thus interact with the canary
// parsep in output_docbook.cpp).
os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
<< "<!-- This DocBook file was created by LyX " << lyx_version
<< "\n See http://www.lyx.org/ for more information -->\n";
// Directly output the root tag, based on the current type of document.
string languageCode = params().language->code();
string languageCode = params().language->code();
string params = "xml:lang=\"" + languageCode + '"'
+ " xmlns=\"http://docbook.org/ns/docbook\""
+ " xmlns:xlink=\"http://www.w3.org/1999/xlink\""
+ " xmlns:m=\"http://www.w3.org/1998/Math/MathML\""
+ " xmlns:xi=\"http://www.w3.org/2001/XInclude\""
+ " version=\"5.2\"";
+ " xmlns:xi=\"http://www.w3.org/2001/XInclude\""
+ " version=\"5.2\"";
os << "<" << from_ascii(tclass.docbookroot()) << " " << from_ascii(params) << ">\n";
}

View File

@ -336,8 +336,8 @@ public:
OutputWhat output = FullSource) const;
///
ExportStatus writeDocBookSource(odocstream & os,
OutputParams const & runparams_in,
OutputWhat output = FullSource) const;
OutputParams const & runparams_in,
OutputWhat output = FullSource) const;
///
ExportStatus makeLyXHTMLFile(support::FileName const & filename,
OutputParams const & runparams_in) const;

View File

@ -3004,13 +3004,13 @@ void doFontSwitchDocBook(vector<xml::FontTag> & tagsToOpen,
vector<xml::EndFontTag> & tagsToClose,
bool & flag, FontState curstate, xml::FontTypes type)
{
if (curstate == FONT_ON) {
tagsToOpen.push_back(docbookStartFontTag(type));
flag = true;
} else if (flag) {
tagsToClose.push_back(docbookEndFontTag(type));
flag = false;
}
if (curstate == FONT_ON) {
tagsToOpen.push_back(docbookStartFontTag(type));
flag = true;
} else if (flag) {
tagsToClose.push_back(docbookEndFontTag(type));
flag = false;
}
}
class OptionalFontType {
@ -3024,42 +3024,42 @@ public:
OptionalFontType fontShapeToXml(FontShape fs)
{
switch (fs) {
case ITALIC_SHAPE:
switch (fs) {
case ITALIC_SHAPE:
return {xml::FT_ITALIC};
case SLANTED_SHAPE:
return {xml::FT_SLANTED};
case SMALLCAPS_SHAPE:
return {xml::FT_SMALLCAPS};
case UP_SHAPE:
case INHERIT_SHAPE:
return {};
default:
// the other tags are for internal use
LATTEST(false);
return {};
}
case SLANTED_SHAPE:
return {xml::FT_SLANTED};
case SMALLCAPS_SHAPE:
return {xml::FT_SMALLCAPS};
case UP_SHAPE:
case INHERIT_SHAPE:
return {};
default:
// the other tags are for internal use
LATTEST(false);
return {};
}
}
OptionalFontType fontFamilyToXml(FontFamily fm)
{
switch (fm) {
case ROMAN_FAMILY:
return {xml::FT_ROMAN};
break;
case SANS_FAMILY:
return {xml::FT_SANS};
break;
case TYPEWRITER_FAMILY:
return {xml::FT_TYPE};
break;
case INHERIT_FAMILY:
return {};
default:
// the other tags are for internal use
LATTEST(false);
return {};
}
switch (fm) {
case ROMAN_FAMILY:
return {xml::FT_ROMAN};
break;
case SANS_FAMILY:
return {xml::FT_SANS};
break;
case TYPEWRITER_FAMILY:
return {xml::FT_TYPE};
break;
case INHERIT_FAMILY:
return {};
default:
// the other tags are for internal use
LATTEST(false);
return {};
}
}
OptionalFontType fontSizeToXml(FontSize fs)
@ -3095,7 +3095,6 @@ OptionalFontType fontSizeToXml(FontSize fs)
LATTEST(false);
return {};
}
}
}// anonymous namespace
@ -3108,198 +3107,198 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
bool start_paragraph, bool close_paragraph,
pos_type initial) const
{
// track whether we have opened these tags
bool emph_flag = false;
bool bold_flag = false;
bool noun_flag = false;
bool ubar_flag = false;
bool dbar_flag = false;
bool sout_flag = false;
bool wave_flag = false;
// shape tags
bool shap_flag = false;
// family tags
bool faml_flag = false;
// size tags
bool size_flag = false;
// track whether we have opened these tags
bool emph_flag = false;
bool bold_flag = false;
bool noun_flag = false;
bool ubar_flag = false;
bool dbar_flag = false;
bool sout_flag = false;
bool wave_flag = false;
// shape tags
bool shap_flag = false;
// family tags
bool faml_flag = false;
// size tags
bool size_flag = false;
Layout const & style = *d->layout_;
Layout const & style = *d->layout_;
if (start_paragraph)
xs.startDivision(allowEmpty());
if (start_paragraph)
xs.startDivision(allowEmpty());
FontInfo font_old =
style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
FontInfo font_old =
style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
FontShape curr_fs = INHERIT_SHAPE;
FontFamily curr_fam = INHERIT_FAMILY;
FontSize curr_size = INHERIT_SIZE;
FontShape curr_fs = INHERIT_SHAPE;
FontFamily curr_fam = INHERIT_FAMILY;
FontSize curr_size = INHERIT_SIZE;
string const default_family =
buf.masterBuffer()->params().fonts_default_family;
string const default_family =
buf.masterBuffer()->params().fonts_default_family;
vector<xml::FontTag> tagsToOpen;
vector<xml::EndFontTag> tagsToClose;
vector<xml::FontTag> tagsToOpen;
vector<xml::EndFontTag> tagsToClose;
// parsing main loop
for (pos_type i = initial; i < size(); ++i) {
// let's not show deleted material in the output
if (isDeleted(i))
continue;
// parsing main loop
for (pos_type i = initial; i < size(); ++i) {
// let's not show deleted material in the output
if (isDeleted(i))
continue;
Font const font = getFont(buf.masterBuffer()->params(), i, outerfont);
Font const font = getFont(buf.masterBuffer()->params(), i, outerfont);
// emphasis
FontState curstate = font.fontInfo().emph();
if (font_old.emph() != curstate)
doFontSwitchDocBook(tagsToOpen, tagsToClose, emph_flag, curstate, xml::FT_EMPH);
// emphasis
FontState curstate = font.fontInfo().emph();
if (font_old.emph() != curstate)
doFontSwitchDocBook(tagsToOpen, tagsToClose, emph_flag, curstate, xml::FT_EMPH);
// noun
curstate = font.fontInfo().noun();
if (font_old.noun() != curstate)
doFontSwitchDocBook(tagsToOpen, tagsToClose, noun_flag, curstate, xml::FT_NOUN);
// noun
curstate = font.fontInfo().noun();
if (font_old.noun() != curstate)
doFontSwitchDocBook(tagsToOpen, tagsToClose, noun_flag, curstate, xml::FT_NOUN);
// underbar
curstate = font.fontInfo().underbar();
if (font_old.underbar() != curstate)
doFontSwitchDocBook(tagsToOpen, tagsToClose, ubar_flag, curstate, xml::FT_UBAR);
// underbar
curstate = font.fontInfo().underbar();
if (font_old.underbar() != curstate)
doFontSwitchDocBook(tagsToOpen, tagsToClose, ubar_flag, curstate, xml::FT_UBAR);
// strikeout
curstate = font.fontInfo().strikeout();
if (font_old.strikeout() != curstate)
doFontSwitchDocBook(tagsToOpen, tagsToClose, sout_flag, curstate, xml::FT_SOUT);
// strikeout
curstate = font.fontInfo().strikeout();
if (font_old.strikeout() != curstate)
doFontSwitchDocBook(tagsToOpen, tagsToClose, sout_flag, curstate, xml::FT_SOUT);
// double underbar
curstate = font.fontInfo().uuline();
if (font_old.uuline() != curstate)
doFontSwitchDocBook(tagsToOpen, tagsToClose, dbar_flag, curstate, xml::FT_DBAR);
// double underbar
curstate = font.fontInfo().uuline();
if (font_old.uuline() != curstate)
doFontSwitchDocBook(tagsToOpen, tagsToClose, dbar_flag, curstate, xml::FT_DBAR);
// wavy line
curstate = font.fontInfo().uwave();
if (font_old.uwave() != curstate)
doFontSwitchDocBook(tagsToOpen, tagsToClose, wave_flag, curstate, xml::FT_WAVE);
// wavy line
curstate = font.fontInfo().uwave();
if (font_old.uwave() != curstate)
doFontSwitchDocBook(tagsToOpen, tagsToClose, wave_flag, curstate, xml::FT_WAVE);
// bold
// a little hackish, but allows us to reuse what we have.
curstate = (font.fontInfo().series() == BOLD_SERIES ? FONT_ON : FONT_OFF);
if (font_old.series() != font.fontInfo().series())
doFontSwitchDocBook(tagsToOpen, tagsToClose, bold_flag, curstate, xml::FT_BOLD);
// bold
// a little hackish, but allows us to reuse what we have.
curstate = (font.fontInfo().series() == BOLD_SERIES ? FONT_ON : FONT_OFF);
if (font_old.series() != font.fontInfo().series())
doFontSwitchDocBook(tagsToOpen, tagsToClose, bold_flag, curstate, xml::FT_BOLD);
// Font shape
curr_fs = font.fontInfo().shape();
FontShape old_fs = font_old.shape();
if (old_fs != curr_fs) {
// Font shape
curr_fs = font.fontInfo().shape();
FontShape old_fs = font_old.shape();
if (old_fs != curr_fs) {
if (shap_flag) {
OptionalFontType tag = fontShapeToXml(old_fs);
if (tag.has_value) {
tagsToClose.push_back(docbookEndFontTag(tag.ft));
}
shap_flag = false;
shap_flag = false;
}
OptionalFontType tag = fontShapeToXml(curr_fs);
if (tag.has_value) {
tagsToOpen.push_back(docbookStartFontTag(tag.ft));
}
}
}
// Font family
curr_fam = font.fontInfo().family();
FontFamily old_fam = font_old.family();
if (old_fam != curr_fam) {
if (faml_flag) {
// Font family
curr_fam = font.fontInfo().family();
FontFamily old_fam = font_old.family();
if (old_fam != curr_fam) {
if (faml_flag) {
OptionalFontType tag = fontFamilyToXml(old_fam);
if (tag.has_value) {
tagsToClose.push_back(docbookEndFontTag(tag.ft));
}
faml_flag = false;
}
switch (curr_fam) {
case ROMAN_FAMILY:
// we will treat a "default" font family as roman, since we have
// no other idea what to do.
if (default_family != "rmdefault" && default_family != "default") {
tagsToOpen.push_back(docbookStartFontTag(xml::FT_ROMAN));
faml_flag = true;
}
break;
case SANS_FAMILY:
if (default_family != "sfdefault") {
tagsToOpen.push_back(docbookStartFontTag(xml::FT_SANS));
faml_flag = true;
}
break;
case TYPEWRITER_FAMILY:
if (default_family != "ttdefault") {
tagsToOpen.push_back(docbookStartFontTag(xml::FT_TYPE));
faml_flag = true;
}
break;
case INHERIT_FAMILY:
break;
default:
// the other tags are for internal use
LATTEST(false);
break;
}
}
if (tag.has_value) {
tagsToClose.push_back(docbookEndFontTag(tag.ft));
}
faml_flag = false;
}
switch (curr_fam) {
case ROMAN_FAMILY:
// we will treat a "default" font family as roman, since we have
// no other idea what to do.
if (default_family != "rmdefault" && default_family != "default") {
tagsToOpen.push_back(docbookStartFontTag(xml::FT_ROMAN));
faml_flag = true;
}
break;
case SANS_FAMILY:
if (default_family != "sfdefault") {
tagsToOpen.push_back(docbookStartFontTag(xml::FT_SANS));
faml_flag = true;
}
break;
case TYPEWRITER_FAMILY:
if (default_family != "ttdefault") {
tagsToOpen.push_back(docbookStartFontTag(xml::FT_TYPE));
faml_flag = true;
}
break;
case INHERIT_FAMILY:
break;
default:
// the other tags are for internal use
LATTEST(false);
break;
}
}
// Font size
curr_size = font.fontInfo().size();
FontSize old_size = font_old.size();
if (old_size != curr_size) {
if (size_flag) {
// Font size
curr_size = font.fontInfo().size();
FontSize old_size = font_old.size();
if (old_size != curr_size) {
if (size_flag) {
OptionalFontType tag = fontSizeToXml(old_size);
if (tag.has_value) {
tagsToClose.push_back(docbookEndFontTag(tag.ft));
}
size_flag = false;
}
size_flag = false;
}
OptionalFontType tag = fontSizeToXml(curr_size);
if (tag.has_value) {
tagsToOpen.push_back(docbookStartFontTag(tag.ft));
size_flag = true;
}
}
}
// FIXME XHTML
// Other such tags? What about the other text ranges?
// FIXME XHTML
// Other such tags? What about the other text ranges?
vector<xml::EndFontTag>::const_iterator cit = tagsToClose.begin();
vector<xml::EndFontTag>::const_iterator cen = tagsToClose.end();
for (; cit != cen; ++cit)
xs << *cit;
vector<xml::EndFontTag>::const_iterator cit = tagsToClose.begin();
vector<xml::EndFontTag>::const_iterator cen = tagsToClose.end();
for (; cit != cen; ++cit)
xs << *cit;
vector<xml::FontTag>::const_iterator sit = tagsToOpen.begin();
vector<xml::FontTag>::const_iterator sen = tagsToOpen.end();
for (; sit != sen; ++sit)
xs << *sit;
vector<xml::FontTag>::const_iterator sit = tagsToOpen.begin();
vector<xml::FontTag>::const_iterator sen = tagsToOpen.end();
for (; sit != sen; ++sit)
xs << *sit;
tagsToClose.clear();
tagsToOpen.clear();
tagsToClose.clear();
tagsToOpen.clear();
if (Inset const * inset = getInset(i)) {
if (!runparams.for_toc || inset->isInToc()) {
OutputParams np = runparams;
np.local_font = &font;
// If the paragraph has size 1, then we are in the "special
// case" where we do not output the containing paragraph info.
if (!inset->getLayout().htmlisblock() && size() != 1) // TODO: htmlisblock here too!
np.docbook_in_par = true;
inset->docbook(xs, np);
}
} else {
char_type c = getUChar(buf.masterBuffer()->params(), runparams, i);
xs << c;
}
font_old = font.fontInfo();
}
if (Inset const * inset = getInset(i)) {
if (!runparams.for_toc || inset->isInToc()) {
OutputParams np = runparams;
np.local_font = &font;
// If the paragraph has size 1, then we are in the "special
// case" where we do not output the containing paragraph info.
if (!inset->getLayout().htmlisblock() && size() != 1) // TODO: htmlisblock here too!
np.docbook_in_par = true;
inset->docbook(xs, np);
}
} else {
char_type c = getUChar(buf.masterBuffer()->params(), runparams, i);
xs << c;
}
font_old = font.fontInfo();
}
// FIXME, this code is just imported from XHTML
// I'm worried about what happens if a branch, say, is itself
// wrapped in some font stuff. I think that will not work.
xs.closeFontTags();
// FIXME, this code is just imported from XHTML
// I'm worried about what happens if a branch, say, is itself
// wrapped in some font stuff. I think that will not work.
xs.closeFontTags();
if (runparams.docbook_in_listing)
xs << xml::CR();
if (close_paragraph)

View File

@ -554,29 +554,29 @@ int InsetIPAChar::plaintext(odocstringstream & os, OutputParams const &, size_t)
void InsetIPAChar::docbook(XMLStream & xs, OutputParams const &) const
{
switch (kind_) {
case TONE_FALLING:
xs << XMLStream::ESCAPE_NONE << "&#x2e5;";
xs << XMLStream::ESCAPE_NONE << "&#x2e9;";
break;
case TONE_RISING:
xs << XMLStream::ESCAPE_NONE << "&#x2e9;";
xs << XMLStream::ESCAPE_NONE << "&#x2e5;";
break;
case TONE_HIGH_RISING:
xs << XMLStream::ESCAPE_NONE << "&#x2e7;";
xs << XMLStream::ESCAPE_NONE << "&#x2e5;";
break;
case TONE_LOW_RISING:
xs << XMLStream::ESCAPE_NONE << "&#x2e9;";
xs << XMLStream::ESCAPE_NONE << "&#x2e7;";
break;
case TONE_HIGH_RISING_FALLING:
xs << XMLStream::ESCAPE_NONE << "&#x2e8;";
xs << XMLStream::ESCAPE_NONE << "&#x2e5;";
xs << XMLStream::ESCAPE_NONE << "&#x2e8;";
break;
}
switch (kind_) {
case TONE_FALLING:
xs << XMLStream::ESCAPE_NONE << "&#x2e5;";
xs << XMLStream::ESCAPE_NONE << "&#x2e9;";
break;
case TONE_RISING:
xs << XMLStream::ESCAPE_NONE << "&#x2e9;";
xs << XMLStream::ESCAPE_NONE << "&#x2e5;";
break;
case TONE_HIGH_RISING:
xs << XMLStream::ESCAPE_NONE << "&#x2e7;";
xs << XMLStream::ESCAPE_NONE << "&#x2e5;";
break;
case TONE_LOW_RISING:
xs << XMLStream::ESCAPE_NONE << "&#x2e9;";
xs << XMLStream::ESCAPE_NONE << "&#x2e7;";
break;
case TONE_HIGH_RISING_FALLING:
xs << XMLStream::ESCAPE_NONE << "&#x2e8;";
xs << XMLStream::ESCAPE_NONE << "&#x2e5;";
xs << XMLStream::ESCAPE_NONE << "&#x2e8;";
break;
}
}

View File

@ -193,19 +193,19 @@ void InsetIndex::docbook(XMLStream & xs, OutputParams const & runparams) const
InsetText::latex(ots, runparams);
docstring latexString = trim(odss.str());
// Check whether there are unsupported things.
if (latexString.find(from_utf8("@")) != latexString.npos) {
docstring error = from_utf8("Unsupported feature: an index entry contains an @. "
"Complete entry: \"") + latexString + from_utf8("\"");
LYXERR0(error);
xs << XMLStream::ESCAPE_NONE << (from_utf8("<!-- Output Error: ") + error + from_utf8(" -->\n"));
}
// Check whether there are unsupported things.
if (latexString.find(from_utf8("@")) != latexString.npos) {
docstring error = from_utf8("Unsupported feature: an index entry contains an @. "
"Complete entry: \"") + latexString + from_utf8("\"");
LYXERR0(error);
xs << XMLStream::ESCAPE_NONE << (from_utf8("<!-- Output Error: ") + error + from_utf8(" -->\n"));
}
// Handle several indices.
docstring indexType = from_utf8("");
if (buffer().masterBuffer()->params().use_indices) {
indexType += " type=\"" + params_.index + "\"";
}
// Handle several indices.
docstring indexType = from_utf8("");
if (buffer().masterBuffer()->params().use_indices) {
indexType += " type=\"" + params_.index + "\"";
}
// Split the string into its main constituents: terms, and command (see, see also, range).
size_t positionVerticalBar = latexString.find(from_ascii("|")); // What comes before | is (sub)(sub)entries.
@ -237,13 +237,13 @@ void InsetIndex::docbook(XMLStream & xs, OutputParams const & runparams) const
docstring see = from_utf8("");
vector<docstring> seeAlsoes;
if (command.substr(0, 3) == "see") {
// Unescape brackets.
size_t index = 0;
while ((index = command.find(from_utf8("\\{"), index)) != std::string::npos)
command.erase(index, 1);
index = 0;
while ((index = command.find(from_utf8("\\}"), index)) != std::string::npos)
command.erase(index, 1);
// Unescape brackets.
size_t index = 0;
while ((index = command.find(from_utf8("\\{"), index)) != std::string::npos)
command.erase(index, 1);
index = 0;
while ((index = command.find(from_utf8("\\}"), index)) != std::string::npos)
command.erase(index, 1);
// Retrieve the part between brackets, and remove the complete seealso.
size_t positionOpeningBracket = command.find(from_ascii("{"));
@ -258,14 +258,14 @@ void InsetIndex::docbook(XMLStream & xs, OutputParams const & runparams) const
if (see.find(from_ascii(",")) != see.npos) {
docstring error = from_utf8("Several index terms found as \"see\"! Only one is acceptable. "
"Complete entry: \"") + latexString + from_utf8("\"");
"Complete entry: \"") + latexString + from_utf8("\"");
LYXERR0(error);
xs << XMLStream::ESCAPE_NONE << (from_utf8("<!-- Output Error: ") + error + from_utf8(" -->\n"));
}
}
// Remove the complete see/seealso from the commands, in case there is something else to parse.
command = command.substr(positionClosingBracket + 1);
// Remove the complete see/seealso from the commands, in case there is something else to parse.
command = command.substr(positionClosingBracket + 1);
}
// Some parts of the strings are not parsed, as they do not have anything matching in DocBook: things like

View File

@ -483,10 +483,10 @@ docstring InsetListings::xhtml(XMLStream & os, OutputParams const & rp) const
void InsetListings::docbook(XMLStream & xs, OutputParams const & rp) const
{
InsetLayout const & il = getLayout();
InsetLayout const & il = getLayout();
// Forge the attributes.
string attrs;
string attrs;
if (!il.docbookattr().empty())
attrs += " role=\"" + il.docbookattr() + "\"";
string const lang = params().getParamValue("language");

View File

@ -4165,7 +4165,7 @@ docstring InsetTableCell::xhtml(XMLStream & xs, OutputParams const & rp) const
void InsetTableCell::docbook(XMLStream & xs, OutputParams const & runparams) const
{
InsetText::docbook(xs, runparams);
InsetText::docbook(xs, runparams);
}

View File

@ -573,7 +573,7 @@ public:
///
void latex(otexstream &, OutputParams const &) const;
///
void docbook(XMLStream &, OutputParams const &) const;
void docbook(XMLStream &, OutputParams const &) const;
///
docstring xhtml(XMLStream &, OutputParams const &) const;
///
@ -908,8 +908,8 @@ public:
std::vector<unsigned int> const &,
bool onlydata, size_t max_length) const;
/// auxiliary function for docbook
void docbookRow(XMLStream &, row_type, OutputParams const &,
bool header = false) const;
void docbookRow(XMLStream &, row_type, OutputParams const &,
bool header = false) const;
///
docstring xhtmlRow(XMLStream & xs, row_type, OutputParams const &,
bool header = false) const;

View File

@ -591,7 +591,7 @@ int InsetText::plaintext(odocstringstream & os,
void InsetText::docbook(XMLStream & xs, OutputParams const & rp) const
{
docbook(xs, rp, WriteEverything);
docbook(xs, rp, WriteEverything);
}
@ -612,13 +612,13 @@ void InsetText::docbook(XMLStream & xs, OutputParams const & rp, XHTMLOptions op
InsetLayout const & il = getLayout();
if (opts & WriteOuterTag && !il.docbooktag().empty() && il.docbooktag() != "NONE") {
docstring attrs = docstring();
if (!il.docbookattr().empty())
attrs += from_ascii(il.docbookattr());
if (il.docbooktag() == "link")
attrs += from_ascii(" xlink:href=\"") + text_.asString() + from_ascii("\"");
xs << xml::StartTag(il.docbooktag(), attrs);
}
docstring attrs = docstring();
if (!il.docbookattr().empty())
attrs += from_ascii(il.docbookattr());
if (il.docbooktag() == "link")
attrs += from_ascii(" xlink:href=\"") + text_.asString() + from_ascii("\"");
xs << xml::StartTag(il.docbooktag(), attrs);
}
// No need for labels that are generated from counters.

View File

@ -2444,23 +2444,23 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams const & runparams) cons
ms << from_utf8(subst(subst(to_utf8(ls.str()), "&", "&amp;"), "<", "&lt;"));
ms << "</" << from_ascii("alt") << ">";
// Actual transformation of the formula into MathML. This translation may fail (for example, due to custom macros).
// The new output stream is required to deal with the errors: first write completely the formula into this
// temporary stream; then, if it is possible without error, then copy it back to the "real" stream. Otherwise,
// Actual transformation of the formula into MathML. This translation may fail (for example, due to custom macros).
// The new output stream is required to deal with the errors: first write completely the formula into this
// temporary stream; then, if it is possible without error, then copy it back to the "real" stream. Otherwise,
// some incomplete tags might be put into the real stream.
try {
// First, generate the MathML expression.
odocstringstream ostmp;
MathStream mstmp(ostmp, ms.xmlns(), ms.xmlMode());
InsetMathGrid::mathmlize(mstmp);
try {
// First, generate the MathML expression.
odocstringstream ostmp;
MathStream mstmp(ostmp, ms.xmlns(), ms.xmlMode());
InsetMathGrid::mathmlize(mstmp);
// Then, output it (but only if the generation can be done without errors!).
ms << MTag("math");
ms.cr();
// Then, output it (but only if the generation can be done without errors!).
ms << MTag("math");
ms.cr();
osmath << ostmp.str(); // osmath is not a XMLStream, so no need for XMLStream::ESCAPE_NONE.
ms << ETag("math");
} catch (MathExportException const &) {
osmath << "MathML export failed. Please report this as a bug.";
ms << ETag("math");
} catch (MathExportException const &) {
osmath << "MathML export failed. Please report this as a bug.";
}
// Close the DocBook tag enclosing the formula.

View File

@ -47,122 +47,124 @@ namespace lyx {
namespace {
std::string const fontToDocBookTag(xml::FontTypes type) {
switch (type) {
case xml::FontTypes::FT_EMPH:
case xml::FontTypes::FT_BOLD:
return "emphasis";
case xml::FontTypes::FT_NOUN:
return "person";
case xml::FontTypes::FT_UBAR:
case xml::FontTypes::FT_WAVE:
case xml::FontTypes::FT_DBAR:
case xml::FontTypes::FT_SOUT:
case xml::FontTypes::FT_XOUT:
case xml::FontTypes::FT_ITALIC:
case xml::FontTypes::FT_UPRIGHT:
case xml::FontTypes::FT_SLANTED:
case xml::FontTypes::FT_SMALLCAPS:
case xml::FontTypes::FT_ROMAN:
case xml::FontTypes::FT_SANS:
return "emphasis";
case xml::FontTypes::FT_TYPE:
return "code";
case xml::FontTypes::FT_SIZE_TINY:
case xml::FontTypes::FT_SIZE_SCRIPT:
case xml::FontTypes::FT_SIZE_FOOTNOTE:
case xml::FontTypes::FT_SIZE_SMALL:
case xml::FontTypes::FT_SIZE_NORMAL:
case xml::FontTypes::FT_SIZE_LARGE:
case xml::FontTypes::FT_SIZE_LARGER:
case xml::FontTypes::FT_SIZE_LARGEST:
case xml::FontTypes::FT_SIZE_HUGE:
case xml::FontTypes::FT_SIZE_HUGER:
case xml::FontTypes::FT_SIZE_INCREASE:
case xml::FontTypes::FT_SIZE_DECREASE:
return "emphasis";
default:
return "";
}
std::string const fontToDocBookTag(xml::FontTypes type)
{
switch (type) {
case xml::FontTypes::FT_EMPH:
case xml::FontTypes::FT_BOLD:
return "emphasis";
case xml::FontTypes::FT_NOUN:
return "person";
case xml::FontTypes::FT_UBAR:
case xml::FontTypes::FT_WAVE:
case xml::FontTypes::FT_DBAR:
case xml::FontTypes::FT_SOUT:
case xml::FontTypes::FT_XOUT:
case xml::FontTypes::FT_ITALIC:
case xml::FontTypes::FT_UPRIGHT:
case xml::FontTypes::FT_SLANTED:
case xml::FontTypes::FT_SMALLCAPS:
case xml::FontTypes::FT_ROMAN:
case xml::FontTypes::FT_SANS:
return "emphasis";
case xml::FontTypes::FT_TYPE:
return "code";
case xml::FontTypes::FT_SIZE_TINY:
case xml::FontTypes::FT_SIZE_SCRIPT:
case xml::FontTypes::FT_SIZE_FOOTNOTE:
case xml::FontTypes::FT_SIZE_SMALL:
case xml::FontTypes::FT_SIZE_NORMAL:
case xml::FontTypes::FT_SIZE_LARGE:
case xml::FontTypes::FT_SIZE_LARGER:
case xml::FontTypes::FT_SIZE_LARGEST:
case xml::FontTypes::FT_SIZE_HUGE:
case xml::FontTypes::FT_SIZE_HUGER:
case xml::FontTypes::FT_SIZE_INCREASE:
case xml::FontTypes::FT_SIZE_DECREASE:
return "emphasis";
default:
return "";
}
}
string fontToRole(xml::FontTypes type) {
// Specific fonts are achieved with roles. The only common ones are "" for basic emphasis,
// and "bold"/"strong" for bold. With some specific options, other roles are copied into
// HTML output (via the DocBook XSLT sheets); otherwise, if not recognised, they are just ignored.
// Hence, it is not a problem to have many roles by default here.
// See https://www.sourceware.org/ml/docbook/2003-05/msg00269.html
switch (type) {
case xml::FontTypes::FT_ITALIC:
case xml::FontTypes::FT_EMPH:
return "";
case xml::FontTypes::FT_BOLD:
return "bold";
case xml::FontTypes::FT_NOUN:
return ""; // Outputs a <person>
case xml::FontTypes::FT_TYPE:
return ""; // Outputs a <code>
string fontToRole(xml::FontTypes type)
{
// Specific fonts are achieved with roles. The only common ones are "" for basic emphasis,
// and "bold"/"strong" for bold. With some specific options, other roles are copied into
// HTML output (via the DocBook XSLT sheets); otherwise, if not recognised, they are just ignored.
// Hence, it is not a problem to have many roles by default here.
// See https://www.sourceware.org/ml/docbook/2003-05/msg00269.html
switch (type) {
case xml::FontTypes::FT_ITALIC:
case xml::FontTypes::FT_EMPH:
return "";
case xml::FontTypes::FT_BOLD:
return "bold";
case xml::FontTypes::FT_NOUN:
return ""; // Outputs a <person>
case xml::FontTypes::FT_TYPE:
return ""; // Outputs a <code>
// All other roles are non-standard for DocBook.
// All other roles are non-standard for DocBook.
case xml::FontTypes::FT_UBAR:
return "ubar";
case xml::FontTypes::FT_WAVE:
return "wave";
case xml::FontTypes::FT_DBAR:
return "dbar";
case xml::FontTypes::FT_SOUT:
return "sout";
case xml::FontTypes::FT_XOUT:
return "xout";
case xml::FontTypes::FT_UPRIGHT:
return "upright";
case xml::FontTypes::FT_SLANTED:
return "slanted";
case xml::FontTypes::FT_SMALLCAPS:
return "smallcaps";
case xml::FontTypes::FT_ROMAN:
return "roman";
case xml::FontTypes::FT_SANS:
return "sans";
case xml::FontTypes::FT_SIZE_TINY:
return "tiny";
case xml::FontTypes::FT_SIZE_SCRIPT:
return "size_script";
case xml::FontTypes::FT_SIZE_FOOTNOTE:
return "size_footnote";
case xml::FontTypes::FT_SIZE_SMALL:
return "size_small";
case xml::FontTypes::FT_SIZE_NORMAL:
return "size_normal";
case xml::FontTypes::FT_SIZE_LARGE:
return "size_large";
case xml::FontTypes::FT_SIZE_LARGER:
return "size_larger";
case xml::FontTypes::FT_SIZE_LARGEST:
return "size_largest";
case xml::FontTypes::FT_SIZE_HUGE:
return "size_huge";
case xml::FontTypes::FT_SIZE_HUGER:
return "size_huger";
case xml::FontTypes::FT_SIZE_INCREASE:
return "size_increase";
case xml::FontTypes::FT_SIZE_DECREASE:
return "size_decrease";
default:
return "";
}
case xml::FontTypes::FT_UBAR:
return "ubar";
case xml::FontTypes::FT_WAVE:
return "wave";
case xml::FontTypes::FT_DBAR:
return "dbar";
case xml::FontTypes::FT_SOUT:
return "sout";
case xml::FontTypes::FT_XOUT:
return "xout";
case xml::FontTypes::FT_UPRIGHT:
return "upright";
case xml::FontTypes::FT_SLANTED:
return "slanted";
case xml::FontTypes::FT_SMALLCAPS:
return "smallcaps";
case xml::FontTypes::FT_ROMAN:
return "roman";
case xml::FontTypes::FT_SANS:
return "sans";
case xml::FontTypes::FT_SIZE_TINY:
return "tiny";
case xml::FontTypes::FT_SIZE_SCRIPT:
return "size_script";
case xml::FontTypes::FT_SIZE_FOOTNOTE:
return "size_footnote";
case xml::FontTypes::FT_SIZE_SMALL:
return "size_small";
case xml::FontTypes::FT_SIZE_NORMAL:
return "size_normal";
case xml::FontTypes::FT_SIZE_LARGE:
return "size_large";
case xml::FontTypes::FT_SIZE_LARGER:
return "size_larger";
case xml::FontTypes::FT_SIZE_LARGEST:
return "size_largest";
case xml::FontTypes::FT_SIZE_HUGE:
return "size_huge";
case xml::FontTypes::FT_SIZE_HUGER:
return "size_huger";
case xml::FontTypes::FT_SIZE_INCREASE:
return "size_increase";
case xml::FontTypes::FT_SIZE_DECREASE:
return "size_decrease";
default:
return "";
}
}
string fontToAttribute(xml::FontTypes type) {
// If there is a role (i.e. nonstandard use of a tag), output the attribute. Otherwise, the sheer tag is sufficient
// for the font.
string role = fontToRole(type);
if (!role.empty()) {
return "role='" + role + "'";
} else {
return "";
}
// If there is a role (i.e. nonstandard use of a tag), output the attribute. Otherwise, the sheer tag is sufficient
// for the font.
string role = fontToRole(type);
if (!role.empty()) {
return "role='" + role + "'";
} else {
return "";
}
}
} // end anonymous namespace
@ -170,13 +172,13 @@ string fontToAttribute(xml::FontTypes type) {
xml::FontTag docbookStartFontTag(xml::FontTypes type)
{
return xml::FontTag(from_utf8(fontToDocBookTag(type)), from_utf8(fontToAttribute(type)), type);
return xml::FontTag(from_utf8(fontToDocBookTag(type)), from_utf8(fontToAttribute(type)), type);
}
xml::EndFontTag docbookEndFontTag(xml::FontTypes type)
{
return xml::EndFontTag(from_utf8(fontToDocBookTag(type)), type);
return xml::EndFontTag(from_utf8(fontToDocBookTag(type)), type);
}
@ -184,63 +186,68 @@ namespace {
// convenience functions
void openParTag(XMLStream &xs, Layout const &lay) {
if (lay.docbookwrappertag() != "NONE") {
xs << xml::StartTag(lay.docbookwrappertag(), lay.docbookwrapperattr());
}
void openParTag(XMLStream &xs, Layout const &lay)
{
if (lay.docbookwrappertag() != "NONE") {
xs << xml::StartTag(lay.docbookwrappertag(), lay.docbookwrapperattr());
}
string tag = lay.docbooktag();
if (tag == "Plain Layout")
tag = "para";
string tag = lay.docbooktag();
if (tag == "Plain Layout")
tag = "para";
xs << xml::ParTag(tag, lay.docbookattr());
xs << xml::ParTag(tag, lay.docbookattr());
}
void closeTag(XMLStream &xs, Layout const &lay) {
string tag = lay.docbooktag();
if (tag == "Plain Layout")
tag = "para";
void closeTag(XMLStream &xs, Layout const &lay)
{
string tag = lay.docbooktag();
if (tag == "Plain Layout")
tag = "para";
xs << xml::EndTag(tag);
if (lay.docbookwrappertag() != "NONE")
xs << xml::EndTag(lay.docbookwrappertag());
xs << xml::EndTag(tag);
if (lay.docbookwrappertag() != "NONE")
xs << xml::EndTag(lay.docbookwrappertag());
}
void openLabelTag(XMLStream & xs, Layout const & lay) // Mostly for definition lists.
{
xs << xml::StartTag(lay.docbookitemlabeltag(), lay.docbookitemlabelattr());
xs << xml::StartTag(lay.docbookitemlabeltag(), lay.docbookitemlabelattr());
}
void closeLabelTag(XMLStream & xs, Layout const & lay)
{
xs << xml::EndTag(lay.docbookitemlabeltag());
xs << xml::CR();
xs << xml::EndTag(lay.docbookitemlabeltag());
xs << xml::CR();
}
void openItemTag(XMLStream &xs, Layout const &lay) {
void openItemTag(XMLStream &xs, Layout const &lay)
{
xs << xml::StartTag(lay.docbookitemtag(), lay.docbookitemattr());
}
// Return true when new elements are output in a paragraph, false otherwise.
bool openInnerItemTag(XMLStream &xs, Layout const &lay) {
if (lay.docbookiteminnertag() != "NONE") {
xs << xml::CR();
xs << xml::ParTag(lay.docbookiteminnertag(), lay.docbookiteminnerattr());
bool openInnerItemTag(XMLStream &xs, Layout const &lay)
{
if (lay.docbookiteminnertag() != "NONE") {
xs << xml::CR();
xs << xml::ParTag(lay.docbookiteminnertag(), lay.docbookiteminnerattr());
if (lay.docbookiteminnertag() == "para") {
return true;
}
}
return false;
if (lay.docbookiteminnertag() == "para") {
return true;
}
}
return false;
}
void closeInnerItemTag(XMLStream &xs, Layout const &lay) {
void closeInnerItemTag(XMLStream &xs, Layout const &lay)
{
if (lay.docbookiteminnertag()!= "NONE") {
xs << xml::EndTag(lay.docbookiteminnertag());
xs << xml::CR();
@ -248,164 +255,171 @@ void closeInnerItemTag(XMLStream &xs, Layout const &lay) {
}
inline void closeItemTag(XMLStream &xs, Layout const &lay) {
xs << xml::EndTag(lay.docbookitemtag()) << xml::CR();
inline void closeItemTag(XMLStream &xs, Layout const &lay)
{
xs << xml::EndTag(lay.docbookitemtag()) << xml::CR();
}
// end of convenience functions
ParagraphList::const_iterator findLastParagraph(
ParagraphList::const_iterator p,
ParagraphList::const_iterator const &pend) {
for (++p; p != pend && p->layout().latextype == LATEX_PARAGRAPH; ++p);
ParagraphList::const_iterator p,
ParagraphList::const_iterator const & pend) {
for (++p; p != pend && p->layout().latextype == LATEX_PARAGRAPH; ++p);
return p;
return p;
}
ParagraphList::const_iterator findEndOfEnvironment(
ParagraphList::const_iterator const &pstart,
ParagraphList::const_iterator const &pend) {
ParagraphList::const_iterator p = pstart;
Layout const &bstyle = p->layout();
size_t const depth = p->params().depth();
for (++p; p != pend; ++p) {
Layout const &style = p->layout();
// It shouldn't happen that e.g. a section command occurs inside
// a quotation environment, at a higher depth, but as of 6/2009,
// it can happen. We pretend that it's just at lowest depth.
if (style.latextype == LATEX_COMMAND)
return p;
ParagraphList::const_iterator const & pstart,
ParagraphList::const_iterator const & pend)
{
ParagraphList::const_iterator p = pstart;
Layout const &bstyle = p->layout();
size_t const depth = p->params().depth();
for (++p; p != pend; ++p) {
Layout const &style = p->layout();
// It shouldn't happen that e.g. a section command occurs inside
// a quotation environment, at a higher depth, but as of 6/2009,
// it can happen. We pretend that it's just at lowest depth.
if (style.latextype == LATEX_COMMAND)
return p;
// If depth is down, we're done
if (p->params().depth() < depth)
return p;
// If depth is down, we're done
if (p->params().depth() < depth)
return p;
// If depth is up, we're not done
if (p->params().depth() > depth)
continue;
// If depth is up, we're not done
if (p->params().depth() > depth)
continue;
// FIXME I am not sure about the first check.
// Surely we *could* have different layouts that count as
// LATEX_PARAGRAPH, right?
if (style.latextype == LATEX_PARAGRAPH || style != bstyle)
return p;
}
return pend;
// FIXME I am not sure about the first check.
// Surely we *could* have different layouts that count as
// LATEX_PARAGRAPH, right?
if (style.latextype == LATEX_PARAGRAPH || style != bstyle)
return p;
}
return pend;
}
ParagraphList::const_iterator makeParagraphs(Buffer const &buf,
XMLStream &xs,
OutputParams const &runparams,
Text const &text,
ParagraphList::const_iterator const &pbegin,
ParagraphList::const_iterator const &pend) {
ParagraphList::const_iterator const begin = text.paragraphs().begin();
ParagraphList::const_iterator par = pbegin;
for (; par != pend; ++par) {
Layout const &lay = par->layout();
if (!lay.counter.empty())
buf.masterBuffer()->params().
documentClass().counters().step(lay.counter, OutputUpdate);
ParagraphList::const_iterator makeParagraphs(
Buffer const &buf,
XMLStream &xs,
OutputParams const &runparams,
Text const &text,
ParagraphList::const_iterator const & pbegin,
ParagraphList::const_iterator const & pend)
{
ParagraphList::const_iterator const begin = text.paragraphs().begin();
ParagraphList::const_iterator par = pbegin;
for (; par != pend; ++par) {
Layout const &lay = par->layout();
if (!lay.counter.empty())
buf.masterBuffer()->params().
documentClass().counters().step(lay.counter, OutputUpdate);
// We want to open the paragraph tag if:
// (i) the current layout permits multiple paragraphs
// (ii) we are either not already inside a paragraph (HTMLIsBlock) OR
// we are, but this is not the first paragraph
//
// But there is also a special case, and we first see whether we are in it.
// We do not want to open the paragraph tag if this paragraph contains
// only one item, and that item is "inline", i.e., not HTMLIsBlock (such
// as a branch). On the other hand, if that single item has a font change
// applied to it, then we still do need to open the paragraph.
//
// Obviously, this is very fragile. The main reason we need to do this is
// because of branches, e.g., a branch that contains an entire new section.
// We do not really want to wrap that whole thing in a <div>...</div>.
bool special_case = false;
Inset const *specinset = par->size() == 1 ? par->getInset(0) : 0;
if (specinset && !specinset->getLayout().htmlisblock()) { // TODO: Convert htmlisblock to a DocBook parameter?
Layout const &style = par->layout();
FontInfo const first_font = style.labeltype == LABEL_MANUAL ?
style.labelfont : style.font;
FontInfo const our_font =
par->getFont(buf.masterBuffer()->params(), 0,
text.outerFont(distance(begin, par))).fontInfo();
// We want to open the paragraph tag if:
// (i) the current layout permits multiple paragraphs
// (ii) we are either not already inside a paragraph (HTMLIsBlock) OR
// we are, but this is not the first paragraph
//
// But there is also a special case, and we first see whether we are in it.
// We do not want to open the paragraph tag if this paragraph contains
// only one item, and that item is "inline", i.e., not HTMLIsBlock (such
// as a branch). On the other hand, if that single item has a font change
// applied to it, then we still do need to open the paragraph.
//
// Obviously, this is very fragile. The main reason we need to do this is
// because of branches, e.g., a branch that contains an entire new section.
// We do not really want to wrap that whole thing in a <div>...</div>.
bool special_case = false;
Inset const *specinset = par->size() == 1 ? par->getInset(0) : 0;
if (specinset && !specinset->getLayout().htmlisblock()) { // TODO: Convert htmlisblock to a DocBook parameter?
Layout const &style = par->layout();
FontInfo const first_font = style.labeltype == LABEL_MANUAL ?
style.labelfont : style.font;
FontInfo const our_font =
par->getFont(buf.masterBuffer()->params(), 0,
text.outerFont(distance(begin, par))).fontInfo();
if (first_font == our_font)
special_case = true;
}
if (first_font == our_font)
special_case = true;
}
// Plain layouts must be ignored.
if (!special_case && buf.params().documentClass().isPlainLayout(lay) && !runparams.docbook_force_pars)
special_case = true;
// TODO: Could get rid of this with a DocBook equivalent to htmlisblock?
if (!special_case && par->size() == 1 && par->getInset(0)) {
Inset const * firstInset = par->getInset(0);
// Plain layouts must be ignored.
if (!special_case && buf.params().documentClass().isPlainLayout(lay) && !runparams.docbook_force_pars)
special_case = true;
// TODO: Could get rid of this with a DocBook equivalent to htmlisblock?
if (!special_case && par->size() == 1 && par->getInset(0)) {
Inset const * firstInset = par->getInset(0);
// Floats cannot be in paragraphs.
special_case = to_ascii(firstInset->layoutName()).substr(0, 6) == "Float:";
// Floats cannot be in paragraphs.
special_case = to_ascii(firstInset->layoutName()).substr(0, 6) == "Float:";
// Bibliographies cannot be in paragraphs.
if (!special_case && firstInset->asInsetCommand())
special_case = firstInset->asInsetCommand()->params().getCmdName() == "bibtex";
// Bibliographies cannot be in paragraphs.
if (!special_case && firstInset->asInsetCommand())
special_case = firstInset->asInsetCommand()->params().getCmdName() == "bibtex";
// Equations do not deserve their own paragraph (DocBook allows them outside paragraphs).
if (!special_case && firstInset->asInsetMath())
special_case = true;
// Equations do not deserve their own paragraph (DocBook allows them outside paragraphs).
if (!special_case && firstInset->asInsetMath())
special_case = true;
// ERTs are in comments, not paragraphs.
if (!special_case && firstInset->lyxCode() == lyx::ERT_CODE)
special_case = true;
// ERTs are in comments, not paragraphs.
if (!special_case && firstInset->lyxCode() == lyx::ERT_CODE)
special_case = true;
// Listings should not get into their own paragraph.
if (!special_case && firstInset->lyxCode() == lyx::LISTINGS_CODE)
special_case = true;
}
// Listings should not get into their own paragraph.
if (!special_case && firstInset->lyxCode() == lyx::LISTINGS_CODE)
special_case = true;
}
bool const open_par = runparams.docbook_make_pars
&& (!runparams.docbook_in_par || par != pbegin)
&& !special_case;
bool const open_par = runparams.docbook_make_pars
&& (!runparams.docbook_in_par || par != pbegin)
&& !special_case;
// We want to issue the closing tag if either:
// (i) We opened it, and either docbook_in_par is false,
// or we're not in the last paragraph, anyway.
// (ii) We didn't open it and docbook_in_par is true,
// but we are in the first par, and there is a next par.
ParagraphList::const_iterator nextpar = par;
++nextpar;
bool const close_par =
((open_par && (!runparams.docbook_in_par || nextpar != pend))
|| (!open_par && runparams.docbook_in_par && par == pbegin && nextpar != pend));
// We want to issue the closing tag if either:
// (i) We opened it, and either docbook_in_par is false,
// or we're not in the last paragraph, anyway.
// (ii) We didn't open it and docbook_in_par is true,
// but we are in the first par, and there is a next par.
ParagraphList::const_iterator nextpar = par;
++nextpar;
bool const close_par =
((open_par && (!runparams.docbook_in_par || nextpar != pend))
|| (!open_par && runparams.docbook_in_par && par == pbegin && nextpar != pend));
if (open_par) {
openParTag(xs, lay);
}
if (open_par) {
openParTag(xs, lay);
}
par->simpleDocBookOnePar(buf, xs, runparams, text.outerFont(distance(begin, par)), open_par, close_par, 0);
par->simpleDocBookOnePar(buf, xs, runparams, text.outerFont(distance(begin, par)), open_par, close_par, 0);
if (close_par) {
closeTag(xs, lay);
xs << xml::CR();
}
}
return pend;
if (close_par) {
closeTag(xs, lay);
xs << xml::CR();
}
}
return pend;
}
bool isNormalEnv(Layout const &lay) {
return lay.latextype == LATEX_ENVIRONMENT
|| lay.latextype == LATEX_BIB_ENVIRONMENT;
bool isNormalEnv(Layout const &lay)
{
return lay.latextype == LATEX_ENVIRONMENT
|| lay.latextype == LATEX_BIB_ENVIRONMENT;
}
ParagraphList::const_iterator makeEnvironment(Buffer const &buf,
XMLStream &xs,
OutputParams const &runparams,
Text const &text,
ParagraphList::const_iterator const &pbegin,
ParagraphList::const_iterator const &pend) {
ParagraphList::const_iterator makeEnvironment(
Buffer const &buf,
XMLStream &xs,
OutputParams const &runparams,
Text const &text,
ParagraphList::const_iterator const & pbegin,
ParagraphList::const_iterator const & pend)
{
ParagraphList::const_iterator const begin = text.paragraphs().begin();
ParagraphList::const_iterator par = pbegin;
Layout const &bstyle = par->layout();
@ -429,10 +443,10 @@ ParagraphList::const_iterator makeEnvironment(Buffer const &buf,
Counters & cnts = buf.masterBuffer()->params().documentClass().counters();
docstring const & cntr = style.counter;
if (!style.counter.empty()
&& (par == pbegin || !isNormalEnv(style))
&& cnts.hasCounter(cntr)
)
cnts.step(cntr, OutputUpdate);
&& (par == pbegin || !isNormalEnv(style))
&& cnts.hasCounter(cntr)
)
cnts.step(cntr, OutputUpdate);
ParagraphList::const_iterator send;
// Actual content of this paragraph.
@ -553,35 +567,39 @@ ParagraphList::const_iterator makeEnvironment(Buffer const &buf,
}
void makeCommand(Buffer const &buf,
XMLStream &xs,
OutputParams const &runparams,
Text const &text,
ParagraphList::const_iterator const &pbegin) {
Layout const &style = pbegin->layout();
if (!style.counter.empty())
buf.masterBuffer()->params().
documentClass().counters().step(style.counter, OutputUpdate);
void makeCommand(
Buffer const & buf,
XMLStream & xs,
OutputParams const & runparams,
Text const & text,
ParagraphList::const_iterator const & pbegin)
{
Layout const &style = pbegin->layout();
if (!style.counter.empty())
buf.masterBuffer()->params().
documentClass().counters().step(style.counter, OutputUpdate);
// No need for labels, as they are handled by DocBook tags.
// No need for labels, as they are handled by DocBook tags.
openParTag(xs, style);
openParTag(xs, style);
ParagraphList::const_iterator const begin = text.paragraphs().begin();
pbegin->simpleDocBookOnePar(buf, xs, runparams,
text.outerFont(distance(begin, pbegin)));
closeTag(xs, style);
xs << xml::CR();
ParagraphList::const_iterator const begin = text.paragraphs().begin();
pbegin->simpleDocBookOnePar(buf, xs, runparams,
text.outerFont(distance(begin, pbegin)));
closeTag(xs, style);
xs << xml::CR();
}
pair<ParagraphList::const_iterator, ParagraphList::const_iterator> makeAny(Text const &text,
Buffer const &buf,
XMLStream &xs,
OutputParams const &ourparams,
ParagraphList::const_iterator par,
ParagraphList::const_iterator send,
ParagraphList::const_iterator pend) {
Layout const &style = par->layout();
pair<ParagraphList::const_iterator, ParagraphList::const_iterator> makeAny(
Text const &text,
Buffer const &buf,
XMLStream &xs,
OutputParams const &ourparams,
ParagraphList::const_iterator par,
ParagraphList::const_iterator send,
ParagraphList::const_iterator pend)
{
Layout const & style = par->layout();
switch (style.latextype) {
case LATEX_COMMAND: {
@ -696,13 +714,15 @@ bool hasAbstractBetween(ParagraphList const &paragraphs, pit_type const bpitAbst
}
pit_type generateDocBookParagraphWithoutSectioning(Text const &text,
Buffer const &buf,
XMLStream &xs,
OutputParams const &runparams,
ParagraphList const &paragraphs,
pit_type bpit,
pit_type epit) {
pit_type generateDocBookParagraphWithoutSectioning(
Text const & text,
Buffer const & buf,
XMLStream & xs,
OutputParams const & runparams,
ParagraphList const & paragraphs,
pit_type bpit,
pit_type epit)
{
auto par = paragraphs.iterator_at(bpit);
auto lastStartedPar = par;
ParagraphList::const_iterator send;
@ -719,14 +739,16 @@ pit_type generateDocBookParagraphWithoutSectioning(Text const &text,
}
void outputDocBookInfo(Text const &text,
Buffer const &buf,
XMLStream &xs,
OutputParams const &runparams,
ParagraphList const &paragraphs,
DocBookInfoTag const &info,
pit_type bpitAbstract,
pit_type const epitAbstract) {
void outputDocBookInfo(
Text const & text,
Buffer const & buf,
XMLStream & xs,
OutputParams const & runparams,
ParagraphList const & paragraphs,
DocBookInfoTag const & info,
pit_type bpitAbstract,
pit_type const epitAbstract)
{
// Consider everything between bpitAbstract and epitAbstract (excluded) as paragraphs for the abstract.
// Use bpitAbstract >= epitAbstract to indicate there is no abstract.
@ -773,11 +795,13 @@ void outputDocBookInfo(Text const &text,
}
void docbookFirstParagraphs(Text const &text,
Buffer const &buf,
XMLStream &xs,
OutputParams const &runparams,
pit_type epit) {
void docbookFirstParagraphs(
Text const &text,
Buffer const &buf,
XMLStream &xs,
OutputParams const &runparams,
pit_type epit)
{
// Handle the beginning of the document, supposing it has sections.
// Major role: output the first <info> tag.
@ -793,15 +817,17 @@ bool isParagraphEmpty(const Paragraph &par)
InsetList const &insets = par.insetList();
size_t insetsLength = distance(insets.begin(), insets.end());
bool hasParagraphOnlyNote = insetsLength == 1 && insets.get(0) && insets.get(0)->asInsetCollapsible() &&
dynamic_cast<InsetNote *>(insets.get(0));
dynamic_cast<InsetNote *>(insets.get(0));
return hasParagraphOnlyNote;
}
void docbookSimpleAllParagraphs(Text const &text,
Buffer const &buf,
XMLStream &xs,
OutputParams const &runparams) {
void docbookSimpleAllParagraphs(
Text const & text,
Buffer const & buf,
XMLStream & xs,
OutputParams const & runparams)
{
// Handle the document, supposing it has no sections (i.e. a "simple" document).
// First, the <info> tag.
@ -836,25 +862,25 @@ void docbookSimpleAllParagraphs(Text const &text,
void docbookParagraphs(Text const &text,
Buffer const &buf,
XMLStream &xs,
OutputParams const &runparams) {
Buffer const &buf,
XMLStream &xs,
OutputParams const &runparams) {
ParagraphList const &paragraphs = text.paragraphs();
if (runparams.par_begin == runparams.par_end) {
runparams.par_begin = 0;
runparams.par_end = paragraphs.size();
runparams.par_begin = 0;
runparams.par_end = paragraphs.size();
}
pit_type bpit = runparams.par_begin;
pit_type const epit = runparams.par_end;
LASSERT(bpit < epit,
{
xs << XMLStream::ESCAPE_NONE << "<!-- DocBook output error! -->\n";
return;
});
{
xs << XMLStream::ESCAPE_NONE << "<!-- DocBook output error! -->\n";
return;
});
ParagraphList::const_iterator const pend =
(epit == (int) paragraphs.size()) ?
paragraphs.end() : paragraphs.iterator_at(epit);
(epit == (int) paragraphs.size()) ?
paragraphs.end() : paragraphs.iterator_at(epit);
std::stack<std::pair<int, string>> headerLevels; // Used to determine when to open/close sections: store the depth
// of the section and the tag that was used to open it.
@ -893,13 +919,13 @@ void docbookParagraphs(Text const &text,
// Think about adding <section> and/or </section>s.
const bool isLayoutSectioning = style.category() == from_utf8("Sectioning");
if (isLayoutSectioning) {
int level = style.toclevel;
int level = style.toclevel;
// Need to close a previous section if it has the same level or a higher one (close <section> if opening a <h2>
// after a <h2>, <h3>, <h4>, <h5> or <h6>). More examples:
// - current: h2; back: h1; do not close any <section>
// - current: h1; back: h2; close two <section> (first the <h2>, then the <h1>, so a new <h1> can come)
while (!headerLevels.empty() && level <= headerLevels.top().first) {
// Need to close a previous section if it has the same level or a higher one (close <section> if opening a <h2>
// after a <h2>, <h3>, <h4>, <h5> or <h6>). More examples:
// - current: h2; back: h1; do not close any <section>
// - current: h1; back: h2; close two <section> (first the <h2>, then the <h1>, so a new <h1> can come)
while (!headerLevels.empty() && level <= headerLevels.top().first) {
int stackLevel = headerLevels.top().first;
docstring stackTag = from_utf8("</" + headerLevels.top().second + ">");
headerLevels.pop();
@ -907,15 +933,15 @@ void docbookParagraphs(Text const &text,
// Output the tag only if it corresponds to a legit section.
if (stackLevel != Layout::NOT_IN_TOC)
xs << XMLStream::ESCAPE_NONE << stackTag << xml::CR();
}
}
// Open the new section: first push it onto the stack, then output it in DocBook.
string sectionTag = (currentlyInAppendix && style.docbooksectiontag() == "chapter") ?
"appendix" : style.docbooksectiontag();
headerLevels.push(std::make_pair(level, sectionTag));
// Open the new section: first push it onto the stack, then output it in DocBook.
string sectionTag = (currentlyInAppendix && style.docbooksectiontag() == "chapter") ?
"appendix" : style.docbooksectiontag();
headerLevels.push(std::make_pair(level, sectionTag));
// Some sectioning-like elements should not be output (such as FrontMatter).
if (level != Layout::NOT_IN_TOC) {
// Some sectioning-like elements should not be output (such as FrontMatter).
if (level != Layout::NOT_IN_TOC) {
// Look for a label in the title, i.e. a InsetLabel as a child.
docstring id = docstring();
for (pos_type i = 0; i < par->size(); ++i) {
@ -940,7 +966,7 @@ void docbookParagraphs(Text const &text,
tag += from_utf8(">");
xs << XMLStream::ESCAPE_NONE << tag;
xs << xml::CR();
}
}
}
// Close all sections before the bibliography.

430
src/xml.h
View File

@ -38,93 +38,93 @@ struct CR;
class XMLStream {
public:
///
explicit XMLStream(odocstream & os): os_(os), escape_(ESCAPE_ALL) {}
///
odocstream & os() { return os_; }
///
// int & tab() { return tab_; }
/// closes any font tags that are eligible to be closed,
/// i.e., last on the tag_stack_.
/// \return false if there are open font tags we could not close.
/// because they are "blocked" by open non-font tags on the stack.
bool closeFontTags();
/// sets a mark so we know what tags to close at the end.
/// normally called at the start of a paragraph.
void startDivision(bool keep_empty);
/// clears the mark set by previous method.
/// there should not be any other tags open before it on the stack,
/// but if there are, we will close them.
void endDivision();
///
XMLStream & operator<<(docstring const &);
///
XMLStream & operator<<(const char *);
///
XMLStream & operator<<(char_type);
///
XMLStream & operator<<(int);
///
XMLStream & operator<<(char);
///
XMLStream & operator<<(xml::StartTag const &);
///
XMLStream & operator<<(xml::EndTag const &);
///
XMLStream & operator<<(xml::CompTag const &);
///
XMLStream & operator<<(xml::ParTag const &);
///
XMLStream & operator<<(xml::FontTag const &);
///
XMLStream & operator<<(xml::CR const &);
///
enum EscapeSettings {
ESCAPE_NONE,
ESCAPE_AND, // meaning &
ESCAPE_ALL // meaning <, >, &, at present
};
/// Sets what we are going to escape on the NEXT write.
/// Everything is reset for the next time.
XMLStream & operator<<(EscapeSettings);
/// This routine is for debugging the tag stack, etc. Code
/// for it is disabled by default, however, so you will need
/// to enable it if you want to use it.
void dumpTagStack(std::string const & msg);
///
bool isTagOpen(xml::StartTag const &, int maxdepth = -1) const;
///
bool isTagOpen(xml::EndTag const &, int maxdepth = -1) const;
///
bool isTagPending(xml::StartTag const &, int maxdepth = -1) const;
///
explicit XMLStream(odocstream & os): os_(os), escape_(ESCAPE_ALL) {}
///
odocstream & os() { return os_; }
///
// int & tab() { return tab_; }
/// closes any font tags that are eligible to be closed,
/// i.e., last on the tag_stack_.
/// \return false if there are open font tags we could not close.
/// because they are "blocked" by open non-font tags on the stack.
bool closeFontTags();
/// sets a mark so we know what tags to close at the end.
/// normally called at the start of a paragraph.
void startDivision(bool keep_empty);
/// clears the mark set by previous method.
/// there should not be any other tags open before it on the stack,
/// but if there are, we will close them.
void endDivision();
///
XMLStream & operator<<(docstring const &);
///
XMLStream & operator<<(const char *);
///
XMLStream & operator<<(char_type);
///
XMLStream & operator<<(int);
///
XMLStream & operator<<(char);
///
XMLStream & operator<<(xml::StartTag const &);
///
XMLStream & operator<<(xml::EndTag const &);
///
XMLStream & operator<<(xml::CompTag const &);
///
XMLStream & operator<<(xml::ParTag const &);
///
XMLStream & operator<<(xml::FontTag const &);
///
XMLStream & operator<<(xml::CR const &);
///
enum EscapeSettings {
ESCAPE_NONE,
ESCAPE_AND, // meaning &
ESCAPE_ALL // meaning <, >, &, at present
};
/// Sets what we are going to escape on the NEXT write.
/// Everything is reset for the next time.
XMLStream & operator<<(EscapeSettings);
/// This routine is for debugging the tag stack, etc. Code
/// for it is disabled by default, however, so you will need
/// to enable it if you want to use it.
void dumpTagStack(std::string const & msg);
///
bool isTagOpen(xml::StartTag const &, int maxdepth = -1) const;
///
bool isTagOpen(xml::EndTag const &, int maxdepth = -1) const;
///
bool isTagPending(xml::StartTag const &, int maxdepth = -1) const;
private:
///
void clearTagDeque();
///
void writeError(std::string const &) const;
///
void writeError(docstring const &) const;
///
odocstream & os_;
///
EscapeSettings escape_;
// What we would really like to do here is simply use a
// deque<StartTag>. But we want to store both StartTags and
// sub-classes thereof on this stack, which means we run into the
// so-called polymorphic class problem with the STL. We therefore have
// to use a deque<StartTag *>, which leads to the question who will
// own these pointers and how they will be deleted, so we use shared
// pointers.
///
typedef std::shared_ptr<xml::StartTag> TagPtr;
typedef std::deque<TagPtr> TagDeque;
///
template <typename T>
TagPtr makeTagPtr(T const & tag) { return std::make_shared<T>(tag); }
///
TagDeque pending_tags_;
///
TagDeque tag_stack_;
///
void clearTagDeque();
///
void writeError(std::string const &) const;
///
void writeError(docstring const &) const;
///
odocstream & os_;
///
EscapeSettings escape_;
// What we would really like to do here is simply use a
// deque<StartTag>. But we want to store both StartTags and
// sub-classes thereof on this stack, which means we run into the
// so-called polymorphic class problem with the STL. We therefore have
// to use a deque<StartTag *>, which leads to the question who will
// own these pointers and how they will be deleted, so we use shared
// pointers.
///
typedef std::shared_ptr<xml::StartTag> TagPtr;
typedef std::deque<TagPtr> TagDeque;
///
template <typename T>
TagPtr makeTagPtr(T const & tag) { return std::make_shared<T>(tag); }
///
TagDeque pending_tags_;
///
TagDeque tag_stack_;
};
namespace xml {
@ -160,69 +160,69 @@ struct EndFontTag;
/// be escaped before being passed to the constructor.
struct StartTag
{
///
explicit StartTag(std::string const & tag) : tag_(from_ascii(tag)), keepempty_(false) {}
///
explicit StartTag(docstring const & tag) : tag_(tag), keepempty_(false) {}
///
explicit StartTag(docstring const & tag, docstring const & attr,
bool keepempty = false)
: tag_(tag), attr_(attr), keepempty_(keepempty) {}
///
explicit StartTag(std::string const & tag, std::string const & attr,
bool keepempty = false)
: tag_(from_ascii(tag)), attr_(from_ascii(attr)), keepempty_(keepempty) {}
///
explicit StartTag(std::string const & tag, docstring const & attr,
bool keepempty = false)
: tag_(from_ascii(tag)), attr_(attr), keepempty_(keepempty) {}
///
virtual ~StartTag() {}
/// <tag_ attr_>
virtual docstring writeTag() const;
/// </tag_>
virtual docstring writeEndTag() const;
///
virtual FontTag const * asFontTag() const { return nullptr; }
///
virtual bool operator==(StartTag const & rhs) const
{ return tag_ == rhs.tag_; }
///
virtual bool operator!=(StartTag const & rhs) const
{ return !(*this == rhs); }
///
virtual bool operator==(FontTag const & rhs) const;
///
docstring tag_;
///
docstring attr_;
/// whether to keep things like "<tag></tag>" or discard them
/// you would want this for td, e.g, but maybe not for a div
bool keepempty_;
///
explicit StartTag(std::string const & tag) : tag_(from_ascii(tag)), keepempty_(false) {}
///
explicit StartTag(docstring const & tag) : tag_(tag), keepempty_(false) {}
///
explicit StartTag(docstring const & tag, docstring const & attr,
bool keepempty = false)
: tag_(tag), attr_(attr), keepempty_(keepempty) {}
///
explicit StartTag(std::string const & tag, std::string const & attr,
bool keepempty = false)
: tag_(from_ascii(tag)), attr_(from_ascii(attr)), keepempty_(keepempty) {}
///
explicit StartTag(std::string const & tag, docstring const & attr,
bool keepempty = false)
: tag_(from_ascii(tag)), attr_(attr), keepempty_(keepempty) {}
///
virtual ~StartTag() {}
/// <tag_ attr_>
virtual docstring writeTag() const;
/// </tag_>
virtual docstring writeEndTag() const;
///
virtual FontTag const * asFontTag() const { return nullptr; }
///
virtual bool operator==(StartTag const & rhs) const
{ return tag_ == rhs.tag_; }
///
virtual bool operator!=(StartTag const & rhs) const
{ return !(*this == rhs); }
///
virtual bool operator==(FontTag const & rhs) const;
///
docstring tag_;
///
docstring attr_;
/// whether to keep things like "<tag></tag>" or discard them
/// you would want this for td, e.g, but maybe not for a div
bool keepempty_;
};
///
struct EndTag
{
///
explicit EndTag(std::string tag) : tag_(from_ascii(tag)) {}
///
explicit EndTag(docstring tag) : tag_(tag) {}
///
virtual ~EndTag() {}
/// </tag_>
virtual docstring writeEndTag() const;
///
bool operator==(StartTag const & rhs) const
{ return tag_ == rhs.tag_; }
///
bool operator!=(StartTag const & rhs) const
{ return !(*this == rhs); }
///
virtual EndFontTag const * asFontTag() const { return 0; }
///
docstring tag_;
///
explicit EndTag(std::string tag) : tag_(from_ascii(tag)) {}
///
explicit EndTag(docstring tag) : tag_(tag) {}
///
virtual ~EndTag() {}
/// </tag_>
virtual docstring writeEndTag() const;
///
bool operator==(StartTag const & rhs) const
{ return tag_ == rhs.tag_; }
///
bool operator!=(StartTag const & rhs) const
{ return !(*this == rhs); }
///
virtual EndFontTag const * asFontTag() const { return 0; }
///
docstring tag_;
};
@ -231,18 +231,18 @@ struct EndTag
/// be escaped before being passed to the constructor.
struct CompTag
{
///
explicit CompTag(std::string const & tag)
: tag_(tag) {}
///
explicit CompTag(std::string const & tag, std::string const & attr)
: tag_(tag), attr_(attr) {}
/// <tag_ attr_ />
docstring writeTag() const;
///
std::string tag_;
///
std::string attr_;
///
explicit CompTag(std::string const & tag)
: tag_(tag) {}
///
explicit CompTag(std::string const & tag, std::string const & attr)
: tag_(tag), attr_(attr) {}
/// <tag_ attr_ />
docstring writeTag() const;
///
std::string tag_;
///
std::string attr_;
};
@ -250,84 +250,84 @@ struct CompTag
/// parid is only used for HTML output; XML is supposed to use attr for this.
struct ParTag : public StartTag
{
///
explicit ParTag(std::string const & tag, const std::string & attr): StartTag(tag, from_utf8(attr)) {}
///
~ParTag() {}
///
explicit ParTag(std::string const & tag, const std::string & attr): StartTag(tag, from_utf8(attr)) {}
///
~ParTag() {}
};
///
enum FontTypes {
// ranges
FT_EMPH,
FT_NOUN,
FT_UBAR,
FT_DBAR,
FT_WAVE,
FT_SOUT,
FT_XOUT,
// bold
FT_BOLD,
// shapes
FT_UPRIGHT,
FT_ITALIC,
FT_SLANTED,
FT_SMALLCAPS,
// families
FT_ROMAN,
FT_SANS,
FT_TYPE,
// sizes
FT_SIZE_TINY,
FT_SIZE_SCRIPT,
FT_SIZE_FOOTNOTE,
FT_SIZE_SMALL,
FT_SIZE_NORMAL,
FT_SIZE_LARGE,
FT_SIZE_LARGER,
FT_SIZE_LARGEST,
FT_SIZE_HUGE,
FT_SIZE_HUGER,
FT_SIZE_INCREASE,
FT_SIZE_DECREASE
// ranges
FT_EMPH,
FT_NOUN,
FT_UBAR,
FT_DBAR,
FT_WAVE,
FT_SOUT,
FT_XOUT,
// bold
FT_BOLD,
// shapes
FT_UPRIGHT,
FT_ITALIC,
FT_SLANTED,
FT_SMALLCAPS,
// families
FT_ROMAN,
FT_SANS,
FT_TYPE,
// sizes
FT_SIZE_TINY,
FT_SIZE_SCRIPT,
FT_SIZE_FOOTNOTE,
FT_SIZE_SMALL,
FT_SIZE_NORMAL,
FT_SIZE_LARGE,
FT_SIZE_LARGER,
FT_SIZE_LARGEST,
FT_SIZE_HUGE,
FT_SIZE_HUGER,
FT_SIZE_INCREASE,
FT_SIZE_DECREASE
// When updating this list, also update fontToTag in both output_docbook.cpp and output_xhtml.cpp,
// fontToRole in output_docbook.cpp, and fontToAttribute in output_xhtml.cpp.
// When updating this list, also update fontToTag in both output_docbook.cpp and output_xhtml.cpp,
// fontToRole in output_docbook.cpp, and fontToAttribute in output_xhtml.cpp.
};
///
struct FontTag : public StartTag
{
///
FontTag(docstring const & tag, FontTypes type): StartTag(tag), font_type_(type) {}
///
FontTag(std::string const & tag, FontTypes type): StartTag(from_utf8(tag)), font_type_(type) {}
///
FontTag(docstring const & tag, docstring const & attr, FontTypes type): StartTag(tag, attr), font_type_(type) {}
///
FontTag(std::string const & tag, std::string const & attr, FontTypes type): StartTag(from_utf8(tag), from_utf8(attr)), font_type_(type) {}
///
FontTag const * asFontTag() const override { return this; }
///
bool operator==(StartTag const &) const override;
///
FontTypes font_type_;
///
FontTag(docstring const & tag, FontTypes type): StartTag(tag), font_type_(type) {}
///
FontTag(std::string const & tag, FontTypes type): StartTag(from_utf8(tag)), font_type_(type) {}
///
FontTag(docstring const & tag, docstring const & attr, FontTypes type): StartTag(tag, attr), font_type_(type) {}
///
FontTag(std::string const & tag, std::string const & attr, FontTypes type): StartTag(from_utf8(tag), from_utf8(attr)), font_type_(type) {}
///
FontTag const * asFontTag() const override { return this; }
///
bool operator==(StartTag const &) const override;
///
FontTypes font_type_;
};
///
struct EndFontTag : public EndTag
{
///
EndFontTag(docstring const & tag, FontTypes type): EndTag(tag), font_type_(type) {}
///
EndFontTag(std::string const & tag, FontTypes type): EndTag(from_utf8(tag)), font_type_(type) {}
///
EndFontTag const * asFontTag() const override { return this; }
///
FontTypes font_type_;
///
EndFontTag(docstring const & tag, FontTypes type): EndTag(tag), font_type_(type) {}
///
EndFontTag(std::string const & tag, FontTypes type): EndTag(from_utf8(tag)), font_type_(type) {}
///
EndFontTag const * asFontTag() const override { return this; }
///
FontTypes font_type_;
};