Rename XHTMLStream to XMLStream, move it to another file, and prepare for DocBook adoption.

xml.cpp/h also merges functionalities from sgml.cpp/h.
This commit is contained in:
Thibaut Cuvelier 2019-05-10 01:35:40 +02:00 committed by Pavel Sanda
parent 9cec35697a
commit a6b07608d8
97 changed files with 1922 additions and 1883 deletions

View File

@ -125,7 +125,7 @@ SOURCES += \
../../src/Server.cpp \ ../../src/Server.cpp \
../../src/ServerSocket.cpp \ ../../src/ServerSocket.cpp \
../../src/Session.cpp \ ../../src/Session.cpp \
../../src/sgml.cpp \ ../../src/xml.cpp \
../../src/Spacing.cpp \ ../../src/Spacing.cpp \
../../src/TexRow.cpp \ ../../src/TexRow.cpp \
../../src/TexStream.cpp \ ../../src/TexStream.cpp \
@ -476,7 +476,7 @@ HEADERS += \
../../src/Server.h \ ../../src/Server.h \
../../src/ServerSocket.h \ ../../src/ServerSocket.h \
../../src/Session.h \ ../../src/Session.h \
../../src/sgml.h \ ../../src/xml.h \
../../src/Spacing.h \ ../../src/Spacing.h \
../../src/TexRow.h \ ../../src/TexRow.h \
../../src/TexStream.h \ ../../src/TexStream.h \

View File

@ -1159,7 +1159,7 @@ docstring BibTeXInfo::getValueForKey(string const & oldkey, Buffer const & buf,
} }
if (cleanit) if (cleanit)
ret = html::cleanAttr(ret); ret = xml::cleanAttr(ret);
// make sure it is not too big // make sure it is not too big
support::truncateWithEllipsis(ret, maxsize); support::truncateWithEllipsis(ret, maxsize);

View File

@ -57,7 +57,7 @@
#include "PDFOptions.h" #include "PDFOptions.h"
#include "Session.h" #include "Session.h"
#include "SpellChecker.h" #include "SpellChecker.h"
#include "sgml.h" #include "xml.h"
#include "texstream.h" #include "texstream.h"
#include "TexRow.h" #include "TexRow.h"
#include "Text.h" #include "Text.h"
@ -2195,13 +2195,13 @@ Buffer::ExportStatus Buffer::writeDocBookSource(odocstream & os, string const &
params().documentClass().counters().reset(); params().documentClass().counters().reset();
sgml::openTag(os, top); xml::openTag(os, top);
os << '\n'; os << '\n';
try { try {
docbookParagraphs(text(), *this, os, runparams); docbookParagraphs(text(), *this, os, runparams);
} }
catch (ConversionException const &) { return ExportKilled; } catch (ConversionException const &) { return ExportKilled; }
sgml::closeTag(os, top_element); xml::closeTag(os, top_element);
} }
return ExportSuccess; return ExportSuccess;
} }
@ -2259,7 +2259,7 @@ Buffer::ExportStatus Buffer::writeLyXHTMLSource(odocstream & os,
os << "<title>" os << "<title>"
<< (doctitle.empty() ? << (doctitle.empty() ?
from_ascii("LyX Document") : from_ascii("LyX Document") :
html::htmlize(doctitle, XHTMLStream::ESCAPE_ALL)) xml::xmlize(doctitle, XMLStream::ESCAPE_ALL))
<< "</title>\n"; << "</title>\n";
docstring styles = features.getTClassHTMLPreamble(); docstring styles = features.getTClassHTMLPreamble();
@ -2325,7 +2325,7 @@ Buffer::ExportStatus Buffer::writeLyXHTMLSource(odocstream & os,
bool const output_body_tag = (output != IncludedFile); bool const output_body_tag = (output != IncludedFile);
if (output_body_tag) if (output_body_tag)
os << "<body dir=\"auto\">\n"; os << "<body dir=\"auto\">\n";
XHTMLStream xs(os); XMLStream xs(os);
if (output != IncludedFile) if (output != IncludedFile)
// if we're an included file, the counters are in the master. // if we're an included file, the counters are in the master.
params().documentClass().counters().reset(); params().documentClass().counters().reset();
@ -4123,7 +4123,7 @@ unique_ptr<TexRow> Buffer::getSourceCode(odocstream & os, string const & format,
par.write(ods, params(), dt); par.write(ods, params(), dt);
os << from_utf8(ods.str()); os << from_utf8(ods.str());
} else if (runparams.flavor == OutputParams::HTML) { } else if (runparams.flavor == OutputParams::HTML) {
XHTMLStream xs(os); XMLStream xs(os);
setMathFlavor(runparams); setMathFlavor(runparams);
xhtmlParagraphs(text(), *this, xs, runparams); xhtmlParagraphs(text(), *this, xs, runparams);
} else if (runparams.flavor == OutputParams::TEXT) { } else if (runparams.flavor == OutputParams::TEXT) {

View File

@ -1,7 +1,7 @@
# This file is part of LyX, the document processor. # This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING. # Licence details can be found in the file COPYING.
# #
# Copyright (c) 2006-2011 Peter Kümmel, <syntheticpp@gmx.net> # Copyright (c) 2006-2011 Peter K<EFBFBD>mmel, <syntheticpp@gmx.net>
# #
project(${_lyx}) project(${_lyx})

View File

@ -172,7 +172,7 @@ SOURCEFILESCORE = \
RowPainter.cpp \ RowPainter.cpp \
Server.cpp \ Server.cpp \
ServerSocket.cpp \ ServerSocket.cpp \
sgml.cpp \ xml.cpp \
Session.cpp \ Session.cpp \
Spacing.cpp \ Spacing.cpp \
TexRow.cpp \ TexRow.cpp \
@ -279,7 +279,7 @@ HEADERFILESCORE = \
Server.h \ Server.h \
ServerSocket.h \ ServerSocket.h \
Session.h \ Session.h \
sgml.h \ xml.h \
Spacing.h \ Spacing.h \
SpellChecker.h \ SpellChecker.h \
TexRow.h \ TexRow.h \

View File

@ -37,9 +37,10 @@
#include "OutputParams.h" #include "OutputParams.h"
#include "output_latex.h" #include "output_latex.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "output_docbook.h"
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
#include "SpellChecker.h" #include "SpellChecker.h"
#include "sgml.h" #include "xml.h"
#include "texstream.h" #include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
#include "TexRow.h" #include "TexRow.h"
@ -2930,7 +2931,7 @@ bool Paragraph::emptyTag() const
} }
string Paragraph::getID(Buffer const & buf, OutputParams const & runparams) string Paragraph::getID(Buffer const &, OutputParams const &)
const const
{ {
for (pos_type i = 0; i < size(); ++i) { for (pos_type i = 0; i < size(); ++i) {
@ -2939,7 +2940,7 @@ string Paragraph::getID(Buffer const & buf, OutputParams const & runparams)
if (lyx_code == LABEL_CODE) { if (lyx_code == LABEL_CODE) {
InsetLabel const * const il = static_cast<InsetLabel const *>(inset); InsetLabel const * const il = static_cast<InsetLabel const *>(inset);
docstring const & id = il->getParam("name"); docstring const & id = il->getParam("name");
return "id='" + to_utf8(sgml::cleanID(buf, runparams, id)) + "'"; return "id='" + to_utf8(xml::cleanID(id)) + "'";
} }
} }
} }
@ -2958,14 +2959,14 @@ pos_type Paragraph::firstWordDocBook(odocstream & os, OutputParams const & runpa
char_type c = d->text_[i]; char_type c = d->text_[i];
if (c == ' ') if (c == ' ')
break; break;
os << sgml::escapeChar(c); os << xml::escapeChar(c, XMLStream::ESCAPE_ALL);
} }
} }
return i; return i;
} }
pos_type Paragraph::firstWordLyXHTML(XHTMLStream & xs, OutputParams const & runparams) pos_type Paragraph::firstWordLyXHTML(XMLStream & xs, OutputParams const & runparams)
const const
{ {
pos_type i; pos_type i;
@ -3038,7 +3039,7 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
if (style.pass_thru) if (style.pass_thru)
os.put(c); os.put(c);
else else
os << sgml::escapeChar(c); os << xml::escapeChar(c, XMLStream::EscapeSettings::ESCAPE_ALL);
} }
font_old = font.fontInfo(); font_old = font.fontInfo();
} }
@ -3055,27 +3056,29 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf,
namespace { namespace {
void doFontSwitch(vector<html::FontTag> & tagsToOpen,
vector<html::EndFontTag> & tagsToClose, void doFontSwitchXHTML(vector<xml::FontTag> & tagsToOpen,
bool & flag, FontState curstate, html::FontTypes type) vector<xml::EndFontTag> & tagsToClose,
bool & flag, FontState curstate, xml::FontTypes type)
{ {
if (curstate == FONT_ON) { if (curstate == FONT_ON) {
tagsToOpen.push_back(html::FontTag(type)); tagsToOpen.push_back(xhtmlStartFontTag(type));
flag = true; flag = true;
} else if (flag) { } else if (flag) {
tagsToClose.push_back(html::EndFontTag(type)); tagsToClose.push_back(xhtmlEndFontTag(type));
flag = false; flag = false;
} }
} }
} // namespace
} // anonymous namespace
docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf, docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
XHTMLStream & xs, XMLStream & xs,
OutputParams const & runparams, OutputParams const & runparams,
Font const & outerfont, Font const & outerfont,
bool start_paragraph, bool close_paragraph, bool start_paragraph, bool close_paragraph,
pos_type initial) const pos_type initial) const
{ {
docstring retval; docstring retval;
@ -3110,8 +3113,8 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
string const default_family = string const default_family =
buf.masterBuffer()->params().fonts_default_family; buf.masterBuffer()->params().fonts_default_family;
vector<html::FontTag> tagsToOpen; vector<xml::FontTag> tagsToOpen;
vector<html::EndFontTag> tagsToClose; vector<xml::EndFontTag> tagsToClose;
// parsing main loop // parsing main loop
for (pos_type i = initial; i < size(); ++i) { for (pos_type i = initial; i < size(); ++i) {
@ -3124,260 +3127,260 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
// emphasis // emphasis
FontState curstate = font.fontInfo().emph(); FontState curstate = font.fontInfo().emph();
if (font_old.emph() != curstate) if (font_old.emph() != curstate)
doFontSwitch(tagsToOpen, tagsToClose, emph_flag, curstate, html::FT_EMPH); doFontSwitchXHTML(tagsToOpen, tagsToClose, emph_flag, curstate, xml::FT_EMPH);
// noun // noun
curstate = font.fontInfo().noun(); curstate = font.fontInfo().noun();
if (font_old.noun() != curstate) if (font_old.noun() != curstate)
doFontSwitch(tagsToOpen, tagsToClose, noun_flag, curstate, html::FT_NOUN); doFontSwitchXHTML(tagsToOpen, tagsToClose, noun_flag, curstate, xml::FT_NOUN);
// underbar // underbar
curstate = font.fontInfo().underbar(); curstate = font.fontInfo().underbar();
if (font_old.underbar() != curstate) if (font_old.underbar() != curstate)
doFontSwitch(tagsToOpen, tagsToClose, ubar_flag, curstate, html::FT_UBAR); doFontSwitchXHTML(tagsToOpen, tagsToClose, ubar_flag, curstate, xml::FT_UBAR);
// strikeout // strikeout
curstate = font.fontInfo().strikeout(); curstate = font.fontInfo().strikeout();
if (font_old.strikeout() != curstate) if (font_old.strikeout() != curstate)
doFontSwitch(tagsToOpen, tagsToClose, sout_flag, curstate, html::FT_SOUT); doFontSwitchXHTML(tagsToOpen, tagsToClose, sout_flag, curstate, xml::FT_SOUT);
// xout // xout
curstate = font.fontInfo().xout(); curstate = font.fontInfo().xout();
if (font_old.xout() != curstate) if (font_old.xout() != curstate)
doFontSwitch(tagsToOpen, tagsToClose, xout_flag, curstate, html::FT_XOUT); doFontSwitchXHTML(tagsToOpen, tagsToClose, xout_flag, curstate, xml::FT_XOUT);
// double underbar // double underbar
curstate = font.fontInfo().uuline(); curstate = font.fontInfo().uuline();
if (font_old.uuline() != curstate) if (font_old.uuline() != curstate)
doFontSwitch(tagsToOpen, tagsToClose, dbar_flag, curstate, html::FT_DBAR); doFontSwitchXHTML(tagsToOpen, tagsToClose, dbar_flag, curstate, xml::FT_DBAR);
// wavy line // wavy line
curstate = font.fontInfo().uwave(); curstate = font.fontInfo().uwave();
if (font_old.uwave() != curstate) if (font_old.uwave() != curstate)
doFontSwitch(tagsToOpen, tagsToClose, wave_flag, curstate, html::FT_WAVE); doFontSwitchXHTML(tagsToOpen, tagsToClose, wave_flag, curstate, xml::FT_WAVE);
// bold // bold
// a little hackish, but allows us to reuse what we have. // a little hackish, but allows us to reuse what we have.
curstate = (font.fontInfo().series() == BOLD_SERIES ? FONT_ON : FONT_OFF); curstate = (font.fontInfo().series() == BOLD_SERIES ? FONT_ON : FONT_OFF);
if (font_old.series() != font.fontInfo().series()) if (font_old.series() != font.fontInfo().series())
doFontSwitch(tagsToOpen, tagsToClose, bold_flag, curstate, html::FT_BOLD); doFontSwitchXHTML(tagsToOpen, tagsToClose, bold_flag, curstate, xml::FT_BOLD);
// Font shape // Font shape
curr_fs = font.fontInfo().shape(); curr_fs = font.fontInfo().shape();
FontShape old_fs = font_old.shape(); FontShape old_fs = font_old.shape();
if (old_fs != curr_fs) { if (old_fs != curr_fs) {
if (shap_flag) { if (shap_flag) {
switch (old_fs) { switch (old_fs) {
case ITALIC_SHAPE: case ITALIC_SHAPE:
tagsToClose.push_back(html::EndFontTag(html::FT_ITALIC)); tagsToClose.push_back(xml::EndFontTag(fontToHtmlTag(xml::FT_ITALIC), xml::FT_ITALIC));
break; break;
case SLANTED_SHAPE: case SLANTED_SHAPE:
tagsToClose.push_back(html::EndFontTag(html::FT_SLANTED)); tagsToClose.push_back(xml::EndFontTag(fontToHtmlTag(xml::FT_SLANTED), xml::FT_SLANTED));
break; break;
case SMALLCAPS_SHAPE: case SMALLCAPS_SHAPE:
tagsToClose.push_back(html::EndFontTag(html::FT_SMALLCAPS)); tagsToClose.push_back(xml::EndFontTag(fontToHtmlTag(xml::FT_SMALLCAPS), xml::FT_SMALLCAPS));
break; break;
case UP_SHAPE: case UP_SHAPE:
case INHERIT_SHAPE: case INHERIT_SHAPE:
break; break;
default: default:
// the other tags are for internal use // the other tags are for internal use
LATTEST(false); LATTEST(false);
break; break;
} }
shap_flag = false; shap_flag = false;
} }
switch (curr_fs) { switch (curr_fs) {
case ITALIC_SHAPE: case ITALIC_SHAPE:
tagsToOpen.push_back(html::FontTag(html::FT_ITALIC)); tagsToOpen.push_back(xml::FontTag(fontToHtmlTag(xml::FT_ITALIC), xml::FT_ITALIC));
shap_flag = true; shap_flag = true;
break; break;
case SLANTED_SHAPE: case SLANTED_SHAPE:
tagsToOpen.push_back(html::FontTag(html::FT_SLANTED)); tagsToOpen.push_back(xml::FontTag(fontToHtmlTag(xml::FT_SLANTED), xml::FT_SLANTED));
shap_flag = true; shap_flag = true;
break; break;
case SMALLCAPS_SHAPE: case SMALLCAPS_SHAPE:
tagsToOpen.push_back(html::FontTag(html::FT_SMALLCAPS)); tagsToOpen.push_back(xml::FontTag(fontToHtmlTag(xml::FT_SMALLCAPS), xml::FT_SMALLCAPS));
shap_flag = true; shap_flag = true;
break; break;
case UP_SHAPE: case UP_SHAPE:
case INHERIT_SHAPE: case INHERIT_SHAPE:
break; break;
default: default:
// the other tags are for internal use // the other tags are for internal use
LATTEST(false); LATTEST(false);
break; break;
} }
} }
// Font family // Font family
curr_fam = font.fontInfo().family(); curr_fam = font.fontInfo().family();
FontFamily old_fam = font_old.family(); FontFamily old_fam = font_old.family();
if (old_fam != curr_fam) { if (old_fam != curr_fam) {
if (faml_flag) { if (faml_flag) {
switch (old_fam) { switch (old_fam) {
case ROMAN_FAMILY: case ROMAN_FAMILY:
tagsToClose.push_back(html::EndFontTag(html::FT_ROMAN)); tagsToClose.push_back(xml::EndFontTag(fontToHtmlTag(xml::FT_ROMAN), xml::FT_ROMAN));
break; break;
case SANS_FAMILY: case SANS_FAMILY:
tagsToClose.push_back(html::EndFontTag(html::FT_SANS)); tagsToClose.push_back(xml::EndFontTag(fontToHtmlTag(xml::FT_SANS), xml::FT_SANS));
break; break;
case TYPEWRITER_FAMILY: case TYPEWRITER_FAMILY:
tagsToClose.push_back(html::EndFontTag(html::FT_TYPE)); tagsToClose.push_back(xml::EndFontTag(fontToHtmlTag(xml::FT_TYPE), xml::FT_TYPE));
break; break;
case INHERIT_FAMILY: case INHERIT_FAMILY:
break; break;
default: default:
// the other tags are for internal use // the other tags are for internal use
LATTEST(false); LATTEST(false);
break; break;
} }
faml_flag = false; faml_flag = false;
} }
switch (curr_fam) { switch (curr_fam) {
case ROMAN_FAMILY: case ROMAN_FAMILY:
// we will treat a "default" font family as roman, since we have // we will treat a "default" font family as roman, since we have
// no other idea what to do. // no other idea what to do.
if (default_family != "rmdefault" && default_family != "default") { if (default_family != "rmdefault" && default_family != "default") {
tagsToOpen.push_back(html::FontTag(html::FT_ROMAN)); tagsToOpen.push_back(xml::FontTag(fontToHtmlTag(xml::FT_ROMAN), xml::FT_ROMAN));
faml_flag = true; faml_flag = true;
} }
break; break;
case SANS_FAMILY: case SANS_FAMILY:
if (default_family != "sfdefault") { if (default_family != "sfdefault") {
tagsToOpen.push_back(html::FontTag(html::FT_SANS)); tagsToOpen.push_back(xml::FontTag(fontToHtmlTag(xml::FT_SANS), xml::FT_SANS));
faml_flag = true; faml_flag = true;
} }
break; break;
case TYPEWRITER_FAMILY: case TYPEWRITER_FAMILY:
if (default_family != "ttdefault") { if (default_family != "ttdefault") {
tagsToOpen.push_back(html::FontTag(html::FT_TYPE)); tagsToOpen.push_back(xml::FontTag(fontToHtmlTag(xml::FT_TYPE), xml::FT_TYPE));
faml_flag = true; faml_flag = true;
} }
break; break;
case INHERIT_FAMILY: case INHERIT_FAMILY:
break; break;
default: default:
// the other tags are for internal use // the other tags are for internal use
LATTEST(false); LATTEST(false);
break; break;
} }
} }
// Font size // Font size
curr_size = font.fontInfo().size(); curr_size = font.fontInfo().size();
FontSize old_size = font_old.size(); FontSize old_size = font_old.size();
if (old_size != curr_size) { if (old_size != curr_size) {
if (size_flag) { if (size_flag) {
switch (old_size) { switch (old_size) {
case TINY_SIZE: case TINY_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_TINY)); tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_TINY), xml::FT_SIZE_TINY);
break; break;
case SCRIPT_SIZE: case SCRIPT_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_SCRIPT)); tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_SCRIPT), xml::FT_SIZE_SCRIPT);
break; break;
case FOOTNOTE_SIZE: case FOOTNOTE_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_FOOTNOTE)); tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_FOOTNOTE), xml::FT_SIZE_FOOTNOTE);
break; break;
case SMALL_SIZE: case SMALL_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_SMALL)); tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_SMALL), xml::FT_SIZE_SMALL);
break; break;
case LARGE_SIZE: case LARGE_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_LARGE)); tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_LARGE), xml::FT_SIZE_LARGE);
break; break;
case LARGER_SIZE: case LARGER_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_LARGER)); tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_LARGER), xml::FT_SIZE_LARGER);
break; break;
case LARGEST_SIZE: case LARGEST_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_LARGEST)); tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_LARGEST), xml::FT_SIZE_LARGEST);
break; break;
case HUGE_SIZE: case HUGE_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_HUGE)); tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_HUGE), xml::FT_SIZE_HUGE);
break; break;
case HUGER_SIZE: case HUGER_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_HUGER)); tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_HUGER), xml::FT_SIZE_HUGER);
break; break;
case INCREASE_SIZE: case INCREASE_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_INCREASE)); tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_INCREASE), xml::FT_SIZE_INCREASE);
break; break;
case DECREASE_SIZE: case DECREASE_SIZE:
tagsToClose.push_back(html::EndFontTag(html::FT_SIZE_DECREASE)); tagsToClose.emplace_back(fontToHtmlTag(xml::FT_SIZE_DECREASE), xml::FT_SIZE_DECREASE);
break; break;
case INHERIT_SIZE: case INHERIT_SIZE:
case NORMAL_SIZE: case NORMAL_SIZE:
break; break;
default: default:
// the other tags are for internal use // the other tags are for internal use
LATTEST(false); LATTEST(false);
break; break;
} }
size_flag = false; size_flag = false;
} }
switch (curr_size) { switch (curr_size) {
case TINY_SIZE: case TINY_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_TINY)); tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_TINY), xml::FT_SIZE_TINY);
size_flag = true; size_flag = true;
break; break;
case SCRIPT_SIZE: case SCRIPT_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_SCRIPT)); tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_SCRIPT), xml::FT_SIZE_SCRIPT);
size_flag = true; size_flag = true;
break; break;
case FOOTNOTE_SIZE: case FOOTNOTE_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_FOOTNOTE)); tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_FOOTNOTE), xml::FT_SIZE_FOOTNOTE);
size_flag = true; size_flag = true;
break; break;
case SMALL_SIZE: case SMALL_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_SMALL)); tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_SMALL), xml::FT_SIZE_SMALL);
size_flag = true; size_flag = true;
break; break;
case LARGE_SIZE: case LARGE_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_LARGE)); tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_LARGE), xml::FT_SIZE_LARGE);
size_flag = true; size_flag = true;
break; break;
case LARGER_SIZE: case LARGER_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_LARGER)); tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_LARGER), xml::FT_SIZE_LARGER);
size_flag = true; size_flag = true;
break; break;
case LARGEST_SIZE: case LARGEST_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_LARGEST)); tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_LARGEST), xml::FT_SIZE_LARGEST);
size_flag = true; size_flag = true;
break; break;
case HUGE_SIZE: case HUGE_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_HUGE)); tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_HUGE), xml::FT_SIZE_HUGE);
size_flag = true; size_flag = true;
break; break;
case HUGER_SIZE: case HUGER_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_HUGER)); tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_HUGER), xml::FT_SIZE_HUGER);
size_flag = true; size_flag = true;
break; break;
case INCREASE_SIZE: case INCREASE_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_INCREASE)); tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_INCREASE), xml::FT_SIZE_INCREASE);
size_flag = true; size_flag = true;
break; break;
case DECREASE_SIZE: case DECREASE_SIZE:
tagsToOpen.push_back(html::FontTag(html::FT_SIZE_DECREASE)); tagsToOpen.emplace_back(fontToHtmlTag(xml::FT_SIZE_DECREASE), xml::FT_SIZE_DECREASE);
size_flag = true; size_flag = true;
break; break;
case NORMAL_SIZE: case INHERIT_SIZE:
case INHERIT_SIZE: case NORMAL_SIZE:
break; break;
default: default:
// the other tags are for internal use // the other tags are for internal use
LATTEST(false); LATTEST(false);
break; break;
} }
} }
// FIXME XHTML // FIXME XHTML
// Other such tags? What about the other text ranges? // Other such tags? What about the other text ranges?
vector<html::EndFontTag>::const_iterator cit = tagsToClose.begin(); vector<xml::EndFontTag>::const_iterator cit = tagsToClose.begin();
vector<html::EndFontTag>::const_iterator cen = tagsToClose.end(); vector<xml::EndFontTag>::const_iterator cen = tagsToClose.end();
for (; cit != cen; ++cit) for (; cit != cen; ++cit)
xs << *cit; xs << *cit;
vector<html::FontTag>::const_iterator sit = tagsToOpen.begin(); vector<xml::FontTag>::const_iterator sit = tagsToOpen.begin();
vector<html::FontTag>::const_iterator sen = tagsToOpen.end(); vector<xml::FontTag>::const_iterator sen = tagsToOpen.end();
for (; sit != sen; ++sit) for (; sit != sen; ++sit)
xs << *sit; xs << *sit;
@ -3399,7 +3402,7 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
char_type c = getUChar(buf.masterBuffer()->params(), char_type c = getUChar(buf.masterBuffer()->params(),
runparams, i); runparams, i);
if (c == ' ' && (style.free_spacing || runparams.free_spacing)) if (c == ' ' && (style.free_spacing || runparams.free_spacing))
xs << XHTMLStream::ESCAPE_NONE << "&nbsp;"; xs << XMLStream::ESCAPE_NONE << "&nbsp;";
else else
xs << c; xs << c;
} }

