X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Foutput_xhtml.cpp;h=c6b3c7875dbecf0759aa024b3e17b9433b0a2f0a;hb=d1dddde6d800834eb6b8c7626da4d251e7c74f08;hp=9378783f8965d2ee40c60186809989da290122f8;hpb=c4792434683c963997acb1500ef1f2159dcdcc33;p=lyx.git diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index 9378783f89..c6b3c7875d 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -85,53 +85,10 @@ docstring htmlize(docstring const & str, XHTMLStream::EscapeSettings e) } -string escapeChar(char c, XHTMLStream::EscapeSettings e) +docstring escapeChar(char c, XHTMLStream::EscapeSettings e) { - string str; - switch (e) { - case XHTMLStream::ESCAPE_NONE: - str += c; - break; - case XHTMLStream::ESCAPE_ALL: - if (c == '<') { - str += "<"; - break; - } else if (c == '>') { - str += ">"; - break; - } - // fall through - case XHTMLStream::ESCAPE_AND: - if (c == '&') - str += "&"; - else - str +=c ; - break; - } - return str; -} - - -// escape what needs escaping -string htmlize(string const & str, XHTMLStream::EscapeSettings e) -{ - ostringstream d; - string::const_iterator it = str.begin(); - string::const_iterator en = str.end(); - for (; it != en; ++it) - d << escapeChar(*it, e); - return d.str(); -} - - -string cleanAttr(string const & str) -{ - string newname; - string::const_iterator it = str.begin(); - string::const_iterator en = str.end(); - for (; it != en; ++it) - newname += isAlnumASCII(*it) ? *it : '_'; - return newname; + LATTEST(static_cast(c) < 0x80); + return escapeChar(static_cast(c), e); } @@ -150,11 +107,11 @@ docstring cleanAttr(docstring const & str) docstring StartTag::writeTag() const { - string output = "<" + tag_; + docstring output = '<' + from_utf8(tag_); if (!attr_.empty()) - output += " " + html::htmlize(attr_, XHTMLStream::ESCAPE_NONE); + output += ' ' + html::htmlize(from_utf8(attr_), XHTMLStream::ESCAPE_NONE); output += ">"; - return from_utf8(output); + return output; } @@ -193,11 +150,11 @@ docstring ParTag::writeTag() const docstring CompTag::writeTag() const { - string output = "<" + tag_; + docstring output = '<' + from_utf8(tag_); if (!attr_.empty()) - output += " " + html::htmlize(attr_, XHTMLStream::ESCAPE_NONE); + output += ' ' + html::htmlize(from_utf8(attr_), XHTMLStream::ESCAPE_NONE); output += " />"; - return from_utf8(output); + return output; } @@ -495,7 +452,7 @@ XHTMLStream & XHTMLStream::operator<<(char_type c) XHTMLStream & XHTMLStream::operator<<(char c) { clearTagDeque(); - string const d = html::escapeChar(c, escape_); + os_ << html::escapeChar(c, escape_); escape_ = ESCAPE_ALL; return *this; } @@ -980,9 +937,6 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf, ) cnts.step(cntr, OutputUpdate); ParagraphList::const_iterator send; - // this will be positive, if we want to skip the initial word - // (if it's been taken for the label). - pos_type sep = 0; switch (style.latextype) { case LATEX_ENVIRONMENT: @@ -998,6 +952,9 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf, lastlay = 0; } + // this will be positive, if we want to skip the + // initial word (if it's been taken for the label). + pos_type sep = 0; bool const labelfirst = style.htmllabelfirst(); if (!labelfirst) openItemTag(xs, style, par->params()); @@ -1018,7 +975,7 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf, } xs << html::CR(); } - } else { // some kind of list + } else { // some kind of list if (style.labeltype == LABEL_MANUAL) { openLabelTag(xs, style); sep = par->firstWordLyXHTML(xs, runparams); @@ -1100,14 +1057,24 @@ void makeCommand(Buffer const & buf, documentClass().counters().step(style.counter, OutputUpdate); bool const make_parid = !runparams.for_toc && runparams.html_make_pars; + + if (style.labeltype == LABEL_ABOVE) + xs << html::StartTag("div") + << pbegin->params().labelString() + << html::EndTag("div"); + else if (style.labeltype == LABEL_CENTERED) + xs << html::StartTag("div", "style = \"text-align: center;\"") + << pbegin->params().labelString() + << html::EndTag("div"); openParTag(xs, style, pbegin->params(), make_parid ? pbegin->magicLabel() : ""); // Label around sectioning number: // FIXME Probably need to account for LABEL_MANUAL - // FIXME Probably also need now to account for labels ABOVE and CENTERED. - if (style.labeltype != LABEL_NO_LABEL) { + if (style.labeltype != LABEL_NO_LABEL && + style.labeltype != LABEL_ABOVE && + style.labeltype != LABEL_CENTERED ) { openLabelTag(xs, style); xs << pbegin->params().labelString(); closeLabelTag(xs, style);