View File

@ -50,7 +50,7 @@ class PainterInfo;
class ParagraphParameters; class ParagraphParameters;
class TocBackend; class TocBackend;
class WordLangTuple; class WordLangTuple;
class XHTMLStream; class XMLStream;
class otexstream; class otexstream;
class FontSpan { class FontSpan {
@ -203,7 +203,7 @@ public:
pos_type firstWordDocBook(odocstream & os, OutputParams const & runparams) const; pos_type firstWordDocBook(odocstream & os, OutputParams const & runparams) const;
/// Output the first word of a paragraph, return the position where it left. /// Output the first word of a paragraph, return the position where it left.
pos_type firstWordLyXHTML(XHTMLStream & xs, OutputParams const & runparams) const; pos_type firstWordLyXHTML(XMLStream & xs, OutputParams const & runparams) const;
/// Writes to stream the docbook representation /// Writes to stream the docbook representation
void simpleDocBookOnePar(Buffer const & buf, void simpleDocBookOnePar(Buffer const & buf,
@ -211,10 +211,11 @@ public:
OutputParams const & runparams, OutputParams const & runparams,
Font const & outerfont, Font const & outerfont,
pos_type initial = 0) const; pos_type initial = 0) const;
/// \return any material that has had to be deferred until after the /// \return any material that has had to be deferred until after the
/// paragraph has closed. /// paragraph has closed.
docstring simpleLyXHTMLOnePar(Buffer const & buf, docstring simpleLyXHTMLOnePar(Buffer const & buf,
XHTMLStream & xs, XMLStream & xs,
OutputParams const & runparams, OutputParams const & runparams,
Font const & outerfont, Font const & outerfont,
bool start_paragraph = true, bool start_paragraph = true,

View File

@ -31,7 +31,7 @@
#include "LyXRC.h" #include "LyXRC.h"
#include "Row.h" #include "Row.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "sgml.h" #include "xml.h"
#include "TextClass.h" #include "TextClass.h"
#include "TexRow.h" #include "TexRow.h"

View File

@ -472,7 +472,7 @@ int Inset::docbook(odocstream &, OutputParams const &) const
} }
docstring Inset::xhtml(XHTMLStream & xs, OutputParams const &) const docstring Inset::xhtml(XMLStream & xs, OutputParams const &) const
{ {
xs << "[[Inset: " << from_ascii(insetName(lyxCode())) << "]]"; xs << "[[Inset: " << from_ascii(insetName(lyxCode())) << "]]";
return docstring(); return docstring();

View File

@ -64,7 +64,7 @@ class ParIterator;
class Text; class Text;
class TocBackend; class TocBackend;
class TocList; class TocList;
class XHTMLStream; class XMLStream;
class otexstream; class otexstream;
namespace graphics { class PreviewLoader; } namespace graphics { class PreviewLoader; }
@ -343,11 +343,11 @@ public:
/// docbook output /// docbook output
virtual int docbook(odocstream & os, OutputParams const &) const; virtual int docbook(odocstream & os, OutputParams const &) const;
/// XHTML output /// XHTML output
/// the inset is expected to write XHTML to the XHTMLStream /// the inset is expected to write XHTML to the XMLStream
/// \return any "deferred" material that should be written outside the /// \return any "deferred" material that should be written outside the
/// normal stream, and which will in fact be written after the current /// normal stream, and which will in fact be written after the current
/// paragraph closes. this is appropriate e.g. for floats. /// paragraph closes. this is appropriate e.g. for floats.
virtual docstring xhtml(XHTMLStream & xs, OutputParams const &) const; virtual docstring xhtml(XMLStream &, OutputParams const &) const;
/// Writes a string representation of the inset to the odocstream. /// Writes a string representation of the inset to the odocstream.
/// This one should be called when you want the whole contents of /// This one should be called when you want the whole contents of

View File

@ -56,7 +56,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const { return 0; } int docbook(odocstream &, OutputParams const &) const { return 0; }
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const docstring xhtml(XMLStream &, OutputParams const &) const
{ return docstring(); } { return docstring(); }
/// ///
void write(std::ostream & os) const; void write(std::ostream & os) const;

View File

@ -343,7 +343,7 @@ void InsetBibitem::updateBuffer(ParIterator const & it, UpdateType utype, bool c
} }
docstring InsetBibitem::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetBibitem::xhtml(XMLStream & xs, OutputParams const &) const
{ {
// FIXME XHTML // FIXME XHTML
// XHTML 1.1 doesn't have the "name" attribute for <a>, so we have to use // XHTML 1.1 doesn't have the "name" attribute for <a>, so we have to use
@ -352,11 +352,11 @@ docstring InsetBibitem::xhtml(XHTMLStream & xs, OutputParams const &) const
// handle jumping to ids. If we don't do that, though, we can just put the // handle jumping to ids. If we don't do that, though, we can just put the
// id into the span tag. // id into the span tag.
string const attrs = string const attrs =
"id='LyXCite-" + to_utf8(html::cleanAttr(getParam("key"))) + "'"; "id='LyXCite-" + to_utf8(xml::cleanAttr(getParam("key"))) + "'";
xs << html::CompTag("a", attrs); xs << xml::CompTag("a", attrs);
xs << html::StartTag("span", "class='bibitemlabel'"); xs << xml::StartTag("span", "class='bibitemlabel'");
xs << bibLabel(); xs << bibLabel();
xs << html::EndTag("span"); xs << xml::EndTag("span");
return docstring(); return docstring();
} }

View File

@ -58,7 +58,7 @@ public:
int plaintext(odocstringstream &, OutputParams const &, int plaintext(odocstringstream &, OutputParams const &,
size_t max_length = INT_MAX) const; size_t max_length = INT_MAX) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void collectBibKeys(InsetIterator const &, support::FileNameList &) const; void collectBibKeys(InsetIterator const &, support::FileNameList &) const;
/// update the counter of this inset /// update the counter of this inset

View File

@ -28,6 +28,7 @@
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "output_latex.h" #include "output_latex.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "xml.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "PDFOptions.h" #include "PDFOptions.h"
#include "texstream.h" #include "texstream.h"
@ -1008,7 +1009,7 @@ int InsetBibtex::plaintext(odocstringstream & os,
refoutput += "[" + entry.label() + "] "; refoutput += "[" + entry.label() + "] ";
// FIXME Right now, we are calling BibInfo::getInfo on the key, // FIXME Right now, we are calling BibInfo::getInfo on the key,
// which will give us all the cross-referenced info. But for every // which will give us all the cross-referenced info. But for every
// entry, so there's a lot of repitition. This should be fixed. // entry, so there's a lot of repetition. This should be fixed.
refoutput += bibinfo.getInfo(entry.key(), buffer(), ci) + "\n\n"; refoutput += bibinfo.getInfo(entry.key(), buffer(), ci) + "\n\n";
} }
os << refoutput; os << refoutput;
@ -1019,7 +1020,7 @@ int InsetBibtex::plaintext(odocstringstream & os,
// FIXME // FIXME
// docstring InsetBibtex::entriesAsXHTML(vector<docstring> const & entries) // docstring InsetBibtex::entriesAsXHTML(vector<docstring> const & entries)
// And then here just: entriesAsXHTML(buffer().masterBibInfo().citedEntries()) // And then here just: entriesAsXHTML(buffer().masterBibInfo().citedEntries())
docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetBibtex::xhtml(XMLStream & xs, OutputParams const &) const
{ {
BiblioInfo const & bibinfo = buffer().masterBibInfo(); BiblioInfo const & bibinfo = buffer().masterBibInfo();
bool const all_entries = getParam("btprint") == "btPrintAll"; bool const all_entries = getParam("btprint") == "btPrintAll";
@ -1034,10 +1035,10 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
ci.richtext = true; ci.richtext = true;
ci.max_key_size = UINT_MAX; ci.max_key_size = UINT_MAX;
xs << html::StartTag("h2", "class='bibtex'") xs << xml::StartTag("h2", "class='bibtex'")
<< reflabel << reflabel
<< html::EndTag("h2") << xml::EndTag("h2")
<< html::StartTag("div", "class='bibtex'"); << xml::StartTag("div", "class='bibtex'");
// Now we loop over the entries // Now we loop over the entries
vector<docstring>::const_iterator vit = cites.begin(); vector<docstring>::const_iterator vit = cites.begin();
@ -1049,27 +1050,27 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
BibTeXInfo const & entry = biit->second; BibTeXInfo const & entry = biit->second;
string const attr = "class='bibtexentry' id='LyXCite-" string const attr = "class='bibtexentry' id='LyXCite-"
+ to_utf8(html::cleanAttr(entry.key())) + "'"; + to_utf8(xml::cleanAttr(entry.key())) + "'";
xs << html::StartTag("div", attr); xs << xml::StartTag("div", attr);
// don't print labels if we're outputting all entries // don't print labels if we're outputting all entries
if (!all_entries) { if (!all_entries) {
xs << html::StartTag("span", "class='bibtexlabel'") xs << xml::StartTag("span", "class='bibtexlabel'")
<< entry.label() << entry.label()
<< html::EndTag("span"); << xml::EndTag("span");
} }
// FIXME Right now, we are calling BibInfo::getInfo on the key, // FIXME Right now, we are calling BibInfo::getInfo on the key,
// which will give us all the cross-referenced info. But for every // which will give us all the cross-referenced info. But for every
// entry, so there's a lot of repitition. This should be fixed. // entry, so there's a lot of repitition. This should be fixed.
xs << html::StartTag("span", "class='bibtexinfo'") xs << xml::StartTag("span", "class='bibtexinfo'")
<< XHTMLStream::ESCAPE_AND << XMLStream::ESCAPE_AND
<< bibinfo.getInfo(entry.key(), buffer(), ci) << bibinfo.getInfo(entry.key(), buffer(), ci)
<< html::EndTag("span") << xml::EndTag("span")
<< html::EndTag("div") << xml::EndTag("div")
<< html::CR(); << xml::CR();
} }
xs << html::EndTag("div"); xs << xml::EndTag("div");
return docstring(); return docstring();
} }

View File

@ -64,7 +64,9 @@ public:
/// ///
void validate(LaTeXFeatures &) const; void validate(LaTeXFeatures &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
///
docstring docbook(XMLStream &, OutputParams const &) const;
/// ///
std::string contextMenuName() const; std::string contextMenuName() const;
//@} //@}

View File

@ -721,7 +721,7 @@ int InsetBox::docbook(odocstream & os, OutputParams const & runparams) const
} }
docstring InsetBox::xhtml(XHTMLStream & xs, OutputParams const & runparams) const docstring InsetBox::xhtml(XMLStream & xs, OutputParams const & runparams) const
{ {
// construct attributes // construct attributes
string attrs = "class='" + params_.type + "'"; string attrs = "class='" + params_.type + "'";
@ -737,10 +737,10 @@ docstring InsetBox::xhtml(XHTMLStream & xs, OutputParams const & runparams) cons
if (!style.empty()) if (!style.empty())
attrs += " style='" + style + "'"; attrs += " style='" + style + "'";
xs << html::StartTag("div", attrs); xs << xml::StartTag("div", attrs);
XHTMLOptions const opts = InsetText::WriteLabel | InsetText::WriteInnerTag; XHTMLOptions const opts = InsetText::WriteLabel | InsetText::WriteInnerTag;
docstring defer = InsetText::insetAsXHTML(xs, runparams, opts); docstring defer = InsetText::insetAsXHTML(xs, runparams, opts);
xs << html::EndTag("div"); xs << xml::EndTag("div");
xs << defer; xs << defer;
return docstring(); return docstring();
} }

View File

@ -137,7 +137,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void validate(LaTeXFeatures &) const; void validate(LaTeXFeatures &) const;
/// ///

View File

@ -333,7 +333,7 @@ int InsetBranch::docbook(odocstream & os,
} }
docstring InsetBranch::xhtml(XHTMLStream & xs, OutputParams const & rp) const docstring InsetBranch::xhtml(XMLStream & xs, OutputParams const & rp) const
{ {
if (producesOutput()) { if (producesOutput()) {
OutputParams newrp = rp; OutputParams newrp = rp;

View File

@ -78,7 +78,7 @@ private:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void toString(odocstream &) const; void toString(odocstream &) const;
/// ///

View File

@ -302,7 +302,7 @@ int InsetCaption::docbook(odocstream & os,
} }
docstring InsetCaption::xhtml(XHTMLStream & xs, OutputParams const & rp) const docstring InsetCaption::xhtml(XMLStream & xs, OutputParams const & rp) const
{ {
if (rp.html_disable_captions) if (rp.html_disable_captions)
return docstring(); return docstring();
@ -317,9 +317,9 @@ docstring InsetCaption::xhtml(XHTMLStream & xs, OutputParams const & rp) const
else else
attr = attr + " class='" + our_class + "'"; attr = attr + " class='" + our_class + "'";
} }
xs << html::StartTag(tag, attr); xs << xml::StartTag(tag, attr);
docstring def = getCaptionAsHTML(xs, rp); docstring def = getCaptionAsHTML(xs, rp);
xs << html::EndTag(tag); xs << xml::EndTag(tag);
return def; return def;
} }
@ -364,7 +364,7 @@ int InsetCaption::getCaptionAsPlaintext(odocstream & os,
} }
docstring InsetCaption::getCaptionAsHTML(XHTMLStream & xs, docstring InsetCaption::getCaptionAsHTML(XMLStream & xs,
OutputParams const & runparams) const OutputParams const & runparams) const
{ {
xs << full_label_ << ' '; xs << full_label_ << ' ';

View File

@ -31,7 +31,7 @@ public:
/// return the caption text /// return the caption text
int getCaptionAsPlaintext(odocstream & os, OutputParams const &) const; int getCaptionAsPlaintext(odocstream & os, OutputParams const &) const;
/// return the caption text as HTML /// return the caption text as HTML
docstring getCaptionAsHTML(XHTMLStream & os, OutputParams const &) const; docstring getCaptionAsHTML(XMLStream & os, OutputParams const &) const;
/// ///
std::string contextMenuName() const; std::string contextMenuName() const;
private: private:
@ -78,7 +78,7 @@ private:
/// ///
int docbook(odocstream & os, OutputParams const & runparams) const; int docbook(odocstream & os, OutputParams const & runparams) const;
/// ///
docstring xhtml(XHTMLStream & os, OutputParams const & runparams) const; docstring xhtml(XMLStream & os, OutputParams const & runparams) const;
/// ///
void addToToc(DocIterator const & di, bool output_active, UpdateType utype, void addToToc(DocIterator const & di, bool output_active, UpdateType utype,
TocBackend & backend) const; TocBackend & backend) const;

View File

@ -87,11 +87,11 @@ docstring InsetCaptionable::getCaptionHTML(OutputParams const & runparams) const
return docstring(); return docstring();
odocstringstream ods; odocstringstream ods;
XHTMLStream xs(ods); XMLStream xs(ods);
docstring def = ins->getCaptionAsHTML(xs, runparams); docstring def = ins->getCaptionAsHTML(xs, runparams);
if (!def.empty()) if (!def.empty())
// should already have been escaped // should already have been escaped
xs << XHTMLStream::ESCAPE_NONE << def << '\n'; xs << XMLStream::ESCAPE_NONE << def << '\n';
return ods.str(); return ods.str();
} }

View File

@ -322,8 +322,8 @@ inline docstring wrapCitation(docstring const & key,
return content; return content;
// we have to do the escaping here, because we will ultimately // we have to do the escaping here, because we will ultimately
// write this as a raw string, so as not to escape the tags. // write this as a raw string, so as not to escape the tags.
return "<a href='#LyXCite-" + html::cleanAttr(key) + "'>" + return "<a href='#LyXCite-" + xml::cleanAttr(key) + "'>" +
html::htmlize(content, XHTMLStream::ESCAPE_ALL) + "</a>"; xml::xmlize(content, XMLStream::ESCAPE_ALL) + "</a>";
} }
} // anonymous namespace } // anonymous namespace
@ -554,14 +554,14 @@ int InsetCitation::docbook(odocstream & os, OutputParams const &) const
} }
docstring InsetCitation::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetCitation::xhtml(XMLStream & xs, OutputParams const &) const
{ {
string const & cmd = getCmdName(); string const & cmd = getCmdName();
if (cmd == "nocite") if (cmd == "nocite")
return docstring(); return docstring();
// have to output this raw, because generateLabel() will include tags // have to output this raw, because generateLabel() will include tags
xs << XHTMLStream::ESCAPE_NONE << generateLabel(true); xs << XMLStream::ESCAPE_NONE << generateLabel(true);
return docstring(); return docstring();
} }

View File

@ -58,7 +58,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void toString(odocstream &) const; void toString(odocstream &) const;
/// ///

View File

@ -17,7 +17,7 @@
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "sgml.h" #include "xml.h"
#include "texstream.h" #include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
@ -194,7 +194,7 @@ int InsetCounter::docbook(odocstream &, OutputParams const &) const
} }
docstring InsetCounter::xhtml(XHTMLStream &, OutputParams const &) const docstring InsetCounter::xhtml(XMLStream &, OutputParams const &) const
{ {
// Here, we need to track counter values ourselves, // Here, we need to track counter values ourselves,
// since unlike in the LaTeX case, there is no external // since unlike in the LaTeX case, there is no external

View File

@ -41,7 +41,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void toString(odocstream &) const; void toString(odocstream &) const;
/// ///

View File

@ -183,7 +183,7 @@ string InsetERT::params2string(CollapseStatus status)
} }
docstring InsetERT::xhtml(XHTMLStream &, OutputParams const &) const docstring InsetERT::xhtml(XMLStream &, OutputParams const &) const
{ {
return docstring(); return docstring();
} }

View File

@ -54,7 +54,7 @@ private:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void validate(LaTeXFeatures &) const {} void validate(LaTeXFeatures &) const {}
/// should paragraph indendation be omitted in any case? /// should paragraph indendation be omitted in any case?

View File

@ -33,6 +33,7 @@
#include "output_latex.h" #include "output_latex.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "texstream.h" #include "texstream.h"
#include "xml.h"
#include "TocBackend.h" #include "TocBackend.h"
#include "frontends/alert.h" #include "frontends/alert.h"
@ -789,7 +790,7 @@ int InsetExternal::docbook(odocstream & os,
} }
docstring InsetExternal::xhtml(XHTMLStream & xs, docstring InsetExternal::xhtml(XMLStream & xs,
OutputParams const & runparams) const OutputParams const & runparams) const
{ {
bool const external_in_tmpdir = !runparams.nice; bool const external_in_tmpdir = !runparams.nice;
@ -804,7 +805,7 @@ docstring InsetExternal::xhtml(XHTMLStream & xs,
if (buffer().isClone() && buffer().isExporting()) if (buffer().isClone() && buffer().isExporting())
throw ConversionException(); throw ConversionException();
} }
xs << XHTMLStream::ESCAPE_NONE << ods.str(); xs << XMLStream::ESCAPE_NONE << ods.str();
return docstring(); return docstring();
} }

View File

@ -149,7 +149,7 @@ public:
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// For now, this does nothing. Someone who knows about this /// For now, this does nothing. Someone who knows about this
/// should see what needs doing for XHTML output. /// should see what needs doing for XHTML output.
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// Update needed features for this inset. /// Update needed features for this inset.
void validate(LaTeXFeatures & features) const; void validate(LaTeXFeatures & features) const;
/// ///

View File

@ -11,6 +11,7 @@
*/ */
#include <config.h> #include <config.h>
#include <xml.h>
#include "InsetFloat.h" #include "InsetFloat.h"
#include "InsetCaption.h" #include "InsetCaption.h"
@ -32,6 +33,7 @@
#include "TexRow.h" #include "TexRow.h"
#include "texstream.h" #include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
#include "InsetList.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/docstream.h" #include "support/docstream.h"
@ -334,7 +336,7 @@ void InsetFloat::validate(LaTeXFeatures & features) const
} }
docstring InsetFloat::xhtml(XHTMLStream & xs, OutputParams const & rp) const docstring InsetFloat::xhtml(XMLStream & xs, OutputParams const & rp) const
{ {
FloatList const & floats = buffer().params().documentClass().floats(); FloatList const & floats = buffer().params().documentClass().floats();
Floating const & ftype = floats.getType(params_.type); Floating const & ftype = floats.getType(params_.type);
@ -342,12 +344,12 @@ docstring InsetFloat::xhtml(XHTMLStream & xs, OutputParams const & rp) const
string const & attr = ftype.htmlAttrib(); string const & attr = ftype.htmlAttrib();
odocstringstream ods; odocstringstream ods;
XHTMLStream newxs(ods); XMLStream newxs(ods);
newxs << html::StartTag(htmltype, attr); newxs << xml::StartTag(htmltype, attr);
InsetText::XHTMLOptions const opts = InsetText::XHTMLOptions const opts =
InsetText::WriteLabel | InsetText::WriteInnerTag; InsetText::WriteLabel | InsetText::WriteInnerTag;
docstring deferred = InsetText::insetAsXHTML(newxs, rp, opts); docstring deferred = InsetText::insetAsXHTML(newxs, rp, opts);
newxs << html::EndTag(htmltype); newxs << xml::EndTag(htmltype);
if (rp.inFloat == OutputParams::NONFLOAT) { if (rp.inFloat == OutputParams::NONFLOAT) {
// In this case, this float needs to be deferred, but we'll put it // In this case, this float needs to be deferred, but we'll put it
@ -358,7 +360,7 @@ docstring InsetFloat::xhtml(XHTMLStream & xs, OutputParams const & rp) const
// we can write to the stream. // we can write to the stream.
// Note that things will already have been escaped, so we do not // Note that things will already have been escaped, so we do not
// want to escape them again. // want to escape them again.
xs << XHTMLStream::ESCAPE_NONE << ods.str(); xs << XMLStream::ESCAPE_NONE << ods.str();
} }
return deferred; return deferred;
} }

View File

@ -101,7 +101,7 @@ private:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
bool insetAllowed(InsetCode) const; bool insetAllowed(InsetCode) const;
/** returns false if, when outputing LaTeX, font changes should /** returns false if, when outputing LaTeX, font changes should

View File

@ -172,7 +172,7 @@ int InsetFloatList::plaintext(odocstringstream & os,
} }
docstring InsetFloatList::xhtml(XHTMLStream &, OutputParams const & op) const { docstring InsetFloatList::xhtml(XMLStream &, OutputParams const & op) const {
FloatList const & floats = buffer().params().documentClass().floats(); FloatList const & floats = buffer().params().documentClass().floats();
FloatList::const_iterator cit = floats[to_ascii(getParam("type"))]; FloatList::const_iterator cit = floats[to_ascii(getParam("type"))];
@ -239,14 +239,14 @@ docstring InsetFloatList::xhtml(XHTMLStream &, OutputParams const & op) const {
// that's how we deal with the fact that we're probably inside a standard // that's how we deal with the fact that we're probably inside a standard
// paragraph, and we don't want to be. // paragraph, and we don't want to be.
odocstringstream ods; odocstringstream ods;
XHTMLStream xs(ods); XMLStream xs(ods);
InsetLayout const & il = getLayout(); InsetLayout const & il = getLayout();
string const & tag = il.htmltag(); string const & tag = il.htmltag();
xs << html::StartTag("div", "class='toc toc-floats'"); xs << xml::StartTag("div", "class='toc toc-floats'");
xs << html::StartTag(tag, tocattr) xs << xml::StartTag(tag, tocattr)
<< toclabel << toclabel
<< html::EndTag(tag); << xml::EndTag(tag);
Toc::const_iterator it = toc->begin(); Toc::const_iterator it = toc->begin();
Toc::const_iterator const en = toc->end(); Toc::const_iterator const en = toc->end();
@ -255,14 +255,14 @@ docstring InsetFloatList::xhtml(XHTMLStream &, OutputParams const & op) const {
continue; continue;
Paragraph const & par = it->dit().innerParagraph(); Paragraph const & par = it->dit().innerParagraph();
string const attr = "class='lyxtoc-floats lyxtoc-" + toctype + "'"; string const attr = "class='lyxtoc-floats lyxtoc-" + toctype + "'";
xs << html::StartTag("div", attr); xs << xml::StartTag("div", attr);
string const parattr = "href='#" + par.magicLabel() + "' class='lyxtoc-floats'"; string const parattr = "href='#" + par.magicLabel() + "' class='lyxtoc-floats'";
xs << html::StartTag("a", parattr) xs << xml::StartTag("a", parattr)
<< it->str() << it->str()
<< html::EndTag("a"); << xml::EndTag("a");
xs << html::EndTag("div"); xs << xml::EndTag("div");
} }
xs << html::EndTag("div"); xs << xml::EndTag("div");
return ods.str(); return ods.str();
} }

View File

@ -45,7 +45,7 @@ public:
int plaintext(odocstringstream & ods, OutputParams const & op, int plaintext(odocstringstream & ods, OutputParams const & op,
size_t max_length = INT_MAX) const; size_t max_length = INT_MAX) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void doDispatch(Cursor & cur, FuncRequest & cmd); void doDispatch(Cursor & cur, FuncRequest & cmd);
/// ///

View File

@ -68,7 +68,7 @@ TODO
#include "Mover.h" #include "Mover.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "sgml.h" #include "xml.h"
#include "texstream.h" #include "texstream.h"
#include "TocBackend.h" #include "TocBackend.h"
@ -107,7 +107,7 @@ namespace Alert = frontend::Alert;
namespace { namespace {
/// Find the most suitable image format for images in \p format /// Find the most suitable image format for images in \p format
/// Note that \p format may be unknown (i. e. an empty string) /// Note that \p format may be unknown (i.e. an empty string)
string findTargetFormat(string const & format, OutputParams const & runparams) string findTargetFormat(string const & format, OutputParams const & runparams)
{ {
// Are we latexing to DVI or PDF? // Are we latexing to DVI or PDF?
@ -177,7 +177,7 @@ void readInsetGraphics(Lexer & lex, Buffer const & buf, bool allowOrigin,
InsetGraphics::InsetGraphics(Buffer * buf) InsetGraphics::InsetGraphics(Buffer * buf)
: Inset(buf), graphic_label(sgml::uniqueID(from_ascii("graph"))), : Inset(buf), graphic_label(xml::uniqueID(from_ascii("graph"))),
graphic_(new RenderGraphic(this)) graphic_(new RenderGraphic(this))
{ {
} }
@ -185,7 +185,7 @@ InsetGraphics::InsetGraphics(Buffer * buf)
InsetGraphics::InsetGraphics(InsetGraphics const & ig) InsetGraphics::InsetGraphics(InsetGraphics const & ig)
: Inset(ig), : Inset(ig),
graphic_label(sgml::uniqueID(from_ascii("graph"))), graphic_label(xml::uniqueID(from_ascii("graph"))),
graphic_(new RenderGraphic(*ig.graphic_, this)) graphic_(new RenderGraphic(*ig.graphic_, this))
{ {
setParams(ig.params()); setParams(ig.params());
@ -502,10 +502,6 @@ docstring InsetGraphics::createDocBookAttributes() const
// Calculate the options part of the command, we must do it to a string // Calculate the options part of the command, we must do it to a string
// stream since we copied the code from createLatexParams() ;-) // stream since we copied the code from createLatexParams() ;-)
// FIXME: av: need to translate spec -> Docbook XSL spec
// (http://www.sagehill.net/docbookxsl/ImageSizing.html)
// Right now it only works with my version of db2latex :-)
odocstringstream options; odocstringstream options;
double const scl = convert<double>(params().scale); double const scl = convert<double>(params().scale);
if (!params().scale.empty() && !float_equal(scl, 0.0, 0.05)) { if (!params().scale.empty() && !float_equal(scl, 0.0, 0.05)) {
@ -942,14 +938,14 @@ static int writeImageObject(char const * format, odocstream & os,
{ {
if (runparams.flavor != OutputParams::XML) if (runparams.flavor != OutputParams::XML)
os << "<![ %output.print." << format os << "<![ %output.print." << format
<< "; [" << endl; << "; [" << endl;
os <<"<imageobject><imagedata fileref=\"&" os <<"<imageobject><imagedata fileref=\"&"
<< graphic_label << graphic_label
<< ";." << ";."
<< format << format
<< "\" " << "\" "
<< attributes; << attributes;
if (runparams.flavor == OutputParams::XML) if (runparams.flavor == OutputParams::XML)
os << " role=\"" << format << "\"/>" ; os << " role=\"" << format << "\"/>" ;
@ -1078,7 +1074,7 @@ string InsetGraphics::prepareHTMLFile(OutputParams const & runparams) const
} }
docstring InsetGraphics::xhtml(XHTMLStream & xs, OutputParams const & op) const docstring InsetGraphics::xhtml(XMLStream & xs, OutputParams const & op) const
{ {
string const output_file = op.dryrun ? string() : prepareHTMLFile(op); string const output_file = op.dryrun ? string() : prepareHTMLFile(op);
@ -1087,7 +1083,7 @@ docstring InsetGraphics::xhtml(XHTMLStream & xs, OutputParams const & op) const
<< params().filename << "' for output. File missing?"); << params().filename << "' for output. File missing?");
string const attr = "src='" + params().filename.absFileName() string const attr = "src='" + params().filename.absFileName()
+ "' alt='image: " + output_file + "'"; + "' alt='image: " + output_file + "'";
xs << html::CompTag("img", attr); xs << xml::CompTag("img", attr);
return docstring(); return docstring();
} }
@ -1115,7 +1111,7 @@ docstring InsetGraphics::xhtml(XHTMLStream & xs, OutputParams const & op) const
string const attr = imgstyle + "src='" + output_file + "' alt='image: " string const attr = imgstyle + "src='" + output_file + "' alt='image: "
+ output_file + "'"; + output_file + "'";
xs << html::CompTag("img", attr); xs << xml::CompTag("img", attr);
return docstring(); return docstring();
} }

View File

@ -80,7 +80,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream & os, OutputParams const &) const; docstring xhtml(XMLStream & os, OutputParams const &) const;
/** Tell LyX what the latex features you need i.e. what latex packages /** Tell LyX what the latex features you need i.e. what latex packages
you need to be included. you need to be included.
*/ */

View File

@ -22,7 +22,7 @@
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "sgml.h" #include "xml.h"
#include "texstream.h" #include "texstream.h"
#include "support/docstream.h" #include "support/docstream.h"
@ -218,20 +218,20 @@ int InsetHyperlink::docbook(odocstream & os, OutputParams const &) const
os << "<ulink url=\"" os << "<ulink url=\""
<< subst(getParam("target"), from_ascii("&"), from_ascii("&amp;")) << subst(getParam("target"), from_ascii("&"), from_ascii("&amp;"))
<< "\">" << "\">"
<< sgml::escapeString(getParam("name")) << xml::escapeString(getParam("name"))
<< "</ulink>"; << "</ulink>";
return 0; return 0;
} }
docstring InsetHyperlink::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetHyperlink::xhtml(XMLStream & xs, OutputParams const &) const
{ {
docstring const & target = docstring const & target =
html::htmlize(getParam("target"), XHTMLStream::ESCAPE_AND); xml::xmlize(getParam("target"), XMLStream::ESCAPE_AND);
docstring const & name = getParam("name"); docstring const & name = getParam("name");
xs << html::StartTag("a", to_utf8("href=\"" + target + "\"")); xs << xml::StartTag("a", to_utf8("href=\"" + target + "\""));
xs << (name.empty() ? target : name); xs << (name.empty() ? target : name);
xs << html::EndTag("a"); xs << xml::EndTag("a");
return docstring(); return docstring();
} }

View File

@ -53,7 +53,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
//@} //@}
/// \name Static public methods obligated for InsetCommand derived classes /// \name Static public methods obligated for InsetCommand derived classes

View File

@ -233,7 +233,7 @@ void InsetIPA::latex(otexstream & os, OutputParams const & runparams_in) const
} }
docstring InsetIPA::xhtml(XHTMLStream & xs, OutputParams const & runparams_in) const docstring InsetIPA::xhtml(XMLStream & xs, OutputParams const & runparams_in) const
{ {
OutputParams runparams(runparams_in); OutputParams runparams(runparams_in);
runparams.inIPA = true; runparams.inIPA = true;

View File

@ -77,7 +77,7 @@ public:
/// ///
void latex(otexstream &, OutputParams const &) const; void latex(otexstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream & xs, OutputParams const &) const; docstring xhtml(XMLStream & xs, OutputParams const &) const;
/// ///
void validate(LaTeXFeatures & features) const; void validate(LaTeXFeatures & features) const;
/// ///

View File

@ -312,7 +312,7 @@ int InsetIPADeco::docbook(odocstream & os, OutputParams const & runparams) const
} }
docstring InsetIPADeco::xhtml(XHTMLStream & xs, OutputParams const & runparams) const docstring InsetIPADeco::xhtml(XMLStream & xs, OutputParams const & runparams) const
{ {
// FIXME: Like in plaintext, the combining characters "&#x361;" (toptiebar) // FIXME: Like in plaintext, the combining characters "&#x361;" (toptiebar)
// or "&#x35c;" (bottomtiebar) would need to be inserted just in the mid // or "&#x35c;" (bottomtiebar) would need to be inserted just in the mid
@ -556,29 +556,29 @@ int InsetIPAChar::docbook(odocstream & /*os*/, OutputParams const &) const
} }
docstring InsetIPAChar::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetIPAChar::xhtml(XMLStream & xs, OutputParams const &) const
{ {
switch (kind_) { switch (kind_) {
case TONE_FALLING: case TONE_FALLING:
xs << XHTMLStream::ESCAPE_NONE << "&#x2e5;" xs << XMLStream::ESCAPE_NONE << "&#x2e5;"
<< XHTMLStream::ESCAPE_NONE << "&#x2e9;"; << XMLStream::ESCAPE_NONE << "&#x2e9;";
break; break;
case TONE_RISING: case TONE_RISING:
xs << XHTMLStream::ESCAPE_NONE << "&#x2e9;" xs << XMLStream::ESCAPE_NONE << "&#x2e9;"
<< XHTMLStream::ESCAPE_NONE << "&#x2e5;"; << XMLStream::ESCAPE_NONE << "&#x2e5;";
break; break;
case TONE_HIGH_RISING: case TONE_HIGH_RISING:
xs << XHTMLStream::ESCAPE_NONE << "&#x2e7;" xs << XMLStream::ESCAPE_NONE << "&#x2e7;"
<< XHTMLStream::ESCAPE_NONE << "&#x2e5;"; << XMLStream::ESCAPE_NONE << "&#x2e5;";
break; break;
case TONE_LOW_RISING: case TONE_LOW_RISING:
xs << XHTMLStream::ESCAPE_NONE << "&#x2e9;" xs << XMLStream::ESCAPE_NONE << "&#x2e9;"
<< XHTMLStream::ESCAPE_NONE << "&#x2e7;"; << XMLStream::ESCAPE_NONE << "&#x2e7;";
break; break;
case TONE_HIGH_RISING_FALLING: case TONE_HIGH_RISING_FALLING:
xs << XHTMLStream::ESCAPE_NONE << "&#x2e8;" xs << XMLStream::ESCAPE_NONE << "&#x2e8;"
<< XHTMLStream::ESCAPE_NONE << "&#x2e5;" << XMLStream::ESCAPE_NONE << "&#x2e5;"
<< XHTMLStream::ESCAPE_NONE << "&#x2e8;"; << XMLStream::ESCAPE_NONE << "&#x2e8;";
break; break;
} }
return docstring(); return docstring();

View File

@ -81,7 +81,7 @@ private:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const; bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
/// ///
@ -152,7 +152,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void toString(odocstream &) const; void toString(odocstream &) const;
/// ///

View File

@ -937,7 +937,7 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
} }
docstring InsetInclude::xhtml(XHTMLStream & xs, OutputParams const & rp) const docstring InsetInclude::xhtml(XMLStream & xs, OutputParams const & rp) const
{ {
if (rp.inComment) if (rp.inComment)
return docstring(); return docstring();
@ -947,11 +947,11 @@ docstring InsetInclude::xhtml(XHTMLStream & xs, OutputParams const & rp) const
bool const listing = isListings(params()); bool const listing = isListings(params());
if (listing || isVerbatim(params())) { if (listing || isVerbatim(params())) {
if (listing) if (listing)
xs << html::StartTag("pre"); xs << xml::StartTag("pre");
// FIXME: We don't know the encoding of the file, default to UTF-8. // FIXME: We don't know the encoding of the file, default to UTF-8.
xs << includedFileName(buffer(), params()).fileContents("UTF-8"); xs << includedFileName(buffer(), params()).fileContents("UTF-8");
if (listing) if (listing)
xs << html::EndTag("pre"); xs << xml::EndTag("pre");
return docstring(); return docstring();
} }
@ -988,10 +988,10 @@ docstring InsetInclude::xhtml(XHTMLStream & xs, OutputParams const & rp) const
op.par_end = 0; op.par_end = 0;
ibuf->writeLyXHTMLSource(xs.os(), op, Buffer::IncludedFile); ibuf->writeLyXHTMLSource(xs.os(), op, Buffer::IncludedFile);
} else } else
xs << XHTMLStream::ESCAPE_NONE xs << XMLStream::ESCAPE_NONE
<< "<!-- Included file: " << "<!-- Included file: "
<< from_utf8(included_file.absFileName()) << from_utf8(included_file.absFileName())
<< XHTMLStream::ESCAPE_NONE << XMLStream::ESCAPE_NONE
<< " -->"; << " -->";
return docstring(); return docstring();

View File

@ -96,7 +96,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void validate(LaTeXFeatures &) const; void validate(LaTeXFeatures &) const;
/// ///
@ -159,8 +159,8 @@ private:
/// get the text displayed on the button /// get the text displayed on the button
docstring screenLabel() const; docstring screenLabel() const;
//@} //@}
/// holds the entity name that defines the file location (SGML) /// holds the entity name that defines the file location (XML)
docstring const include_label; docstring const include_label;
/// The pointer never changes although *preview_'s contents may. /// The pointer never changes although *preview_'s contents may.

View File

@ -27,7 +27,7 @@
#include "Lexer.h" #include "Lexer.h"
#include "output_latex.h" #include "output_latex.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "sgml.h" #include "xml.h"
#include "texstream.h" #include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
#include "TocBackend.h" #include "TocBackend.h"
@ -55,7 +55,7 @@ namespace lyx {
InsetIndex::InsetIndex(Buffer * buf, InsetIndexParams const & params) InsetIndex::InsetIndex(Buffer * buf, InsetIndexParams const & params)
: InsetCollapsible(buf), params_(params) : InsetCollapsible(buf), params_(params)
{} {}
@ -67,7 +67,7 @@ void InsetIndex::latex(otexstream & ios, OutputParams const & runparams_in) cons
otexstringstream os; otexstringstream os;
if (buffer().masterBuffer()->params().use_indices && !params_.index.empty() if (buffer().masterBuffer()->params().use_indices && !params_.index.empty()
&& params_.index != "idx") { && params_.index != "idx") {
os << "\\sindex["; os << "\\sindex[";
os << escape(params_.index); os << escape(params_.index);
os << "]{"; os << "]{";
@ -112,12 +112,12 @@ void InsetIndex::latex(otexstream & ios, OutputParams const & runparams_in) cons
LYXERR0("The `|' separator was not found in the plaintext version!"); LYXERR0("The `|' separator was not found in the plaintext version!");
} }
// Separate the entires and subentries, i.e., split on "!" // Separate the entries and subentries, i.e., split on "!"
// FIXME This would do the wrong thing with escaped ! characters // FIXME This would do the wrong thing with escaped ! characters
std::vector<docstring> const levels = std::vector<docstring> const levels =
getVectorFromString(latexstr, from_ascii("!"), true); getVectorFromString(latexstr, from_ascii("!"), true);
std::vector<docstring> const levels_plain = std::vector<docstring> const levels_plain =
getVectorFromString(plainstr, from_ascii("!"), true); getVectorFromString(plainstr, from_ascii("!"), true);
vector<docstring>::const_iterator it = levels.begin(); vector<docstring>::const_iterator it = levels.begin();
vector<docstring>::const_iterator end = levels.end(); vector<docstring>::const_iterator end = levels.end();
@ -138,27 +138,27 @@ void InsetIndex::latex(otexstream & ios, OutputParams const & runparams_in) cons
if (contains(*it, '\\') && !contains(*it, '@')) { if (contains(*it, '\\') && !contains(*it, '@')) {
// Plaintext might return nothing (e.g. for ERTs) // Plaintext might return nothing (e.g. for ERTs)
docstring const spart = docstring const spart =
(it2 < levels_plain.end() && !(*it2).empty()) (it2 < levels_plain.end() && !(*it2).empty())
? *it2 : *it; ? *it2 : *it;
// Now we need to validate that all characters in // Now we need to validate that all characters in
// the sorting part are representable in the current // the sorting part are representable in the current
// encoding. If not try the LaTeX macro which might // encoding. If not try the LaTeX macro which might
// or might not be a good choice, and issue a warning. // or might not be a good choice, and issue a warning.
pair<docstring, docstring> spart_latexed = pair<docstring, docstring> spart_latexed =
runparams.encoding->latexString(spart, runparams.dryrun); runparams.encoding->latexString(spart, runparams.dryrun);
if (!spart_latexed.second.empty()) if (!spart_latexed.second.empty())
LYXERR0("Uncodable character in index entry. Sorting might be wrong!"); LYXERR0("Uncodable character in index entry. Sorting might be wrong!");
if (spart != spart_latexed.first && !runparams.dryrun) { if (spart != spart_latexed.first && !runparams.dryrun) {
// FIXME: warning should be passed to the error dialog // FIXME: warning should be passed to the error dialog
frontend::Alert::warning(_("Index sorting failed"), frontend::Alert::warning(_("Index sorting failed"),
bformat(_("LyX's automatic index sorting algorithm faced\n" bformat(_("LyX's automatic index sorting algorithm faced\n"
"problems with the entry '%1$s'.\n" "problems with the entry '%1$s'.\n"
"Please specify the sorting of this entry manually, as\n" "Please specify the sorting of this entry manually, as\n"
"explained in the User Guide."), spart)); "explained in the User Guide."), spart));
} }
// remove remaining \'s for the sorting part // remove remaining \'s for the sorting part
docstring const ppart = docstring const ppart =
subst(spart_latexed.first, from_ascii("\\"), docstring()); subst(spart_latexed.first, from_ascii("\\"), docstring());
os << ppart; os << ppart;
os << '@'; os << '@';
} }
@ -191,13 +191,13 @@ int InsetIndex::docbook(odocstream & os, OutputParams const & runparams) const
} }
docstring InsetIndex::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetIndex::xhtml(XMLStream & xs, OutputParams const &) const
{ {
// we just print an anchor, taking the paragraph ID from // we just print an anchor, taking the paragraph ID from
// our own interior paragraph, which doesn't get printed // our own interior paragraph, which doesn't get printed
std::string const magic = paragraphs().front().magicLabel(); std::string const magic = paragraphs().front().magicLabel();
std::string const attr = "id='" + magic + "'"; std::string const attr = "id='" + magic + "'";
xs << html::CompTag("a", attr); xs << xml::CompTag("a", attr);
return docstring(); return docstring();
} }
@ -707,7 +707,7 @@ bool operator<(IndexEntry const & lhs, IndexEntry const & rhs)
} // namespace } // namespace
docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const docstring InsetPrintIndex::xhtml(XMLStream &, OutputParams const & op) const
{ {
BufferParams const & bp = buffer().masterBuffer()->params(); BufferParams const & bp = buffer().masterBuffer()->params();
@ -747,14 +747,14 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
// that's how we deal with the fact that we're probably inside a standard // that's how we deal with the fact that we're probably inside a standard
// paragraph, and we don't want to be. // paragraph, and we don't want to be.
odocstringstream ods; odocstringstream ods;
XHTMLStream xs(ods); XMLStream xs(ods);
xs << html::StartTag("div", tocattr); xs << xml::StartTag("div", tocattr);
xs << html::StartTag(lay.htmltag(), lay.htmlattr()) xs << xml::StartTag(lay.htmltag(), lay.htmlattr())
<< translateIfPossible(from_ascii("Index"), << translateIfPossible(from_ascii("Index"),
op.local_font->language()->lang()) op.local_font->language()->lang())
<< html::EndTag(lay.htmltag()); << xml::EndTag(lay.htmltag());
xs << html::StartTag("ul", "class='main'"); xs << xml::StartTag("ul", "class='main'");
Font const dummy; Font const dummy;
vector<IndexEntry>::const_iterator eit = entries.begin(); vector<IndexEntry>::const_iterator eit = entries.begin();
@ -774,11 +774,11 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
// close last entry or entries, depending. // close last entry or entries, depending.
if (level == 3) { if (level == 3) {
// close this sub-sub-entry // close this sub-sub-entry
xs << html::EndTag("li") << html::CR(); xs << xml::EndTag("li") << xml::CR();
// is this another sub-sub-entry within the same sub-entry? // is this another sub-sub-entry within the same sub-entry?
if (!eit->same_sub(last)) { if (!eit->same_sub(last)) {
// close this level // close this level
xs << html::EndTag("ul") << html::CR(); xs << xml::EndTag("ul") << xml::CR();
level = 2; level = 2;
} }
} }
@ -789,11 +789,11 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
// sub-entry. In that case, we do not want to close anything. // sub-entry. In that case, we do not want to close anything.
if (level == 2 && !eit->same_sub(last)) { if (level == 2 && !eit->same_sub(last)) {
// close sub-entry // close sub-entry
xs << html::EndTag("li") << html::CR(); xs << xml::EndTag("li") << xml::CR();
// is this another sub-entry with the same main entry? // is this another sub-entry with the same main entry?
if (!eit->same_main(last)) { if (!eit->same_main(last)) {
// close this level // close this level
xs << html::EndTag("ul") << html::CR(); xs << xml::EndTag("ul") << xml::CR();
level = 1; level = 1;
} }
} }
@ -802,7 +802,7 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
// close the entry. // close the entry.
if (level == 1 && !eit->same_main(last)) { if (level == 1 && !eit->same_main(last)) {
// close entry // close entry
xs << html::EndTag("li") << html::CR(); xs << xml::EndTag("li") << xml::CR();
} }
} }
@ -812,7 +812,7 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
// We need to use our own stream, since we will have to // We need to use our own stream, since we will have to
// modify what we get back. // modify what we get back.
odocstringstream ent; odocstringstream ent;
XHTMLStream entstream(ent); XMLStream entstream(ent);
OutputParams ours = op; OutputParams ours = op;
ours.for_toc = true; ours.for_toc = true;
par.simpleLyXHTMLOnePar(buffer(), entstream, ours, dummy); par.simpleLyXHTMLOnePar(buffer(), entstream, ours, dummy);
@ -830,8 +830,8 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
if (level == 3) { if (level == 3) {
// another subsubentry // another subsubentry
xs << html::StartTag("li", "class='subsubentry'") xs << xml::StartTag("li", "class='subsubentry'")
<< XHTMLStream::ESCAPE_NONE << subsub; << XMLStream::ESCAPE_NONE << subsub;
} else if (level == 2) { } else if (level == 2) {
// there are two ways we can be here: // there are two ways we can be here:
// (i) we can actually be inside a sub-entry already and be about // (i) we can actually be inside a sub-entry already and be about
@ -844,14 +844,14 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
// note that in this case, too, though, the sub-entry might already // note that in this case, too, though, the sub-entry might already
// have a sub-sub-entry. // have a sub-sub-entry.
if (eit->sub != last.sub) if (eit->sub != last.sub)
xs << html::StartTag("li", "class='subentry'") xs << xml::StartTag("li", "class='subentry'")
<< XHTMLStream::ESCAPE_NONE << sub; << XMLStream::ESCAPE_NONE << sub;
if (!subsub.empty()) { if (!subsub.empty()) {
// it's actually a subsubentry, so we need to start that list // it's actually a subsubentry, so we need to start that list
xs << html::CR() xs << xml::CR()
<< html::StartTag("ul", "class='subsubentry'") << xml::StartTag("ul", "class='subsubentry'")
<< html::StartTag("li", "class='subsubentry'") << xml::StartTag("li", "class='subsubentry'")
<< XHTMLStream::ESCAPE_NONE << subsub; << XMLStream::ESCAPE_NONE << subsub;
level = 3; level = 3;
} }
} else { } else {
@ -866,20 +866,20 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
// note that in this case, too, though, the main entry might already // note that in this case, too, though, the main entry might already
// have a sub-entry, or even a sub-sub-entry. // have a sub-entry, or even a sub-sub-entry.
if (eit->main != last.main) if (eit->main != last.main)
xs << html::StartTag("li", "class='main'") << main; xs << xml::StartTag("li", "class='main'") << main;
if (!sub.empty()) { if (!sub.empty()) {
// there's a sub-entry, too // there's a sub-entry, too
xs << html::CR() xs << xml::CR()
<< html::StartTag("ul", "class='subentry'") << xml::StartTag("ul", "class='subentry'")
<< html::StartTag("li", "class='subentry'") << xml::StartTag("li", "class='subentry'")
<< XHTMLStream::ESCAPE_NONE << sub; << XMLStream::ESCAPE_NONE << sub;
level = 2; level = 2;
if (!subsub.empty()) { if (!subsub.empty()) {
// and a sub-sub-entry // and a sub-sub-entry
xs << html::CR() xs << xml::CR()
<< html::StartTag("ul", "class='subsubentry'") << xml::StartTag("ul", "class='subsubentry'")
<< html::StartTag("li", "class='subsubentry'") << xml::StartTag("li", "class='subsubentry'")
<< XHTMLStream::ESCAPE_NONE << subsub; << XMLStream::ESCAPE_NONE << subsub;
level = 3; level = 3;
} }
} }
@ -888,16 +888,16 @@ docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const
// finally, then, we can output the index link itself // finally, then, we can output the index link itself
string const parattr = "href='#" + par.magicLabel() + "'"; string const parattr = "href='#" + par.magicLabel() + "'";
xs << (entry_number == 0 ? ":" : ","); xs << (entry_number == 0 ? ":" : ",");
xs << " " << html::StartTag("a", parattr) xs << " " << xml::StartTag("a", parattr)
<< ++entry_number << html::EndTag("a"); << ++entry_number << xml::EndTag("a");
last = *eit; last = *eit;
} }
// now we have to close all the open levels // now we have to close all the open levels
while (level > 0) { while (level > 0) {
xs << html::EndTag("li") << html::EndTag("ul") << html::CR(); xs << xml::EndTag("li") << xml::EndTag("ul") << xml::CR();
--level; --level;
} }
xs << html::EndTag("div") << html::CR(); xs << xml::EndTag("div") << xml::CR();
return ods.str(); return ods.str();
} }

View File

@ -59,7 +59,7 @@ private:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void latex(otexstream &, OutputParams const &) const; void latex(otexstream &, OutputParams const &) const;
/// ///
@ -105,7 +105,7 @@ public:
/// ///
void latex(otexstream &, OutputParams const &) const; void latex(otexstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void doDispatch(Cursor & cur, FuncRequest & cmd); void doDispatch(Cursor & cur, FuncRequest & cmd);
/// ///

View File

@ -27,7 +27,7 @@
#include "LyX.h" #include "LyX.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "ParIterator.h" #include "ParIterator.h"
#include "sgml.h" #include "xml.h"
#include "texstream.h" #include "texstream.h"
#include "Text.h" #include "Text.h"
#include "TextClass.h" #include "TextClass.h"
@ -351,24 +351,24 @@ int InsetLabel::plaintext(odocstringstream & os,
} }
int InsetLabel::docbook(odocstream & os, OutputParams const & runparams) const int InsetLabel::docbook(odocstream & os, OutputParams const &) const
{ {
os << "<!-- anchor id=\"" os << "<!-- anchor id=\""
<< sgml::cleanID(buffer(), runparams, getParam("name")) << xml::cleanID(getParam("name"))
<< "\" -->"; << "\" -->";
return 0; return 0;
} }
docstring InsetLabel::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetLabel::xhtml(XMLStream & xs, OutputParams const &) const
{ {
// FIXME XHTML // FIXME XHTML
// Unfortunately, the name attribute has been deprecated, so we have to use // Unfortunately, the name attribute has been deprecated, so we have to use
// id here to get the document to validate as XHTML 1.1. This will cause a // id here to get the document to validate as XHTML 1.1. This will cause a
// problem with some browsers, though, I'm sure. (Guess which!) So we will // problem with some browsers, though, I'm sure. (Guess which!) So we will
// have to figure out what to do about this later. // have to figure out what to do about this later.
docstring const attr = "id=\"" + html::cleanAttr(getParam("name")) + '"'; docstring const attr = "id=\"" + xml::cleanAttr(getParam("name")) + '"';
xs << html::CompTag("a", to_utf8(attr)); xs << xml::CompTag("a", to_utf8(attr));
return docstring(); return docstring();
} }

View File

@ -55,7 +55,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void updateBuffer(ParIterator const & it, UpdateType, bool const deleted = false); void updateBuffer(ParIterator const & it, UpdateType, bool const deleted = false);
/// ///

View File

@ -190,9 +190,9 @@ int InsetLine::docbook(odocstream & os, OutputParams const &) const
} }
docstring InsetLine::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetLine::xhtml(XMLStream & xs, OutputParams const &) const
{ {
xs << html::CompTag("hr") << html::CR(); xs << xml::CompTag("hr") << xml::CR();
return docstring(); return docstring();
} }

View File

@ -43,7 +43,7 @@ private:
InsetCode lyxCode() const { return LINE_CODE; } InsetCode lyxCode() const { return LINE_CODE; }
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// Does nothing at the moment. /// Does nothing at the moment.
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
bool hasSettings() const { return true; } bool hasSettings() const { return true; }
void metrics(MetricsInfo &, Dimension &) const; void metrics(MetricsInfo &, Dimension &) const;
void draw(PainterInfo & pi, int x, int y) const; void draw(PainterInfo & pi, int x, int y) const;

View File

@ -433,21 +433,21 @@ void InsetListings::latex(otexstream & os, OutputParams const & runparams) const
} }
docstring InsetListings::xhtml(XHTMLStream & os, OutputParams const & rp) const docstring InsetListings::xhtml(XMLStream & os, OutputParams const & rp) const
{ {
odocstringstream ods; odocstringstream ods;
XHTMLStream out(ods); XMLStream out(ods);
bool const isInline = params().isInline(); bool const isInline = params().isInline();
if (isInline) if (isInline)
out << html::CompTag("br"); out << xml::CompTag("br");
else { else {
out << html::StartTag("div", "class='float-listings'"); out << xml::StartTag("div", "class='float-listings'");
docstring caption = getCaptionHTML(rp); docstring caption = getCaptionHTML(rp);
if (!caption.empty()) if (!caption.empty())
out << html::StartTag("div", "class='listings-caption'") out << xml::StartTag("div", "class='listings-caption'")
<< XHTMLStream::ESCAPE_NONE << XMLStream::ESCAPE_NONE
<< caption << html::EndTag("div"); << caption << xml::EndTag("div");
} }
InsetLayout const & il = getLayout(); InsetLayout const & il = getLayout();
@ -457,21 +457,21 @@ docstring InsetListings::xhtml(XHTMLStream & os, OutputParams const & rp) const
if (!lang.empty()) if (!lang.empty())
attr += " " + lang; attr += " " + lang;
attr += "'"; attr += "'";
out << html::StartTag(tag, attr); out << xml::StartTag(tag, attr);
OutputParams newrp = rp; OutputParams newrp = rp;
newrp.html_disable_captions = true; newrp.html_disable_captions = true;
// We don't want to convert dashes here. That's the only conversion we // We don't want to convert dashes here. That's the only conversion we
// do for XHTML, so this is safe. // do for XHTML, so this is safe.
newrp.pass_thru = true; newrp.pass_thru = true;
docstring def = InsetText::insetAsXHTML(out, newrp, InsetText::JustText); docstring def = InsetText::insetAsXHTML(out, newrp, InsetText::JustText);
out << html::EndTag(tag); out << xml::EndTag(tag);
if (isInline) { if (isInline) {
out << html::CompTag("br"); out << xml::CompTag("br");
// escaping will already have been done // escaping will already have been done
os << XHTMLStream::ESCAPE_NONE << ods.str(); os << XMLStream::ESCAPE_NONE << ods.str();
} else { } else {
out << html::EndTag("div"); out << xml::EndTag("div");
// In this case, this needs to be deferred, but we'll put it // In this case, this needs to be deferred, but we'll put it
// before anything the text itself deferred. // before anything the text itself deferred.
def = ods.str() + '\n' + def; def = ods.str() + '\n' + def;

View File

@ -56,7 +56,7 @@ private:
/// ///
void latex(otexstream &, OutputParams const &) const; void latex(otexstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void validate(LaTeXFeatures &) const; void validate(LaTeXFeatures &) const;
/// ///

View File

@ -178,9 +178,9 @@ int InsetNewline::docbook(odocstream & os, OutputParams const &) const
} }
docstring InsetNewline::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetNewline::xhtml(XMLStream & xs, OutputParams const &) const
{ {
xs << html::CR() << html::CompTag("br") << html::CR(); xs << xml::CR() << xml::CompTag("br") << xml::CR();
return docstring(); return docstring();
} }

View File

@ -65,7 +65,7 @@ private:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void read(Lexer & lex); void read(Lexer & lex);
/// ///

View File

@ -255,9 +255,9 @@ int InsetNewpage::docbook(odocstream & os, OutputParams const &) const
} }
docstring InsetNewpage::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetNewpage::xhtml(XMLStream & xs, OutputParams const &) const
{ {
xs << html::CompTag("br"); xs << xml::CompTag("br");
return docstring(); return docstring();
} }

View File

@ -68,7 +68,7 @@ private:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void read(Lexer & lex); void read(Lexer & lex);
/// ///

View File

@ -30,7 +30,7 @@
#include "LyX.h" #include "LyX.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "output_xhtml.h" #include "output_xhtml.h"
#include "sgml.h" #include "xml.h"
#include "texstream.h" #include "texstream.h"
#include "TocBackend.h" #include "TocBackend.h"
@ -55,7 +55,7 @@ namespace lyx {
InsetNomencl::InsetNomencl(Buffer * buf, InsetCommandParams const & p) InsetNomencl::InsetNomencl(Buffer * buf, InsetCommandParams const & p)
: InsetCommand(buf, p), : InsetCommand(buf, p),
nomenclature_entry_id(sgml::uniqueID(from_ascii("nomen"))) nomenclature_entry_id(xml::uniqueID(from_ascii("nomen")))
{} {}
@ -108,13 +108,13 @@ int InsetNomencl::plaintext(odocstringstream & os,
int InsetNomencl::docbook(odocstream & os, OutputParams const &) const int InsetNomencl::docbook(odocstream & os, OutputParams const &) const
{ {
os << "<glossterm linkend=\"" << nomenclature_entry_id << "\">" os << "<glossterm linkend=\"" << nomenclature_entry_id << "\">"
<< sgml::escapeString(getParam("symbol")) << xml::escapeString(getParam("symbol"))
<< "</glossterm>"; << "</glossterm>";
return 0; return 0;
} }
docstring InsetNomencl::xhtml(XHTMLStream &, OutputParams const &) const docstring InsetNomencl::xhtml(XMLStream &, OutputParams const &) const
{ {
return docstring(); return docstring();
} }
@ -124,10 +124,10 @@ int InsetNomencl::docbookGlossary(odocstream & os) const
{ {
os << "<glossentry id=\"" << nomenclature_entry_id << "\">\n" os << "<glossentry id=\"" << nomenclature_entry_id << "\">\n"
<< "<glossterm>" << "<glossterm>"
<< sgml::escapeString(getParam("symbol")) << xml::escapeString(getParam("symbol"))
<< "</glossterm>\n" << "</glossterm>\n"
<< "<glossdef><para>" << "<glossdef><para>"
<< sgml::escapeString(getParam("description")) << xml::escapeString(getParam("description"))
<< "</para></glossdef>\n" << "</para></glossdef>\n"
<<"</glossentry>\n"; <<"</glossentry>\n";
return 4; return 4;
@ -200,7 +200,7 @@ struct NomenclEntry {
typedef map<docstring, NomenclEntry > EntryMap; typedef map<docstring, NomenclEntry > EntryMap;
docstring InsetPrintNomencl::xhtml(XHTMLStream &, OutputParams const & op) const docstring InsetPrintNomencl::xhtml(XMLStream &, OutputParams const & op) const
{ {
shared_ptr<Toc const> toc = buffer().tocBackend().toc("nomencl"); shared_ptr<Toc const> toc = buffer().tocBackend().toc("nomencl");
@ -234,42 +234,42 @@ docstring InsetPrintNomencl::xhtml(XHTMLStream &, OutputParams const & op) const
// that's how we deal with the fact that we're probably inside a standard // that's how we deal with the fact that we're probably inside a standard
// paragraph, and we don't want to be. // paragraph, and we don't want to be.
odocstringstream ods; odocstringstream ods;
XHTMLStream xs(ods); XMLStream xs(ods);
InsetLayout const & il = getLayout(); InsetLayout const & il = getLayout();
string const & tag = il.htmltag(); string const & tag = il.htmltag();
docstring toclabel = translateIfPossible(from_ascii("Nomenclature"), docstring toclabel = translateIfPossible(from_ascii("Nomenclature"),
op.local_font->language()->lang()); op.local_font->language()->lang());
xs << html::StartTag("div", "class='nomencl'") xs << xml::StartTag("div", "class='nomencl'")
<< html::StartTag(tag, "class='nomencl'") << xml::StartTag(tag, "class='nomencl'")
<< toclabel << toclabel
<< html::EndTag(tag) << xml::EndTag(tag)
<< html::CR() << xml::CR()
<< html::StartTag("dl") << xml::StartTag("dl")
<< html::CR(); << xml::CR();
EntryMap::const_iterator eit = entries.begin(); EntryMap::const_iterator eit = entries.begin();
EntryMap::const_iterator const een = entries.end(); EntryMap::const_iterator const een = entries.end();
for (; eit != een; ++eit) { for (; eit != een; ++eit) {
NomenclEntry const & ne = eit->second; NomenclEntry const & ne = eit->second;
string const parid = ne.par->magicLabel(); string const parid = ne.par->magicLabel();
xs << html::StartTag("dt") xs << xml::StartTag("dt")
<< html::StartTag("a", "href='#" + parid + "' class='nomencl'") << xml::StartTag("a", "href='#" + parid + "' class='nomencl'")
<< ne.symbol << ne.symbol
<< html::EndTag("a") << xml::EndTag("a")
<< html::EndTag("dt") << xml::EndTag("dt")
<< html::CR() << xml::CR()
<< html::StartTag("dd") << xml::StartTag("dd")
<< ne.desc << ne.desc
<< html::EndTag("dd") << xml::EndTag("dd")
<< html::CR(); << xml::CR();
} }
xs << html::EndTag("dl") xs << xml::EndTag("dl")
<< html::CR() << xml::CR()
<< html::EndTag("div") << xml::EndTag("div")
<< html::CR(); << xml::CR();
return ods.str(); return ods.str();
} }

View File

@ -50,7 +50,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// Does nothing at the moment. /// Does nothing at the moment.
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
//@} //@}
/// \name Static public methods obligated for InsetCommand derived classes /// \name Static public methods obligated for InsetCommand derived classes
@ -94,7 +94,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
InsetCode lyxCode() const; InsetCode lyxCode() const;
/// ///

View File

@ -290,7 +290,7 @@ int InsetNote::docbook(odocstream & os, OutputParams const & runparams_in) const
} }
docstring InsetNote::xhtml(XHTMLStream & xs, OutputParams const & rp) const docstring InsetNote::xhtml(XMLStream & xs, OutputParams const & rp) const
{ {
if (params_.type == InsetNoteParams::Note) if (params_.type == InsetNoteParams::Note)
return docstring(); return docstring();

View File

@ -90,7 +90,7 @@ private:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void validate(LaTeXFeatures &) const; void validate(LaTeXFeatures &) const;
/// ///

View File

@ -367,7 +367,7 @@ int InsetPhantom::docbook(odocstream & os, OutputParams const & runparams) const
} }
docstring InsetPhantom::xhtml(XHTMLStream &, OutputParams const &) const docstring InsetPhantom::xhtml(XMLStream &, OutputParams const &) const
{ {
return docstring(); return docstring();
} }

View File

@ -81,7 +81,7 @@ private:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// Makes no sense fof XHTML. /// Makes no sense fof XHTML.
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const; bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
/// ///

View File

@ -536,6 +536,79 @@ docstring InsetQuotesParams::getHTMLQuote(char_type c) const
} }
docstring InsetQuotesParams::getXMLQuote(char_type c) const
{
string res;
switch (c){
case 0x201a: // ,
res = "&#8218;";
break;
case 0x2019: // '
res = "&#8217;";
break;
case 0x2018: // `
res = "&#8216;";
break;
case 0x2039: // <
res = "&#8249;";
break;
case 0x203a: // >
res = "&#8250;";
break;
case 0x0027: // ' (plain)
res = "&#x27;";
break;
case 0x201e: // ,,
res = "&#8222;";
break;
case 0x201d: // ''
res = "&#8221;";
break;
case 0x201c: // ``
res = "&#8220;";
break;
case 0x00ab: // <<
res = "&#171;";
break;
case 0x00bb: // >>
res = "&#187;";
break;
case 0x0022: // "
res = "&#34;";
break;
case 0x300c: // LEFT CORNER BRACKET
res = "&#x300c;";
break;
case 0x300d: // RIGHT CORNER BRACKET
res = "&#x300d;";
break;
case 0x300e: // LEFT WHITE CORNER BRACKET
res = "&#x300e;";
break;
case 0x300f: // RIGHT WHITE CORNER BRACKET
res = "&#x300f;";
break;
case 0x300a: // LEFT DOUBLE ANGLE BRACKET
res = "&#x300a;";
break;
case 0x300b: // RIGHT DOUBLE ANGLE BRACKET
res = "&#x300b;";
break;
case 0x3008: // LEFT ANGLE BRACKET
res = "&#x3008;";
break;
case 0x3009: // RIGHT ANGLE BRACKET
res = "&#x3009;";
break;
default:
break;
}
return from_ascii(res);
}
map<string, docstring> InsetQuotesParams::getTypes() const map<string, docstring> InsetQuotesParams::getTypes() const
{ {
map<string, docstring> res; map<string, docstring> res;
@ -946,10 +1019,11 @@ int InsetQuotes::plaintext(odocstringstream & os,
} }
docstring InsetQuotes::getQuoteEntity() const { docstring InsetQuotes::getQuoteEntity(bool isHTML) const {
InsetQuotesParams::QuoteStyle style = InsetQuotesParams::QuoteStyle style =
(style_ == InsetQuotesParams::DynamicQuotes) ? global_style_ : style_; (style_ == InsetQuotesParams::DynamicQuotes) ? global_style_ : style_;
docstring res = quoteparams.getHTMLQuote(quoteparams.getQuoteChar(style, level_, side_)); docstring res = isHTML ? quoteparams.getHTMLQuote(quoteparams.getQuoteChar(style, level_, side_)) :
quoteparams.getXMLQuote(quoteparams.getQuoteChar(style, level_, side_));
// in French, thin spaces are added inside double guillemets // in French, thin spaces are added inside double guillemets
if (prefixIs(context_lang_, "fr") if (prefixIs(context_lang_, "fr")
&& level_ == InsetQuotesParams::PrimaryQuotes && level_ == InsetQuotesParams::PrimaryQuotes
@ -969,14 +1043,14 @@ docstring InsetQuotes::getQuoteEntity() const {
int InsetQuotes::docbook(odocstream & os, OutputParams const &) const int InsetQuotes::docbook(odocstream & os, OutputParams const &) const
{ {
os << getQuoteEntity(); os << getQuoteEntity(false);
return 0; return 0;
} }
docstring InsetQuotes::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetQuotes::xhtml(XMLStream & xs, OutputParams const &) const
{ {
xs << XHTMLStream::ESCAPE_NONE << getQuoteEntity(); xs << XMLStream::ESCAPE_NONE << getQuoteEntity(true);
return docstring(); return docstring();
} }

View File

@ -82,6 +82,8 @@ public:
bool const rtl = false) const; bool const rtl = false) const;
/// ///
docstring getHTMLQuote(char_type c) const; docstring getHTMLQuote(char_type c) const;
///
docstring getXMLQuote(char_type c) const;
/// Returns a descriptive label of a style suitable for dialog and menu /// Returns a descriptive label of a style suitable for dialog and menu
docstring const getGuiLabel(QuoteStyle const & qs, docstring const getGuiLabel(QuoteStyle const & qs,
bool langdef = false); bool langdef = false);
@ -146,7 +148,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void toString(odocstream &) const; void toString(odocstream &) const;
@ -180,7 +182,7 @@ private:
/// ///
docstring displayString() const; docstring displayString() const;
/// ///
docstring getQuoteEntity() const; docstring getQuoteEntity(bool isHTML) const;
/// ///
InsetQuotesParams::QuoteStyle getStyle(std::string const &); InsetQuotesParams::QuoteStyle getStyle(std::string const &);

View File

@ -24,7 +24,7 @@
#include "output_xhtml.h" #include "output_xhtml.h"
#include "Paragraph.h" #include "Paragraph.h"
#include "ParIterator.h" #include "ParIterator.h"
#include "sgml.h" #include "xml.h"
#include "texstream.h" #include "texstream.h"
#include "TocBackend.h" #include "TocBackend.h"
@ -315,16 +315,16 @@ int InsetRef::docbook(odocstream & os, OutputParams const & runparams) const
if (name.empty()) { if (name.empty()) {
if (runparams.flavor == OutputParams::XML) { if (runparams.flavor == OutputParams::XML) {
os << "<xref linkend=\"" os << "<xref linkend=\""
<< sgml::cleanID(buffer(), runparams, getParam("reference")) << xml::cleanID(getParam("reference"))
<< "\" />"; << "\" />";
} else { } else {
os << "<xref linkend=\"" os << "<xref linkend=\""
<< sgml::cleanID(buffer(), runparams, getParam("reference")) << xml::cleanID(getParam("reference"))
<< "\">"; << "\">";
} }
} else { } else {
os << "<link linkend=\"" os << "<link linkend=\""
<< sgml::cleanID(buffer(), runparams, getParam("reference")) << xml::cleanID(getParam("reference"))
<< "\">" << "\">"
<< getParam("name") << getParam("name")
<< "</link>"; << "</link>";
@ -334,7 +334,7 @@ int InsetRef::docbook(odocstream & os, OutputParams const & runparams) const
} }
docstring InsetRef::xhtml(XHTMLStream & xs, OutputParams const & op) const docstring InsetRef::xhtml(XMLStream & xs, OutputParams const & op) const
{ {
docstring const & ref = getParam("reference"); docstring const & ref = getParam("reference");
InsetLabel const * il = buffer().insetLabel(ref, true); InsetLabel const * il = buffer().insetLabel(ref, true);
@ -375,10 +375,10 @@ docstring InsetRef::xhtml(XHTMLStream & xs, OutputParams const & op) const
// FIXME What we'd really like to do is to be able to output some // FIXME What we'd really like to do is to be able to output some
// appropriate sort of text here. But to do that, we need to associate // appropriate sort of text here. But to do that, we need to associate
// some sort of counter with the label, and we don't have that yet. // some sort of counter with the label, and we don't have that yet.
docstring const attr = "href=\"#" + html::cleanAttr(ref) + '"'; docstring const attr = "href=\"#" + xml::cleanAttr(ref) + '"';
xs << html::StartTag("a", to_utf8(attr)); xs << xml::StartTag("a", to_utf8(attr));
xs << display_string; xs << display_string;
xs << html::EndTag("a"); xs << xml::EndTag("a");
return docstring(); return docstring();
} }

View File

@ -65,7 +65,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void toString(odocstream &) const; void toString(odocstream &) const;
/// ///

View File

@ -174,9 +174,9 @@ int InsetSeparator::docbook(odocstream & os, OutputParams const &) const
} }
docstring InsetSeparator::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetSeparator::xhtml(XMLStream & xs, OutputParams const &) const
{ {
xs << html::CR() << html::CompTag("br") << html::CR(); xs << xml::CR() << xml::CompTag("br") << xml::CR();
return docstring(); return docstring();
} }

View File

@ -79,7 +79,7 @@ private:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void read(Lexer & lex); void read(Lexer & lex);
/// ///

View File

@ -762,7 +762,7 @@ int InsetSpace::docbook(odocstream & os, OutputParams const &) const
} }
docstring InsetSpace::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetSpace::xhtml(XMLStream & xs, OutputParams const &) const
{ {
string output; string output;
switch (params_.kind) { switch (params_.kind) {
@ -822,7 +822,7 @@ docstring InsetSpace::xhtml(XHTMLStream & xs, OutputParams const &) const
break; break;
} }
// don't escape the entities! // don't escape the entities!
xs << XHTMLStream::ESCAPE_NONE << from_ascii(output); xs << XMLStream::ESCAPE_NONE << from_ascii(output);
return docstring(); return docstring();
} }

View File

@ -129,7 +129,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void validate(LaTeXFeatures & features) const; void validate(LaTeXFeatures & features) const;
/// ///

View File

@ -551,31 +551,31 @@ int InsetSpecialChar::docbook(odocstream & os, OutputParams const &) const
} }
docstring InsetSpecialChar::xhtml(XHTMLStream & xs, OutputParams const &) const docstring InsetSpecialChar::xhtml(XMLStream & xs, OutputParams const &) const
{ {
switch (kind_) { switch (kind_) {
case HYPHENATION: case HYPHENATION:
break; break;
case ALLOWBREAK: case ALLOWBREAK:
xs << XHTMLStream::ESCAPE_NONE << "&#8203;"; xs << XMLStream::ESCAPE_NONE << "&#8203;";
break; break;
case LIGATURE_BREAK: case LIGATURE_BREAK:
xs << XHTMLStream::ESCAPE_NONE << "&#8204;"; xs << XMLStream::ESCAPE_NONE << "&#8204;";
break; break;
case END_OF_SENTENCE: case END_OF_SENTENCE:
xs << '.'; xs << '.';
break; break;
case LDOTS: case LDOTS:
xs << XHTMLStream::ESCAPE_NONE << "&hellip;"; xs << XMLStream::ESCAPE_NONE << "&hellip;";
break; break;
case MENU_SEPARATOR: case MENU_SEPARATOR:
xs << XHTMLStream::ESCAPE_NONE << "&rArr;"; xs << XMLStream::ESCAPE_NONE << "&rArr;";
break; break;
case SLASH: case SLASH:
xs << XHTMLStream::ESCAPE_NONE << "&frasl;"; xs << XMLStream::ESCAPE_NONE << "&frasl;";
break; break;
case NOBREAKDASH: case NOBREAKDASH:
xs << XHTMLStream::ESCAPE_NONE << "&#8209;"; xs << XMLStream::ESCAPE_NONE << "&#8209;";
break; break;
case PHRASE_LYX: case PHRASE_LYX:
xs << "LyX"; xs << "LyX";
@ -584,7 +584,7 @@ docstring InsetSpecialChar::xhtml(XHTMLStream & xs, OutputParams const &) const
xs << "TeX"; xs << "TeX";
break; break;
case PHRASE_LATEX2E: case PHRASE_LATEX2E:
xs << "LaTeX2" << XHTMLStream::ESCAPE_NONE << "&#x3b5;"; xs << "LaTeX2" << XMLStream::ESCAPE_NONE << "&#x3b5;";
break; break;
case PHRASE_LATEX: case PHRASE_LATEX:
xs << "LaTeX"; xs << "LaTeX";

View File

@ -78,7 +78,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void toString(odocstream &) const; void toString(odocstream &) const;
/// ///

View File

@ -136,11 +136,11 @@ int InsetTOC::docbook(odocstream & os, OutputParams const &) const
} }
void InsetTOC::makeTOCEntry(XHTMLStream & xs, void InsetTOC::makeTOCEntry(XMLStream & xs,
Paragraph const & par, OutputParams const & op) const Paragraph const & par, OutputParams const & op) const
{ {
string const attr = "href='#" + par.magicLabel() + "' class='tocentry'"; string const attr = "href='#" + par.magicLabel() + "' class='tocentry'";
xs << html::StartTag("a", attr); xs << xml::StartTag("a", attr);
// First the label, if there is one // First the label, if there is one
docstring const & label = par.params().labelString(); docstring const & label = par.params().labelString();
@ -152,11 +152,11 @@ void InsetTOC::makeTOCEntry(XHTMLStream & xs,
Font const dummy; Font const dummy;
par.simpleLyXHTMLOnePar(buffer(), xs, ours, dummy); par.simpleLyXHTMLOnePar(buffer(), xs, ours, dummy);
xs << html::EndTag("a") << html::CR(); xs << xml::EndTag("a") << xml::CR();
} }
void InsetTOC::makeTOCWithDepth(XHTMLStream & xs, void InsetTOC::makeTOCWithDepth(XMLStream & xs,
Toc const & toc, OutputParams const & op) const Toc const & toc, OutputParams const & op) const
{ {
Toc::const_iterator it = toc.begin(); Toc::const_iterator it = toc.begin();
@ -177,13 +177,13 @@ void InsetTOC::makeTOCWithDepth(XHTMLStream & xs,
continue; continue;
if (depth > lastdepth) { if (depth > lastdepth) {
xs << html::CR(); xs << xml::CR();
// open as many tags as we need to open to get to this level // open as many tags as we need to open to get to this level
// this includes the tag for the current level // this includes the tag for the current level
for (int i = lastdepth + 1; i <= depth; ++i) { for (int i = lastdepth + 1; i <= depth; ++i) {
stringstream attr; stringstream attr;
attr << "class='lyxtoc-" << i << "'"; attr << "class='lyxtoc-" << i << "'";
xs << html::StartTag("div", attr.str()) << html::CR(); xs << xml::StartTag("div", attr.str()) << xml::CR();
} }
lastdepth = depth; lastdepth = depth;
} }
@ -191,18 +191,18 @@ void InsetTOC::makeTOCWithDepth(XHTMLStream & xs,
// close as many as we have to close to get back to this level // close as many as we have to close to get back to this level
// this includes closing the last tag at this level // this includes closing the last tag at this level
for (int i = lastdepth; i >= depth; --i) for (int i = lastdepth; i >= depth; --i)
xs << html::EndTag("div") << html::CR(); xs << xml::EndTag("div") << xml::CR();
// now open our tag // now open our tag
stringstream attr; stringstream attr;
attr << "class='lyxtoc-" << depth << "'"; attr << "class='lyxtoc-" << depth << "'";
xs << html::StartTag("div", attr.str()) << html::CR(); xs << xml::StartTag("div", attr.str()) << xml::CR();
lastdepth = depth; lastdepth = depth;
} else { } else {
// no change of level, so close and open // no change of level, so close and open
xs << html::EndTag("div") << html::CR(); xs << xml::EndTag("div") << xml::CR();
stringstream attr; stringstream attr;
attr << "class='lyxtoc-" << depth << "'"; attr << "class='lyxtoc-" << depth << "'";
xs << html::StartTag("div", attr.str()) << html::CR(); xs << xml::StartTag("div", attr.str()) << xml::CR();
} }
// Now output TOC info for this entry // Now output TOC info for this entry
@ -210,11 +210,11 @@ void InsetTOC::makeTOCWithDepth(XHTMLStream & xs,
makeTOCEntry(xs, par, op); makeTOCEntry(xs, par, op);
} }
for (int i = lastdepth; i > 0; --i) for (int i = lastdepth; i > 0; --i)
xs << html::EndTag("div") << html::CR(); xs << xml::EndTag("div") << xml::CR();
} }
void InsetTOC::makeTOCNoDepth(XHTMLStream & xs, void InsetTOC::makeTOCNoDepth(XMLStream & xs,
Toc const & toc, const OutputParams & op) const Toc const & toc, const OutputParams & op) const
{ {
Toc::const_iterator it = toc.begin(); Toc::const_iterator it = toc.begin();
@ -225,17 +225,17 @@ void InsetTOC::makeTOCNoDepth(XHTMLStream & xs,
if (!it->isOutput()) if (!it->isOutput())
continue; continue;
xs << html::StartTag("div", "class='lyxtoc-flat'") << html::CR(); xs << xml::StartTag("div", "class='lyxtoc-flat'") << xml::CR();
Paragraph const & par = it->dit().innerParagraph(); Paragraph const & par = it->dit().innerParagraph();
makeTOCEntry(xs, par, op); makeTOCEntry(xs, par, op);
xs << html::EndTag("div"); xs << xml::EndTag("div");
} }
} }
docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const docstring InsetTOC::xhtml(XMLStream &, OutputParams const & op) const
{ {
string const & command = getCmdName(); string const & command = getCmdName();
if (command != "tableofcontents" && command != "lstlistoflistings") { if (command != "tableofcontents" && command != "lstlistoflistings") {
@ -252,9 +252,9 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const
// that's how we deal with the fact that we're probably inside a standard // that's how we deal with the fact that we're probably inside a standard
// paragraph, and we don't want to be. // paragraph, and we don't want to be.
odocstringstream ods; odocstringstream ods;
XHTMLStream xs(ods); XMLStream xs(ods);
xs << html::StartTag("div", "class='toc'"); xs << xml::StartTag("div", "class='toc'");
// Title of TOC // Title of TOC
InsetLayout const & il = getLayout(); InsetLayout const & il = getLayout();
@ -263,9 +263,9 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const
Layout const & lay = buffer().params().documentClass().htmlTOCLayout(); Layout const & lay = buffer().params().documentClass().htmlTOCLayout();
string const & tocclass = lay.defaultCSSClass(); string const & tocclass = lay.defaultCSSClass();
string const tocattr = "class='tochead " + tocclass + "'"; string const tocattr = "class='tochead " + tocclass + "'";
xs << html::StartTag(tag, tocattr) xs << xml::StartTag(tag, tocattr)
<< title << title
<< html::EndTag(tag); << xml::EndTag(tag);
// with lists of listings, at least, there is no depth // with lists of listings, at least, there is no depth
// to worry about. so the code can be simpler. // to worry about. so the code can be simpler.
@ -277,7 +277,7 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const
else else
makeTOCNoDepth(xs, *toc, op); makeTOCNoDepth(xs, *toc, op);
xs << html::EndTag("div") << html::CR(); xs << xml::EndTag("div") << xml::CR();
return ods.str(); return ods.str();
} }

View File

@ -46,7 +46,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream & xs, OutputParams const &) const; docstring xhtml(XMLStream & xs, OutputParams const &) const;
/// ///
void doDispatch(Cursor & cur, FuncRequest & cmd); void doDispatch(Cursor & cur, FuncRequest & cmd);
/// ///
@ -65,11 +65,11 @@ public:
private: private:
/// ///
void makeTOCWithDepth(XHTMLStream & xs, Toc const & toc, const OutputParams & op) const; void makeTOCWithDepth(XMLStream & xs, Toc const & toc, const OutputParams & op) const;
/// ///
void makeTOCNoDepth(XHTMLStream & xs, Toc const & toc, const OutputParams & op) const; void makeTOCNoDepth(XMLStream & xs, Toc const & toc, const OutputParams & op) const;
/// ///
void makeTOCEntry(XHTMLStream & xs, Paragraph const & par, OutputParams const & op) const; void makeTOCEntry(XMLStream & xs, Paragraph const & par, OutputParams const & op) const;
/// \name Private functions inherited from Inset class /// \name Private functions inherited from Inset class
//@{ //@{

View File

@ -3649,14 +3649,14 @@ int Tabular::docbook(odocstream & os, OutputParams const & runparams) const
} }
docstring Tabular::xhtmlRow(XHTMLStream & xs, row_type row, docstring Tabular::xhtmlRow(XMLStream & xs, row_type row,
OutputParams const & runparams, bool header) const OutputParams const & runparams, bool header) const
{ {
docstring ret; docstring ret;
string const celltag = header ? "th" : "td"; string const celltag = header ? "th" : "td";
idx_type cell = getFirstCellInRow(row); idx_type cell = getFirstCellInRow(row);
xs << html::StartTag("tr"); xs << xml::StartTag("tr");
for (col_type c = 0; c < ncols(); ++c) { for (col_type c = 0; c < ncols(); ++c) {
if (isPartOfMultiColumn(row, c) || isPartOfMultiRow(row, c)) if (isPartOfMultiColumn(row, c) || isPartOfMultiRow(row, c))
continue; continue;
@ -3700,17 +3700,17 @@ docstring Tabular::xhtmlRow(XHTMLStream & xs, row_type row,
else if (isMultiRow(cell)) else if (isMultiRow(cell))
attr << " rowspan='" << rowSpan(cell) << "'"; attr << " rowspan='" << rowSpan(cell) << "'";
xs << html::StartTag(celltag, attr.str(), true) << html::CR(); xs << xml::StartTag(celltag, attr.str(), true) << xml::CR();
ret += cellInset(cell)->xhtml(xs, runparams); ret += cellInset(cell)->xhtml(xs, runparams);
xs << html::EndTag(celltag) << html::CR(); xs << xml::EndTag(celltag) << xml::CR();
++cell; ++cell;
} }
xs << html::EndTag("tr"); xs << xml::EndTag("tr");
return ret; return ret;
} }
docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const docstring Tabular::xhtml(XMLStream & xs, OutputParams const & runparams) const
{ {
docstring ret; docstring ret;
@ -3728,20 +3728,20 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
align = "right"; align = "right";
break; break;
} }
xs << html::StartTag("div", "class='longtable' style='text-align: " + align + ";'") xs << xml::StartTag("div", "class='longtable' style='text-align: " + align + ";'")
<< html::CR(); << xml::CR();
// The caption flag wins over head/foot // The caption flag wins over head/foot
if (haveLTCaption()) { if (haveLTCaption()) {
xs << html::StartTag("div", "class='longtable-caption' style='text-align: " + align + ";'") xs << xml::StartTag("div", "class='longtable-caption' style='text-align: " + align + ";'")
<< html::CR(); << xml::CR();
for (row_type r = 0; r < nrows(); ++r) for (row_type r = 0; r < nrows(); ++r)
if (row_info[r].caption) if (row_info[r].caption)
ret += xhtmlRow(xs, r, runparams); ret += xhtmlRow(xs, r, runparams);
xs << html::EndTag("div") << html::CR(); xs << xml::EndTag("div") << xml::CR();
} }
} }
xs << html::StartTag("table") << html::CR(); xs << xml::StartTag("table") << xml::CR();
// output header info // output header info
bool const havefirsthead = haveLTFirstHead(false); bool const havefirsthead = haveLTFirstHead(false);
@ -3750,7 +3750,7 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
// in XHTML. this test accomplishes that. // in XHTML. this test accomplishes that.
bool const havehead = !havefirsthead && haveLTHead(false); bool const havehead = !havefirsthead && haveLTHead(false);
if (havehead || havefirsthead) { if (havehead || havefirsthead) {
xs << html::StartTag("thead") << html::CR(); xs << xml::StartTag("thead") << xml::CR();
for (row_type r = 0; r < nrows(); ++r) { for (row_type r = 0; r < nrows(); ++r) {
if (((havefirsthead && row_info[r].endfirsthead) || if (((havefirsthead && row_info[r].endfirsthead) ||
(havehead && row_info[r].endhead)) && (havehead && row_info[r].endhead)) &&
@ -3758,14 +3758,14 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
ret += xhtmlRow(xs, r, runparams, true); ret += xhtmlRow(xs, r, runparams, true);
} }
} }
xs << html::EndTag("thead") << html::CR(); xs << xml::EndTag("thead") << xml::CR();
} }
// output footer info // output footer info
bool const havelastfoot = haveLTLastFoot(false); bool const havelastfoot = haveLTLastFoot(false);
// as before. // as before.
bool const havefoot = !havelastfoot && haveLTFoot(false); bool const havefoot = !havelastfoot && haveLTFoot(false);
if (havefoot || havelastfoot) { if (havefoot || havelastfoot) {
xs << html::StartTag("tfoot") << html::CR(); xs << xml::StartTag("tfoot") << xml::CR();
for (row_type r = 0; r < nrows(); ++r) { for (row_type r = 0; r < nrows(); ++r) {
if (((havelastfoot && row_info[r].endlastfoot) || if (((havelastfoot && row_info[r].endlastfoot) ||
(havefoot && row_info[r].endfoot)) && (havefoot && row_info[r].endfoot)) &&
@ -3773,21 +3773,21 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
ret += xhtmlRow(xs, r, runparams); ret += xhtmlRow(xs, r, runparams);
} }
} }
xs << html::EndTag("tfoot") << html::CR(); xs << xml::EndTag("tfoot") << xml::CR();
} }
xs << html::StartTag("tbody") << html::CR(); xs << xml::StartTag("tbody") << xml::CR();
for (row_type r = 0; r < nrows(); ++r) { for (row_type r = 0; r < nrows(); ++r) {
if (isValidRow(r)) { if (isValidRow(r)) {
ret += xhtmlRow(xs, r, runparams); ret += xhtmlRow(xs, r, runparams);
} }
} }
xs << html::EndTag("tbody") xs << xml::EndTag("tbody")
<< html::CR() << xml::CR()
<< html::EndTag("table") << xml::EndTag("table")
<< html::CR(); << xml::CR();
if (is_long_tabular) if (is_long_tabular)
xs << html::EndTag("div") << html::CR(); xs << xml::EndTag("div") << xml::CR();
return ret; return ret;
} }
@ -4167,7 +4167,7 @@ void InsetTableCell::addToToc(DocIterator const & di, bool output_active,
} }
docstring InsetTableCell::xhtml(XHTMLStream & xs, OutputParams const & rp) const docstring InsetTableCell::xhtml(XMLStream & xs, OutputParams const & rp) const
{ {
if (!isFixedWidth) if (!isFixedWidth)
return InsetText::insetAsXHTML(xs, rp, InsetText::JustText); return InsetText::insetAsXHTML(xs, rp, InsetText::JustText);
@ -4203,7 +4203,6 @@ void InsetTableCell::metrics(MetricsInfo & mi, Dimension & dim) const
} }
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
// //
// InsetTabular // InsetTabular
@ -6028,7 +6027,7 @@ int InsetTabular::docbook(odocstream & os, OutputParams const & runparams) const
} }
docstring InsetTabular::xhtml(XHTMLStream & xs, OutputParams const & rp) const docstring InsetTabular::xhtml(XMLStream & xs, OutputParams const & rp) const
{ {
return tabular.xhtml(xs, rp); return tabular.xhtml(xs, rp);
} }

View File

@ -44,7 +44,7 @@ class FuncStatus;
class Lexer; class Lexer;
class OutputParams; class OutputParams;
class Paragraph; class Paragraph;
class XHTMLStream; class XMLStream;
/// ///
@ -72,7 +72,7 @@ public:
/// descending into insets /// descending into insets
docstring asString(bool intoInsets = true); docstring asString(bool intoInsets = true);
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void addToToc(DocIterator const & di, bool output_active, void addToToc(DocIterator const & di, bool output_active,
UpdateType utype, TocBackend & backend) const; UpdateType utype, TocBackend & backend) const;
@ -573,7 +573,7 @@ public:
/// ///
int docbook(odocstream & os, OutputParams const &) const; int docbook(odocstream & os, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream & os, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void plaintext(odocstringstream &, void plaintext(odocstringstream &,
OutputParams const & runparams, int const depth, OutputParams const & runparams, int const depth,
@ -908,7 +908,7 @@ public:
/// auxiliary function for docbook /// auxiliary function for docbook
int docbookRow(odocstream & os, row_type, OutputParams const &) const; int docbookRow(odocstream & os, row_type, OutputParams const &) const;
/// ///
docstring xhtmlRow(XHTMLStream & xs, row_type, OutputParams const &, docstring xhtmlRow(XMLStream & xs, row_type, OutputParams const &,
bool header = false) const; bool header = false) const;
/// change associated Buffer /// change associated Buffer
@ -981,7 +981,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void validate(LaTeXFeatures & features) const; void validate(LaTeXFeatures & features) const;
/// ///

View File

@ -45,7 +45,7 @@
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
#include "ParIterator.h" #include "ParIterator.h"
#include "Row.h" #include "Row.h"
#include "sgml.h" #include "xml.h"
#include "TexRow.h" #include "TexRow.h"
#include "texstream.h" #include "texstream.h"
#include "TextClass.h" #include "TextClass.h"
@ -590,19 +590,19 @@ int InsetText::docbook(odocstream & os, OutputParams const & runparams) const
ParagraphList::const_iterator const beg = paragraphs().begin(); ParagraphList::const_iterator const beg = paragraphs().begin();
if (!undefined()) if (!undefined())
sgml::openTag(os, getLayout().latexname(), xml::openTag(os, getLayout().latexname(),
beg->getID(buffer(), runparams) + getLayout().latexparam()); beg->getID(buffer(), runparams) + getLayout().latexparam());
docbookParagraphs(text_, buffer(), os, runparams); docbookParagraphs(text_, buffer(), os, runparams);
if (!undefined()) if (!undefined())
sgml::closeTag(os, getLayout().latexname()); xml::closeTag(os, getLayout().latexname());
return 0; return 0;
} }
docstring InsetText::xhtml(XHTMLStream & xs, OutputParams const & runparams) const docstring InsetText::xhtml(XMLStream & xs, OutputParams const & runparams) const
{ {
return insetAsXHTML(xs, runparams, WriteEverything); return insetAsXHTML(xs, runparams, WriteEverything);
} }
@ -621,7 +621,7 @@ docstring InsetText::xhtml(XHTMLStream & xs, OutputParams const & runparams) con
// if so, try to close fonts, etc. // if so, try to close fonts, etc.
// There are probably limits to how well we can do here, though, and we will // There are probably limits to how well we can do here, though, and we will
// have to rely upon users not putting footnotes inside noun-type insets. // have to rely upon users not putting footnotes inside noun-type insets.
docstring InsetText::insetAsXHTML(XHTMLStream & xs, OutputParams const & rp, docstring InsetText::insetAsXHTML(XMLStream & xs, OutputParams const & rp,
XHTMLOptions opts) const XHTMLOptions opts) const
{ {
// we will always want to output all our paragraphs when we are // we will always want to output all our paragraphs when we are
@ -639,7 +639,7 @@ docstring InsetText::insetAsXHTML(XHTMLStream & xs, OutputParams const & rp,
InsetLayout const & il = getLayout(); InsetLayout const & il = getLayout();
if (opts & WriteOuterTag) if (opts & WriteOuterTag)
xs << html::StartTag(il.htmltag(), il.htmlattr()); xs << xml::StartTag(il.htmltag(), il.htmlattr());
if ((opts & WriteLabel) && !il.counter().empty()) { if ((opts & WriteLabel) && !il.counter().empty()) {
BufferParams const & bp = buffer().masterBuffer()->params(); BufferParams const & bp = buffer().masterBuffer()->params();
@ -651,15 +651,15 @@ docstring InsetText::insetAsXHTML(XHTMLStream & xs, OutputParams const & rp,
cntrs.counterLabel(from_utf8(il.htmllabel()), bp.language->code()); cntrs.counterLabel(from_utf8(il.htmllabel()), bp.language->code());
// FIXME is this check necessary? // FIXME is this check necessary?
if (!lbl.empty()) { if (!lbl.empty()) {
xs << html::StartTag(il.htmllabeltag(), il.htmllabelattr()); xs << xml::StartTag(il.htmllabeltag(), il.htmllabelattr());
xs << lbl; xs << lbl;
xs << html::EndTag(il.htmllabeltag()); xs << xml::EndTag(il.htmllabeltag());
} }
} }
} }
if (opts & WriteInnerTag) if (opts & WriteInnerTag)
xs << html::StartTag(il.htmlinnertag(), il.htmlinnerattr()); xs << xml::StartTag(il.htmlinnertag(), il.htmlinnerattr());
// we will eventually lose information about the containing inset // we will eventually lose information about the containing inset
if (!allowMultiPar() || opts == JustText) if (!allowMultiPar() || opts == JustText)
@ -672,10 +672,10 @@ docstring InsetText::insetAsXHTML(XHTMLStream & xs, OutputParams const & rp,
xs.endDivision(); xs.endDivision();
if (opts & WriteInnerTag) if (opts & WriteInnerTag)
xs << html::EndTag(il.htmlinnertag()); xs << xml::EndTag(il.htmlinnertag());
if (opts & WriteOuterTag) if (opts & WriteOuterTag)
xs << html::EndTag(il.htmltag()); xs << xml::EndTag(il.htmltag());
return docstring(); return docstring();
} }

View File

@ -83,7 +83,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
enum XHTMLOptions { enum XHTMLOptions {
JustText = 0, JustText = 0,
@ -93,7 +93,7 @@ public:
WriteEverything = 7 WriteEverything = 7
}; };
/// ///
docstring insetAsXHTML(XHTMLStream &, OutputParams const &, docstring insetAsXHTML(XMLStream &, OutputParams const &,
XHTMLOptions) const; XHTMLOptions) const;
/// ///
void validate(LaTeXFeatures & features) const; void validate(LaTeXFeatures & features) const;

View File

@ -231,11 +231,11 @@ int InsetVSpace::docbook(odocstream & os, OutputParams const &) const
} }
docstring InsetVSpace::xhtml(XHTMLStream & os, OutputParams const &) const docstring InsetVSpace::xhtml(XMLStream & os, OutputParams const &) const
{ {
string const len = space_.asHTMLLength(); string const len = space_.asHTMLLength();
string const attr = "style='height:" + (len.empty() ? "1em" : len) + "'"; string const attr = "style='height:" + (len.empty() ? "1em" : len) + "'";
os << html::StartTag("div", attr, true) << html::EndTag("div"); os << xml::StartTag("div", attr, true) << xml::EndTag("div");
return docstring(); return docstring();
} }

View File

@ -56,7 +56,7 @@ private:
/// The normal case is that this inset will be on a line by /// The normal case is that this inset will be on a line by
/// itself, and in that case the present paragraph will not, /// itself, and in that case the present paragraph will not,
/// in fact, appear at all. /// in fact, appear at all.
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void read(Lexer & lex); void read(Lexer & lex);
/// ///

View File

@ -217,17 +217,17 @@ int InsetWrap::docbook(odocstream & os, OutputParams const & runparams) const
} }
docstring InsetWrap::xhtml(XHTMLStream & xs, OutputParams const & rp) const docstring InsetWrap::xhtml(XMLStream & xs, OutputParams const & rp) const
{ {
string const len = params_.width.asHTMLString(); string const len = params_.width.asHTMLString();
string const width = len.empty() ? "50%" : len; string const width = len.empty() ? "50%" : len;
InsetLayout const & il = getLayout(); InsetLayout const & il = getLayout();
string const & tag = il.htmltag(); string const & tag = il.htmltag();
string const attr = il.htmlattr() + " style='width:" + width + ";'"; string const attr = il.htmlattr() + " style='width:" + width + ";'";
xs << html::StartTag(tag, attr); xs << xml::StartTag(tag, attr);
docstring const deferred = docstring const deferred =
InsetText::insetAsXHTML(xs, rp, InsetText::WriteInnerTag); InsetText::insetAsXHTML(xs, rp, InsetText::WriteInnerTag);
xs << html::EndTag(tag); xs << xml::EndTag(tag);
return deferred; return deferred;
} }

View File

@ -74,7 +74,7 @@ private:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
bool insetAllowed(InsetCode) const; bool insetAllowed(InsetCode) const;
/// ///

View File

@ -41,7 +41,7 @@
#include "output_xhtml.h" #include "output_xhtml.h"
#include "Paragraph.h" #include "Paragraph.h"
#include "ParIterator.h" #include "ParIterator.h"
#include "sgml.h" #include "xml.h"
#include "TexRow.h" #include "TexRow.h"
#include "TextClass.h" #include "TextClass.h"
#include "TextPainter.h" #include "TextPainter.h"
@ -2416,7 +2416,7 @@ int InsetMathHull::docbook(odocstream & os, OutputParams const & runparams) cons
docstring bname = name; docstring bname = name;
if (!label(0).empty()) if (!label(0).empty())
bname += " id='" + sgml::cleanID(buffer(), runparams, label(0)) + "'"; bname += " id='" + xml::cleanID(label(0)) + "'";
++ms.tab(); ms.cr(); ms.os() << '<' << bname << '>'; ++ms.tab(); ms.cr(); ms.os() << '<' << bname << '>';
@ -2446,9 +2446,9 @@ int InsetMathHull::docbook(odocstream & os, OutputParams const & runparams) cons
ms << from_ascii("<graphic fileref=\"eqn/"); ms << from_ascii("<graphic fileref=\"eqn/");
if (!label(0).empty()) if (!label(0).empty())
ms << sgml::cleanID(buffer(), runparams, label(0)); ms << xml::cleanID(label(0));
else else
ms << sgml::uniqueID(from_ascii("anon")); ms << xml::uniqueID(from_ascii("anon"));
if (runparams.flavor == OutputParams::XML) if (runparams.flavor == OutputParams::XML)
ms << from_ascii("\"/>"); ms << from_ascii("\"/>");
@ -2585,7 +2585,7 @@ void InsetMathHull::mathAsLatex(WriteStream & os) const
} }
docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const docstring InsetMathHull::xhtml(XMLStream & xs, OutputParams const & op) const
{ {
BufferParams::MathOutput const mathtype = BufferParams::MathOutput const mathtype =
buffer().masterBuffer()->params().html_math_output; buffer().masterBuffer()->params().html_math_output;
@ -2611,14 +2611,14 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
} catch (MathExportException const &) {} } catch (MathExportException const &) {}
if (success) { if (success) {
if (getType() == hullSimple) if (getType() == hullSimple)
xs << html::StartTag("math", xs << xml::StartTag("math",
"xmlns=\"http://www.w3.org/1998/Math/MathML\"", true); "xmlns=\"http://www.w3.org/1998/Math/MathML\"", true);
else else
xs << html::StartTag("math", xs << xml::StartTag("math",
"display=\"block\" xmlns=\"http://www.w3.org/1998/Math/MathML\"", true); "display=\"block\" xmlns=\"http://www.w3.org/1998/Math/MathML\"", true);
xs << XHTMLStream::ESCAPE_NONE xs << XMLStream::ESCAPE_NONE
<< os.str() << os.str()
<< html::EndTag("math"); << xml::EndTag("math");
} }
} else if (mathtype == BufferParams::HTML) { } else if (mathtype == BufferParams::HTML) {
odocstringstream os; odocstringstream os;
@ -2629,10 +2629,10 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
} catch (MathExportException const &) {} } catch (MathExportException const &) {}
if (success) { if (success) {
string const tag = (getType() == hullSimple) ? "span" : "div"; string const tag = (getType() == hullSimple) ? "span" : "div";
xs << html::StartTag(tag, "class='formula'", true) xs << xml::StartTag(tag, "class='formula'", true)
<< XHTMLStream::ESCAPE_NONE << XMLStream::ESCAPE_NONE
<< os.str() << os.str()
<< html::EndTag(tag); << xml::EndTag(tag);
} }
} }
@ -2672,11 +2672,11 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
} }
string const tag = (getType() == hullSimple) ? "span" : "div"; string const tag = (getType() == hullSimple) ? "span" : "div";
xs << html::CR() xs << xml::CR()
<< html::StartTag(tag, "style = \"text-align: center;\"") << xml::StartTag(tag, "style = \"text-align: center;\"")
<< html::CompTag("img", "src=\"" + filename + "\" alt=\"Mathematical Equation\"") << xml::CompTag("img", "src=\"" + filename + "\" alt=\"Mathematical Equation\"")
<< html::EndTag(tag) << xml::EndTag(tag)
<< html::CR(); << xml::CR();
success = true; success = true;
} }
} }
@ -2699,10 +2699,10 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
// FIXME XHTML // FIXME XHTML
// probably should allow for some kind of customization here // probably should allow for some kind of customization here
string const tag = (getType() == hullSimple) ? "span" : "div"; string const tag = (getType() == hullSimple) ? "span" : "div";
xs << html::StartTag(tag, "class='math'") xs << xml::StartTag(tag, "class='math'")
<< latex << latex
<< html::EndTag(tag) << xml::EndTag(tag)
<< html::CR(); << xml::CR();
} }
return docstring(); return docstring();
} }

View File

@ -146,7 +146,7 @@ public:
/// ///
int docbook(odocstream &, OutputParams const &) const; int docbook(odocstream &, OutputParams const &) const;
/// ///
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
void mathmlize(MathStream &) const; void mathmlize(MathStream &) const;
/// ///

View File

@ -1263,7 +1263,7 @@ int InsetMathMacroTemplate::write(WriteStream & os, bool overwriteRedefinition)
} }
docstring InsetMathMacroTemplate::xhtml(XHTMLStream &, OutputParams const &) const docstring InsetMathMacroTemplate::xhtml(XMLStream &, OutputParams const &) const
{ {
return docstring(); return docstring();
} }

View File

@ -21,7 +21,7 @@
namespace lyx { namespace lyx {
class OutputParams; class OutputParams;
class XHTMLStream; class XMLStream;
/// This class contains the macro definition. /// This class contains the macro definition.
class InsetMathMacroTemplate : public InsetMathNest { class InsetMathMacroTemplate : public InsetMathNest {
@ -52,7 +52,7 @@ public:
/// if overwriteRedefinition is true /// if overwriteRedefinition is true
int write(WriteStream & os, bool overwriteRedefinition) const; int write(WriteStream & os, bool overwriteRedefinition) const;
/// Nothing happens. This is simply to suppress the default output. /// Nothing happens. This is simply to suppress the default output.
docstring xhtml(XHTMLStream &, OutputParams const &) const; docstring xhtml(XMLStream &, OutputParams const &) const;
/// ///
int plaintext(odocstringstream &, OutputParams const &, size_t) const; int plaintext(odocstringstream &, OutputParams const &, size_t) const;
/// ///

View File

@ -24,7 +24,7 @@
#include "MathSupport.h" #include "MathSupport.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "ParIterator.h" #include "ParIterator.h"
#include "sgml.h" #include "xml.h"
#include "insets/InsetCommand.h" #include "insets/InsetCommand.h"
@ -186,14 +186,14 @@ int InsetMathRef::docbook(odocstream & os, OutputParams const & runparams) const
{ {
if (cell(1).empty()) { if (cell(1).empty()) {
os << "<xref linkend=\"" os << "<xref linkend=\""
<< sgml::cleanID(buffer(), runparams, asString(cell(0))); << xml::cleanID(asString(cell(0)));
if (runparams.flavor == OutputParams::XML) if (runparams.flavor == OutputParams::XML)
os << "\"/>"; os << "\"/>";
else else
os << "\">"; os << "\">";
} else { } else {
os << "<link linkend=\"" os << "<link linkend=\""
<< sgml::cleanID(buffer(), runparams, asString(cell(0))) << xml::cleanID(asString(cell(0)))
<< "\">" << "\">"
<< asString(cell(1)) << asString(cell(1))
<< "</link>"; << "</link>";

View File

@ -23,7 +23,7 @@
#include "Paragraph.h" #include "Paragraph.h"
#include "ParagraphList.h" #include "ParagraphList.h"
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
#include "sgml.h" #include "xml.h"
#include "Text.h" #include "Text.h"
#include "TextClass.h" #include "TextClass.h"
@ -41,6 +41,45 @@ namespace lyx {
namespace { 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 "";
}
}
ParagraphList::const_iterator searchParagraph( ParagraphList::const_iterator searchParagraph(
ParagraphList::const_iterator p, ParagraphList::const_iterator p,
ParagraphList::const_iterator const & pend) ParagraphList::const_iterator const & pend)
@ -115,10 +154,10 @@ ParagraphList::const_iterator makeParagraph(
par->simpleDocBookOnePar(buf, os, runparams, par->simpleDocBookOnePar(buf, os, runparams,
text.outerFont(distance(paragraphs.begin(), par))); text.outerFont(distance(paragraphs.begin(), par)));
} else { } else {
sgml::openTag(buf, os, runparams, *par); xml::openTag(buf, os, runparams, *par);
par->simpleDocBookOnePar(buf, os, runparams, par->simpleDocBookOnePar(buf, os, runparams,
text.outerFont(distance(paragraphs.begin(), par))); text.outerFont(distance(paragraphs.begin(), par)));
sgml::closeTag(os, *par); xml::closeTag(os, *par);
} }
} }
return pend; return pend;
@ -140,7 +179,7 @@ ParagraphList::const_iterator makeEnvironment(
Layout const & bstyle = par->layout(); Layout const & bstyle = par->layout();
// Opening outter tag // Opening outter tag
sgml::openTag(buf, os, runparams, *pbegin); xml::openTag(buf, os, runparams, *pbegin);
os << '\n'; os << '\n';
if (bstyle.latextype == LATEX_ENVIRONMENT && bstyle.pass_thru) if (bstyle.latextype == LATEX_ENVIRONMENT && bstyle.pass_thru)
os << "<![CDATA["; os << "<![CDATA[";
@ -156,23 +195,23 @@ ParagraphList::const_iterator makeEnvironment(
switch (bstyle.latextype) { switch (bstyle.latextype) {
case LATEX_ENVIRONMENT: case LATEX_ENVIRONMENT:
if (!bstyle.innertag().empty()) { if (!bstyle.innertag().empty()) {
sgml::openTag(os, bstyle.innertag(), id); xml::openTag(os, bstyle.innertag(), id);
} }
break; break;
case LATEX_ITEM_ENVIRONMENT: case LATEX_ITEM_ENVIRONMENT:
if (!bstyle.labeltag().empty()) { if (!bstyle.labeltag().empty()) {
sgml::openTag(os, bstyle.innertag(), id); xml::openTag(os, bstyle.innertag(), id);
sgml::openTag(os, bstyle.labeltag()); xml::openTag(os, bstyle.labeltag());
sep = par->firstWordDocBook(os, runparams) + 1; sep = par->firstWordDocBook(os, runparams) + 1;
sgml::closeTag(os, bstyle.labeltag()); xml::closeTag(os, bstyle.labeltag());
} }
wrapper = defaultstyle.latexname(); wrapper = defaultstyle.latexname();
// If a sub list (embedded list) appears next with a // If a sub list (embedded list) appears next with a
// different depth, then there is no need to open // different depth, then there is no need to open
// another tag at the current depth. // another tag at the current depth.
if(par->params().depth() == pbegin->params().depth()) { if(par->params().depth() == pbegin->params().depth()) {
sgml::openTag(os, bstyle.itemtag()); xml::openTag(os, bstyle.itemtag());
} }
break; break;
default: default:
@ -183,10 +222,10 @@ ParagraphList::const_iterator makeEnvironment(
case LATEX_ENVIRONMENT: case LATEX_ENVIRONMENT:
case LATEX_ITEM_ENVIRONMENT: { case LATEX_ITEM_ENVIRONMENT: {
if (par->params().depth() == pbegin->params().depth()) { if (par->params().depth() == pbegin->params().depth()) {
sgml::openTag(os, wrapper); xml::openTag(os, wrapper);
par->simpleDocBookOnePar(buf, os, runparams, par->simpleDocBookOnePar(buf, os, runparams,
text.outerFont(distance(paragraphs.begin(), par)), sep); text.outerFont(distance(paragraphs.begin(), par)), sep);
sgml::closeTag(os, wrapper); xml::closeTag(os, wrapper);
++par; ++par;
} }
else { else {
@ -212,7 +251,7 @@ ParagraphList::const_iterator makeEnvironment(
switch (bstyle.latextype) { switch (bstyle.latextype) {
case LATEX_ENVIRONMENT: case LATEX_ENVIRONMENT:
if (!bstyle.innertag().empty()) { if (!bstyle.innertag().empty()) {
sgml::closeTag(os, bstyle.innertag()); xml::closeTag(os, bstyle.innertag());
os << '\n'; os << '\n';
} }
break; break;
@ -226,10 +265,10 @@ ParagraphList::const_iterator makeEnvironment(
// when par == pend but at the same time that the // when par == pend but at the same time that the
// current tag is closed. // current tag is closed.
if((par != pend && par->params().depth() == pbegin->params().depth()) || par == pend) { if((par != pend && par->params().depth() == pbegin->params().depth()) || par == pend) {
sgml::closeTag(os, bstyle.itemtag()); xml::closeTag(os, bstyle.itemtag());
} }
if (!bstyle.labeltag().empty()) if (!bstyle.labeltag().empty())
sgml::closeTag(os, bstyle.innertag()); xml::closeTag(os, bstyle.innertag());
break; break;
default: default:
break; break;
@ -240,7 +279,7 @@ ParagraphList::const_iterator makeEnvironment(
os << "]]>"; os << "]]>";
// Closing outer tag // Closing outer tag
sgml::closeTag(os, *pbegin); xml::closeTag(os, *pbegin);
return pend; return pend;
} }
@ -259,22 +298,22 @@ ParagraphList::const_iterator makeCommand(
Layout const & bstyle = par->layout(); Layout const & bstyle = par->layout();
//Open outter tag //Open outter tag
sgml::openTag(buf, os, runparams, *pbegin); xml::openTag(buf, os, runparams, *pbegin);
os << '\n'; os << '\n';
// Label around sectioning number: // Label around sectioning number:
if (!bstyle.labeltag().empty()) { if (!bstyle.labeltag().empty()) {
sgml::openTag(os, bstyle.labeltag()); xml::openTag(os, bstyle.labeltag());
// We don't care about appendix in DOCBOOK. // We don't care about appendix in DOCBOOK.
os << par->expandDocBookLabel(bstyle, buf.params()); os << par->expandDocBookLabel(bstyle, buf.params());
sgml::closeTag(os, bstyle.labeltag()); xml::closeTag(os, bstyle.labeltag());
} }
// Opend inner tag and close inner tags // Opend inner tag and close inner tags
sgml::openTag(os, bstyle.innertag()); xml::openTag(os, bstyle.innertag());
par->simpleDocBookOnePar(buf, os, runparams, par->simpleDocBookOnePar(buf, os, runparams,
text.outerFont(distance(paragraphs.begin(), par))); text.outerFont(distance(paragraphs.begin(), par)));
sgml::closeTag(os, bstyle.innertag()); xml::closeTag(os, bstyle.innertag());
os << '\n'; os << '\n';
++par; ++par;
@ -307,7 +346,7 @@ ParagraphList::const_iterator makeCommand(
} }
} }
// Close outter tag // Close outter tag
sgml::closeTag(os, *pbegin); xml::closeTag(os, *pbegin);
return pend; return pend;
} }

View File

@ -14,9 +14,12 @@
#define OUTPUT_DOCBOOK_H #define OUTPUT_DOCBOOK_H
#include "support/strfwd.h" #include "support/strfwd.h"
#include "xml.h"
namespace lyx { namespace lyx {
std::string const fontToDocBookTag(xml::FontTypes type);
class Buffer; class Buffer;
class OutputParams; class OutputParams;
class Text; class Text;

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,7 @@
#include "support/docstream.h" #include "support/docstream.h"
#include "support/strfwd.h" #include "support/strfwd.h"
#include "xml.h"
#include <deque> #include <deque>
#include <memory> #include <memory>
@ -23,286 +24,27 @@
namespace lyx { namespace lyx {
docstring const & fontToHtmlTag(xml::FontTypes type);
class Buffer; class Buffer;
class OutputParams; class OutputParams;
class Text; class Text;
// Inspiration for the *Tag structs and for XHTMLStream
// came from MathStream and its cousins.
namespace html {
struct FontTag;
struct EndFontTag;
/// Attributes will be escaped automatically and so should NOT
/// be escaped before being passed to the constructor.
struct StartTag
{
///
explicit StartTag(std::string const & tag) : tag_(tag), keepempty_(false) {}
///
explicit StartTag(std::string const & tag, std::string const & attr,
bool keepempty = false)
: tag_(tag), attr_(attr), keepempty_(keepempty) {}
///
virtual ~StartTag() {}
/// <tag_ attr_>
virtual docstring writeTag() const;
/// </tag_>
virtual docstring writeEndTag() const;
///
virtual FontTag const * asFontTag() const { return 0; }
///
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;
///
std::string tag_;
///
std::string 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 xml::FontTag xhtmlStartFontTag(xml::FontTypes type);
{
///
explicit EndTag(std::string const & 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; }
///
std::string tag_;
};
/// Tags like <img />
/// Attributes will be escaped automatically and so should NOT
/// 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_;
};
/// A special case of StartTag, used exclusively for tags that wrap paragraphs.
struct ParTag : public StartTag
{
///
explicit ParTag(std::string const & tag, std::string attr,
std::string const & parid);
///
~ParTag() {}
};
/// ///
enum FontTypes { xml::EndFontTag xhtmlEndFontTag(xml::FontTypes type);
// 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
};
///
struct FontTag : public StartTag
{
///
explicit FontTag(FontTypes type);
///
FontTag const * asFontTag() const { return this; }
///
bool operator==(StartTag const &) const;
///
FontTypes font_type_;
};
///
struct EndFontTag : public EndTag
{
///
explicit EndFontTag(FontTypes type);
///
EndFontTag const * asFontTag() const { return this; }
///
FontTypes font_type_;
};
// trivial struct for output of newlines
struct CR{};
} // namespace html
class XHTMLStream {
public:
///
explicit XHTMLStream(odocstream & os);
///
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();
///
XHTMLStream & operator<<(docstring const &);
///
XHTMLStream & operator<<(const char *);
///
XHTMLStream & operator<<(char_type);
///
XHTMLStream & operator<<(int);
///
XHTMLStream & operator<<(char);
///
XHTMLStream & operator<<(html::StartTag const &);
///
XHTMLStream & operator<<(html::EndTag const &);
///
XHTMLStream & operator<<(html::CompTag const &);
///
XHTMLStream & operator<<(html::ParTag const &);
///
XHTMLStream & operator<<(html::FontTag const &);
///
XHTMLStream & operator<<(html::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.
XHTMLStream & 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);
private:
///
void clearTagDeque();
///
bool isTagOpen(html::StartTag const &) const;
///
bool isTagOpen(html::EndTag const &) const;
///
bool isTagPending(html::StartTag const &) const;
///
void writeError(std::string 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<html::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 xhtmlParagraphs(Text const & text, void xhtmlParagraphs(Text const & text,
Buffer const & buf, Buffer const & buf,
XHTMLStream & xs, XMLStream & xs,
OutputParams const & runparams); OutputParams const & runparams);
/// \return a string appropriate for setting alignment in CSS /// \return a string appropriate for setting alignment in CSS
/// Does NOT return "justify" for "block" /// Does NOT return "justify" for "block"
std::string alignmentToCSS(LyXAlignment align); std::string alignmentToCSS(LyXAlignment align);
namespace html {
///
docstring escapeChar(char_type c, XHTMLStream::EscapeSettings e);
/// converts a string to a form safe for links, etc
docstring htmlize(docstring const & str, XHTMLStream::EscapeSettings e);
/// cleans \param str for use as an atttribute by replacing
/// all non-alnum by "_"
docstring cleanAttr(docstring const & str);
/// \p c must be ASCII
docstring escapeChar(char c, XHTMLStream::EscapeSettings e);
} // namespace html
} // namespace lyx } // namespace lyx
#endif #endif

View File

@ -1,257 +0,0 @@
/**
* \file sgml.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author José Matos
* \author John Levon
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "sgml.h"
#include "Buffer.h"
#include "BufferParams.h"
#include "Counters.h"
#include "Layout.h"
#include "OutputParams.h"
#include "Paragraph.h"
#include "Text.h"
#include "TextClass.h"
#include "support/convert.h"
#include "support/docstream.h"
#include "support/lstrings.h"
#include "support/textutils.h"
#include <atomic>
#include <map>
#include <QThreadStorage>
using namespace std;
using namespace lyx::support;
namespace lyx {
docstring sgml::escapeChar(char_type c)
{
docstring str;
switch (c) {
case ' ':
str += " ";
break;
case '&':
str += "&amp;";
break;
case '<':
str += "&lt;";
break;
case '>':
str += "&gt;";
break;
#if 0
case '$':
str += "&dollar;";
break;
case '#':
str += "&num;";
break;
case '%':
str += "&percnt;";
break;
case '[':
str += "&lsqb;";
break;
case ']':
str += "&rsqb;";
break;
case '{':
str += "&lcub;";
break;
case '}':
str += "&rcub;";
break;
case '~':
str += "&tilde;";
break;
case '"':
str += "&quot;";
break;
case '\\':
str += "&bsol;";
break;
#endif
default:
str += c;
break;
}
return str;
}
docstring sgml::escapeString(docstring const & raw)
{
docstring bin;
bin.reserve(raw.size() * 2); // crude approximation is sufficient
for (size_t i = 0; i != raw.size(); ++i)
bin += sgml::escapeChar(raw[i]);
return bin;
}
docstring const sgml::uniqueID(docstring const & label)
{
// thread-safe
static atomic_uint seed(1000);
return label + convert<docstring>(++seed);
}
docstring sgml::cleanID(Buffer const & buf, OutputParams const & runparams,
docstring const & orig)
{
// The standard DocBook SGML declaration only allows letters,
// digits, '-' and '.' in a name.
// Since users might change that declaration one has to cater
// for additional allowed characters.
// This routine replaces illegal characters by '-' or '.'
// and adds a number for uniqueness.
// If you know what you are doing, you can set allowed==""
// to disable this mangling.
DocumentClass const & tclass = buf.params().documentClass();
docstring const allowed = from_ascii(
runparams.flavor == OutputParams::XML ? ".-_:" : tclass.options());
if (allowed.empty())
return orig;
docstring::const_iterator it = orig.begin();
docstring::const_iterator end = orig.end();
docstring content;
typedef map<docstring, docstring> MangledMap;
static QThreadStorage<MangledMap> tMangledNames;
static QThreadStorage<int> tMangleID;
MangledMap & mangledNames = tMangledNames.localData();
MangledMap::const_iterator const known = mangledNames.find(orig);
if (known != mangledNames.end())
return known->second;
// make sure it starts with a letter
if (!isAlphaASCII(*it) && allowed.find(*it) >= allowed.size())
content += "x";
bool mangle = false;
for (; it != end; ++it) {
char_type c = *it;
if (isAlphaASCII(c) || isDigitASCII(c) || c == '-' || c == '.'
|| allowed.find(c) < allowed.size())
content += c;
else if (c == '_' || c == ' ') {
mangle = true;
content += "-";
}
else if (c == ':' || c == ',' || c == ';' || c == '!') {
mangle = true;
content += ".";
}
else {
mangle = true;
}
}
if (mangle) {
int & mangleID = tMangleID.localData();
content += "-" + convert<docstring>(mangleID++);
} else if (isDigitASCII(content[content.size() - 1]))
content += ".";
mangledNames[orig] = content;
return content;
}
void sgml::openTag(odocstream & os, string const & name, string const & attribute)
{
// FIXME UNICODE
// This should be fixed in layout files later.
string param = subst(attribute, "<", "\"");
param = subst(param, ">", "\"");
// Note: we ignore the name if it empty or if it is a comment "<!-- -->" or
// if the name is *dummy*.
// We ignore dummy because dummy is not a valid docbook element and it is
// the internal name given to single paragraphs in the latex output.
// This allow us to simplify the code a lot and is a reasonable compromise.
if (!name.empty() && name != "!-- --" && name != "dummy") {
os << '<' << from_ascii(name);
if (!param.empty())
os << ' ' << from_ascii(param);
os << '>';
}
}
void sgml::closeTag(odocstream & os, string const & name)
{
if (!name.empty() && name != "!-- --" && name != "dummy")
os << "</" << from_ascii(name) << '>';
}
void sgml::openTag(Buffer const & buf, odocstream & os,
OutputParams const & runparams, Paragraph const & par)
{
Layout const & style = par.layout();
string const & name = style.latexname();
string param = style.latexparam();
Counters & counters = buf.params().documentClass().counters();
string id = par.getID(buf, runparams);
string attribute;
if (!id.empty()) {
if (param.find('#') != string::npos) {
string::size_type pos = param.find("id=<");
string::size_type end = param.find(">");
if( pos != string::npos && end != string::npos)
param.erase(pos, end-pos + 1);
}
attribute = id + ' ' + param;
} else {
if (param.find('#') != string::npos) {
// FIXME UNICODE
if (!style.counter.empty())
// This uses InternalUpdate at the moment becuase sgml output
// does not do anything with tracked counters, and it would need
// to track layouts if it did want to use them.
counters.step(style.counter, InternalUpdate);
else
counters.step(from_ascii(name), InternalUpdate);
int i = counters.value(from_ascii(name));
attribute = subst(param, "#", convert<string>(i));
} else {
attribute = param;
}
}
openTag(os, name, attribute);
}
void sgml::closeTag(odocstream & os, Paragraph const & par)
{
Layout const & style = par.layout();
closeTag(os, style.latexname());
}
} // namespace lyx

View File

@ -1,59 +0,0 @@
// -*- C++ -*-
/**
* \file sgml.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author José Matos
* \author John Levon
*
* Full author contact details are available in file CREDITS.
*/
#ifndef SGML_H
#define SGML_H
#include "support/docstring.h"
namespace lyx {
class Buffer;
class Paragraph;
class OutputParams;
namespace sgml {
/**
* Escape the given character, if necessary,
* to an SGML entity.
*/
docstring escapeChar(char_type c);
/// Escape a word instead of a single character
docstring escapeString(docstring const & raw);
/// replaces illegal characters from SGML/XML ID attributes
docstring cleanID(Buffer const & buf, OutputParams const & runparams,
docstring const & orig);
/// returns a unique numeric id
docstring const uniqueID(docstring const & label);
/// Opens tag
void openTag(odocstream & os, std::string const & name,
std::string const & attribute = std::string());
/// Open tag
void openTag(Buffer const & buf, odocstream & os,
OutputParams const & runparams, Paragraph const & par);
/// Close tag
void closeTag(odocstream & os, std::string const & name);
/// Close tag
void closeTag(odocstream & os, Paragraph const & par);
} // namespace sgml
} // namespace lyx
#endif // SGML_H

View File

@ -5,6 +5,7 @@
#include "LyXRC.h" #include "LyXRC.h"
#include "support/Messages.h" #include "support/Messages.h"
#include "xml.h"
using namespace std; using namespace std;
@ -49,4 +50,10 @@ string alignmentToCSS(LyXAlignment)
return string(); return string();
} }
namespace xml {
docstring StartTag::writeTag() const { return docstring(); }
docstring StartTag::writeEndTag() const { return docstring(); }
bool StartTag::operator==(FontTag const & rhs) const { return rhs == *this; }
}
} // namespace lyx } // namespace lyx

View File

@ -114,4 +114,10 @@ string alignmentToCSS(LyXAlignment)
void lyx_exit(int) void lyx_exit(int)
{} {}
namespace xml {
docstring StartTag::writeTag() const { return docstring(); }
docstring StartTag::writeEndTag() const { return docstring(); }
bool StartTag::operator==(FontTag const & rhs) const { return rhs == *this; }
}
} // namespace lyx } // namespace lyx

690
src/xml.cpp Normal file
View File

@ -0,0 +1,690 @@
/**
* \file xml.cpp
* This file is part of LyX, the document processor.
* License details can be found in the file COPYING.
*
* \author José Matos
* \author John Levon
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "xml.h"
#include "Buffer.h"
#include "BufferParams.h"
#include "Counters.h"
#include "Layout.h"
#include "OutputParams.h"
#include "Paragraph.h"
#include "Text.h"
#include "TextClass.h"
#include "support/convert.h"
#include "support/docstream.h"
#include "support/lstrings.h"
#include "support/textutils.h"
#include <atomic>
#include <map>
#include <functional>
#include <QThreadStorage>
#include <support/lassert.h>
using namespace std;
using namespace lyx::support;
namespace lyx {
namespace xml {
docstring escapeChar(char_type c, XMLStream::EscapeSettings e)
{
docstring str;
switch (e) { // For HTML: always ESCAPE_NONE. For XML: it depends, hence the parameter.
case XMLStream::ESCAPE_NONE:
str += c;
break;
case XMLStream::ESCAPE_ALL:
if (c == '<') {
str += "&lt;";
break;
} else if (c == '>') {
str += "&gt;";
break;
}
// fall through
case XMLStream::ESCAPE_AND:
if (c == '&')
str += "&amp;";
else
str +=c ;
break;
}
return str;
}
// escape what needs escaping
docstring xmlize(docstring const &str, XMLStream::EscapeSettings e) {
odocstringstream d;
docstring::const_iterator it = str.begin();
docstring::const_iterator en = str.end();
for (; it != en; ++it)
d << escapeChar(*it, e);
return d.str();
}
docstring escapeChar(char c, XMLStream::EscapeSettings e) {
LATTEST(static_cast<unsigned char>(c) < 0x80);
return escapeChar(static_cast<char_type>(c), e);
}
docstring cleanAttr(docstring const & str)
{
docstring newname;
docstring::const_iterator it = str.begin();
docstring::const_iterator en = str.end();
for (; it != en; ++it) {
char_type const c = *it;
newname += isAlnumASCII(c) ? c : char_type('_');
}
return newname;
}
docstring StartTag::writeTag() const {
docstring output = '<' + tag_;
if (!attr_.empty()) {
docstring attributes = xml::xmlize(attr_, XMLStream::ESCAPE_NONE);
attributes.erase(attributes.begin(), std::find_if(attributes.begin(), attributes.end(),
[](int c) {return !std::isspace(c);}));
if (!attributes.empty()) {
output += ' ' + attributes;
}
}
output += ">";
return output;
}
docstring StartTag::writeEndTag() const {
return from_utf8("</") + tag_ + from_utf8(">");
}
bool StartTag::operator==(FontTag const &rhs) const {
return rhs == *this;
}
docstring EndTag::writeEndTag() const {
return from_utf8("</") + tag_ + from_utf8(">");
}
docstring CompTag::writeTag() const {
docstring output = '<' + from_utf8(tag_);
if (!attr_.empty()) {
// Erase the beginning of the attributes if it contains space characters: this function deals with that
// automatically.
docstring attributes = xmlize(from_utf8(attr_), XMLStream::ESCAPE_NONE);
attributes.erase(attributes.begin(), std::find_if(attributes.begin(), attributes.end(),
[](int c) {return !std::isspace(c);}));
if (!attributes.empty()) {
output += ' ' + attributes;
}
}
output += " />";
return output;
}
bool FontTag::operator==(StartTag const & tag) const
{
FontTag const * const ftag = tag.asFontTag();
if (!ftag)
return false;
return (font_type_ == ftag->font_type_);
}
} // namespace xml
void XMLStream::writeError(std::string const &s) const {
LYXERR0(s);
os_ << from_utf8("<!-- Output Error: " + s + " -->\n");
}
void XMLStream::writeError(docstring const &s) const {
LYXERR0(s);
os_ << from_utf8("<!-- Output Error: ") << s << from_utf8(" -->\n");
}
bool XMLStream::closeFontTags() {
if (isTagPending(xml::parsep_tag))
// we haven't had any content
return true;
// this may be a useless check, since we ought at least to have
// the parsep_tag. but it can't hurt too much to be careful.
if (tag_stack_.empty())
return true;
// first, we close any open font tags we can close
TagPtr *curtag = &tag_stack_.back();
while ((*curtag)->asFontTag()) {
if (**curtag != xml::parsep_tag)
os_ << (*curtag)->writeEndTag();
tag_stack_.pop_back();
// this shouldn't happen, since then the font tags
// weren't in any other tag.
LASSERT(!tag_stack_.empty(), return true);
curtag = &tag_stack_.back();
}
if (**curtag == xml::parsep_tag)
return true;
// so we've hit a non-font tag.
writeError("Tags still open in closeFontTags(). Probably not a problem,\n"
"but you might want to check these tags:");
TagDeque::const_reverse_iterator it = tag_stack_.rbegin();
TagDeque::const_reverse_iterator const en = tag_stack_.rend();
for (; it != en; ++it) {
if (**it == xml::parsep_tag)
break;
writeError((*it)->tag_);
}
return false;
}
void XMLStream::startDivision(bool keep_empty) {
pending_tags_.push_back(makeTagPtr(xml::StartTag(xml::parsep_tag)));
if (keep_empty)
clearTagDeque();
}
void XMLStream::endDivision() {
if (isTagPending(xml::parsep_tag)) {
// this case is normal. it just means we didn't have content,
// so the parsep_tag never got moved onto the tag stack.
while (!pending_tags_.empty()) {
// clear all pending tags up to and including the parsep tag.
// note that we work from the back, because we want to get rid
// of everything that hasn't been used.
TagPtr const cur_tag = pending_tags_.back();
pending_tags_.pop_back();
if (*cur_tag == xml::parsep_tag)
break;
}
#ifdef XHTML_DEBUG
dumpTagStack("EndDivision");
#endif
return;
}
if (!isTagOpen(xml::parsep_tag)) {
writeError("No division separation tag found in endDivision().");
return;
}
// this case is also normal, if the parsep tag is the last one
// on the stack. otherwise, it's an error.
while (!tag_stack_.empty()) {
TagPtr const cur_tag = tag_stack_.back();
tag_stack_.pop_back();
if (*cur_tag == xml::parsep_tag)
break;
writeError("Tag `" + cur_tag->tag_ + "' still open at end of paragraph. Closing.");
os_ << cur_tag->writeEndTag();
}
#ifdef XHTML_DEBUG
dumpTagStack("EndDivision");
#endif
}
void XMLStream::clearTagDeque() {
while (!pending_tags_.empty()) {
TagPtr const & tag = pending_tags_.front();
if (*tag != xml::parsep_tag)
// tabs?
os_ << tag->writeTag();
tag_stack_.push_back(tag);
pending_tags_.pop_front();
}
}
XMLStream &XMLStream::operator<<(docstring const &d) {
clearTagDeque();
os_ << xml::xmlize(d, escape_);
escape_ = ESCAPE_ALL;
return *this;
}
XMLStream &XMLStream::operator<<(const char *s) {
clearTagDeque();
docstring const d = from_ascii(s);
os_ << xml::xmlize(d, escape_);
escape_ = ESCAPE_ALL;
return *this;
}
XMLStream &XMLStream::operator<<(char_type c) {
clearTagDeque();
os_ << xml::escapeChar(c, escape_);
escape_ = ESCAPE_ALL;
return *this;
}
XMLStream &XMLStream::operator<<(char c) {
clearTagDeque();
os_ << xml::escapeChar(c, escape_);
escape_ = ESCAPE_ALL;
return *this;
}
XMLStream &XMLStream::operator<<(int i) {
clearTagDeque();
os_ << i;
escape_ = ESCAPE_ALL;
return *this;
}
XMLStream &XMLStream::operator<<(EscapeSettings e) {
escape_ = e;
return *this;
}
XMLStream &XMLStream::operator<<(xml::StartTag const &tag) {
if (tag.tag_.empty())
return *this;
pending_tags_.push_back(makeTagPtr(tag));
if (tag.keepempty_)
clearTagDeque();
return *this;
}
XMLStream &XMLStream::operator<<(xml::ParTag const &tag) {
if (tag.tag_.empty())
return *this;
pending_tags_.push_back(makeTagPtr(tag));
return *this;
}
XMLStream &XMLStream::operator<<(xml::CompTag const &tag) {
if (tag.tag_.empty())
return *this;
clearTagDeque();
os_ << tag.writeTag();
return *this;
}
XMLStream &XMLStream::operator<<(xml::FontTag const &tag) {
if (tag.tag_.empty())
return *this;
pending_tags_.push_back(makeTagPtr(tag));
return *this;
}
XMLStream &XMLStream::operator<<(xml::CR const &) {
os_ << from_ascii("\n");
return *this;
}
bool XMLStream::isTagOpen(xml::StartTag const &stag) const {
auto sit = tag_stack_.begin();
auto sen = tag_stack_.cend();
for (; sit != sen; ++sit)
if (**sit == stag)
return true;
return false;
}
bool XMLStream::isTagOpen(xml::EndTag const &etag) const {
auto sit = tag_stack_.begin();
auto sen = tag_stack_.cend();
for (; sit != sen; ++sit)
if (etag == **sit)
return true;
return false;
}
bool XMLStream::isTagPending(xml::StartTag const &stag) const {
auto sit = pending_tags_.begin();
auto sen = pending_tags_.cend();
for (; sit != sen; ++sit)
if (**sit == stag)
return true;
return false;
}
// this is complicated, because we want to make sure that
// everything is properly nested. the code ought to make
// sure of that, but we won't assert (yet) if we run into
// a problem. we'll just output error messages and try our
// best to make things work.
XMLStream &XMLStream::operator<<(xml::EndTag const &etag) {
if (etag.tag_.empty())
return *this;
// if this tag is pending, we can simply discard it.
if (!pending_tags_.empty()) {
if (etag == *pending_tags_.back()) {
// we have <tag></tag>, so we discard it and remove it
// from the pending_tags_.
pending_tags_.pop_back();
return *this;
}
// there is a pending tag that isn't the one we are trying
// to close.
// is this tag itself pending?
// non-const iterators because we may call erase().
TagDeque::iterator dit = pending_tags_.begin();
TagDeque::iterator const den = pending_tags_.end();
for (; dit != den; ++dit) {
if (etag == **dit) {
// it was pending, so we just erase it
writeError("Tried to close pending tag `" + to_utf8(etag.tag_)
+ "' when other tags were pending. Last pending tag is `"
+ to_utf8(pending_tags_.back()->writeTag())
+ "'. Tag discarded.");
pending_tags_.erase(dit);
return *this;
}
}
// so etag isn't itself pending. is it even open?
if (!isTagOpen(etag)) {
writeError("Tried to close `" + to_utf8(etag.tag_)
+ "' when tag was not open. Tag discarded.");
return *this;
}
// ok, so etag is open.
// our strategy will be as below: we will do what we need to
// do to close this tag.
string estr = "Closing tag `" + to_utf8(etag.tag_)
+ "' when other tags are pending. Discarded pending tags:\n";
for (dit = pending_tags_.begin(); dit != den; ++dit)
estr += to_utf8(xml::xmlize((*dit)->writeTag(), XMLStream::ESCAPE_ALL)) + "\n";
writeError(estr);
// clear the pending tags...
pending_tags_.clear();
// ...and then just fall through.
}
// make sure there are tags to be closed
if (tag_stack_.empty()) {
writeError("Tried to close `" + etag.tag_
+ "' when no tags were open!");
return *this;
}
// is the tag we are closing the last one we opened?
if (etag == *tag_stack_.back()) {
// output it...
os_ << etag.writeEndTag();
// ...and forget about it
tag_stack_.pop_back();
return *this;
}
// we are trying to close a tag other than the one last opened.
// let's first see if this particular tag is still open somehow.
if (!isTagOpen(etag)) {
writeError("Tried to close `" + etag.tag_
+ "' when tag was not open. Tag discarded.");
return *this;
}
// so the tag was opened, but other tags have been opened since
// and not yet closed.
// if it's a font tag, though...
if (etag.asFontTag()) {
// it won't be a problem if the other tags open since this one
// are also font tags.
TagDeque::const_reverse_iterator rit = tag_stack_.rbegin();
TagDeque::const_reverse_iterator ren = tag_stack_.rend();
for (; rit != ren; ++rit) {
if (etag == **rit)
break;
if (!(*rit)->asFontTag()) {
// we'll just leave it and, presumably, have to close it later.
writeError("Unable to close font tag `" + etag.tag_
+ "' due to open non-font tag `" + (*rit)->tag_ + "'.");
return *this;
}
}
// so we have e.g.:
// <em>this is <strong>bold
// and are being asked to closed em. we want:
// <em>this is <strong>bold</strong></em><strong>
// first, we close the intervening tags...
TagPtr *curtag = &tag_stack_.back();
// ...remembering them in a stack.
TagDeque fontstack;
while (etag != **curtag) {
os_ << (*curtag)->writeEndTag();
fontstack.push_back(*curtag);
tag_stack_.pop_back();
curtag = &tag_stack_.back();
}
os_ << etag.writeEndTag();
tag_stack_.pop_back();
// ...and restore the other tags.
rit = fontstack.rbegin();
ren = fontstack.rend();
for (; rit != ren; ++rit)
pending_tags_.push_back(*rit);
return *this;
}
// it wasn't a font tag.
// so other tags were opened before this one and not properly closed.
// so we'll close them, too. that may cause other issues later, but it
// at least guarantees proper nesting.
writeError("Closing tag `" + etag.tag_
+ "' when other tags are open, namely:");
TagPtr *curtag = &tag_stack_.back();
while (etag != **curtag) {
writeError((*curtag)->tag_);
if (**curtag != xml::parsep_tag)
os_ << (*curtag)->writeEndTag();
tag_stack_.pop_back();
curtag = &tag_stack_.back();
}
// curtag is now the one we actually want.
os_ << (*curtag)->writeEndTag();
tag_stack_.pop_back();
return *this;
}
docstring xml::escapeString(docstring const & raw, XMLStream::EscapeSettings e)
{
docstring bin;
bin.reserve(raw.size() * 2); // crude approximation is sufficient
for (size_t i = 0; i != raw.size(); ++i)
bin += xml::escapeChar(raw[i], e);
return bin;
}
docstring const xml::uniqueID(docstring const & label)
{
// thread-safe
static atomic_uint seed(1000);
return label + convert<docstring>(++seed);
}
docstring xml::cleanID(docstring const &orig)
{
// The standard xml:id only allows letters,
// digits, '-' and '.' in a name.
// This routine replaces illegal characters by '-' or '.'
// and adds a number for uniqueness if need be.
docstring const allowed = from_ascii(".-_");
// Use a cache of already mangled names: the alterations may merge several IDs as one. This ensures that the IDs
// are not mixed up in the document.
typedef map<docstring, docstring> MangledMap;
static QThreadStorage<MangledMap> tMangledNames;
static QThreadStorage<int> tMangleID;
MangledMap & mangledNames = tMangledNames.localData();
// If the name is already known, just return it.
MangledMap::const_iterator const known = mangledNames.find(orig);
if (known != mangledNames.end())
return known->second;
// Start creating the mangled name by iterating over the characters.
docstring content;
docstring::const_iterator it = orig.begin();
docstring::const_iterator end = orig.end();
// Make sure it starts with a letter.
if (!isAlphaASCII(*it) && allowed.find(*it) >= allowed.size())
content += "x";
// Do the mangling.
bool mangle = false; // Indicates whether the ID had to be changed, i.e. if ID no more ensured to be unique.
for (; it != end; ++it) {
char_type c = *it;
if (isAlphaASCII(c) || isDigitASCII(c) || c == '-' || c == '.'
|| allowed.find(c) < allowed.size())
content += c;
else if (c == '_' || c == ' ') {
mangle = true;
content += "-";
}
else if (c == ':' || c == ',' || c == ';' || c == '!') {
mangle = true;
content += ".";
}
else {
mangle = true;
content += "-";
}
}
if (mangle) {
int & mangleID = tMangleID.localData();
content += "-" + convert<docstring>(mangleID++);
} else if (isDigitASCII(content[content.size() - 1]))
content += ".";
mangledNames[orig] = content;
return content;
}
void xml::openTag(odocstream & os, string const & name, string const & attribute)
{
// FIXME UNICODE
// This should be fixed in layout files later.
string param = subst(attribute, "<", "\"");
param = subst(param, ">", "\"");
// Note: we ignore the name if it empty or if it is a comment "<!-- -->" or
// if the name is *dummy*.
// We ignore dummy because dummy is not a valid docbook element and it is
// the internal name given to single paragraphs in the latex output.
// This allow us to simplify the code a lot and is a reasonable compromise.
if (!name.empty() && name != "!-- --" && name != "dummy") {
os << '<' << from_ascii(name);
if (!param.empty())
os << ' ' << from_ascii(param);
os << '>';
}
}
void xml::closeTag(odocstream & os, string const & name)
{
if (!name.empty() && name != "!-- --" && name != "dummy")
os << "</" << from_ascii(name) << '>';
}
void xml::openTag(Buffer const & buf, odocstream & os,
OutputParams const & runparams, Paragraph const & par)
{
Layout const & style = par.layout();
string const & name = style.latexname();
string param = style.latexparam();
Counters & counters = buf.params().documentClass().counters();
string id = par.getID(buf, runparams);
string attribute;
if (!id.empty()) {
if (param.find('#') != string::npos) {
string::size_type pos = param.find("id=<");
string::size_type end = param.find(">");
if( pos != string::npos && end != string::npos)
param.erase(pos, end-pos + 1);
}
attribute = id + ' ' + param;
} else {
if (param.find('#') != string::npos) {
// FIXME UNICODE
if (!style.counter.empty())
// This uses InternalUpdate at the moment becuase xml output
// does not do anything with tracked counters, and it would need
// to track layouts if it did want to use them.
counters.step(style.counter, InternalUpdate);
else
counters.step(from_ascii(name), InternalUpdate);
int i = counters.value(from_ascii(name));
attribute = subst(param, "#", convert<string>(i));
} else {
attribute = param;
}
}
openTag(os, name, attribute);
}
void xml::closeTag(odocstream & os, Paragraph const & par)
{
Layout const & style = par.layout();
closeTag(os, style.latexname());
}
} // namespace lyx

355
src/xml.h Normal file
View File

@ -0,0 +1,355 @@
// -*- C++ -*-
/**
* \file xml.h
* This file is part of LyX, the document processor.
* License details can be found in the file COPYING.
*
* \author José Matos
* \author John Levon
*
* Full author contact details are available in file CREDITS.
*/
#ifndef XML_H
#define XML_H
#include "support/docstring.h"
#include <deque>
#include <memory>
namespace lyx {
class Buffer;
class Paragraph;
class OutputParams;
// Inspiration for the *Tag structs and for XMLStream
// came from MathStream and its cousins.
namespace xml {
struct StartTag;
struct EndTag;
struct CompTag;
struct ParTag;
struct FontTag;
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);
private:
///
void clearTagDeque();
///
bool isTagOpen(xml::StartTag const &) const;
///
bool isTagOpen(xml::EndTag const &) const;
///
bool isTagPending(xml::StartTag const &) const;
///
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 {
/// Escape the given character, if necessary, to an entity.
docstring escapeChar(char_type c, XMLStream::EscapeSettings e);
/// Escape the given character, if necessary, to an entity.
docstring escapeChar(char c, XMLStream::EscapeSettings e);
/// Escape a word instead of a single character
docstring escapeString(docstring const & raw, XMLStream::EscapeSettings e=XMLStream::ESCAPE_ALL);
/// Converts a string to a form safe for links, etc.
docstring xmlize(docstring const &str, XMLStream::EscapeSettings e);
/// cleans \param str for use as an attribute by replacing all non-altnum by "_"
docstring cleanAttr(docstring const & str);
/// \p c must be ASCII
docstring escapeChar(char c, XMLStream::EscapeSettings e);
/// replaces illegal characters from ID attributes
docstring cleanID(docstring const &orig);
/// returns a unique numeric ID
docstring const uniqueID(docstring const & label);
struct FontTag;
struct EndFontTag;
/// Attributes will be escaped automatically and so should NOT
/// 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 0; }
///
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_;
};
/// Tags like <img />
/// Attributes will be escaped automatically and so should NOT
/// 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_;
};
/// A special case of StartTag, used exclusively for tags that wrap paragraphs.
/// parid is only used for HTML output; XML is supposed to use attr for this. TODO: REMOVE PARID.
struct ParTag : public StartTag
{
///
explicit ParTag(std::string const & tag, const std::string & attr): StartTag(tag, from_utf8(attr)) {}
///
explicit ParTag(std::string const & tag, const std::string & attr, const std::string & parid):
StartTag(tag, from_utf8(attr + (parid.empty() ? (" id='" + parid + "'") : ""))) {}
///
~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
// 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(docstring const & tag, docstring const & attr, FontTypes type): StartTag(tag, 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 const * asFontTag() const override { return this; }
///
FontTypes font_type_;
};
// trivial struct for output of newlines
struct CR{};
// an illegal tag for internal use
xml::StartTag const parsep_tag("&LyX_parsep_tag&");
/// Open tag
void openTag(odocstream & os, std::string const & name,
std::string const & attribute = std::string());
/// Open tag
void openTag(Buffer const & buf, odocstream & os,
OutputParams const & runparams, Paragraph const & par);
/// Close tag
void closeTag(odocstream & os, std::string const & name);
/// Close tag
void closeTag(odocstream & os, Paragraph const & par);
} // namespace xml
} // namespace lyx
#endif // XML_H