+docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
+ XHTMLStream & xs,
+ OutputParams const & runparams,
+ Font const & outerfont,
+ bool fortoc,
+ pos_type initial) const
+{
+ docstring retval;
+
+ bool emph_flag = false;
+ bool bold_flag = false;
+ string closing_tag;
+
+ Layout const & style = *d->layout_;
+
+ if (!fortoc) {
+ // generate a magic label for this paragraph
+ string const attr = "id='" + magicLabel() + "'";
+ xs << CompTag("a", attr);
+ }
+
+ FontInfo font_old =
+ style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
+
+ // parsing main loop
+ for (pos_type i = initial; i < size(); ++i) {
+ Font font = getFont(buf.params(), i, outerfont);
+
+ // emphasis
+ if (font_old.emph() != font.fontInfo().emph()) {
+ if (font.fontInfo().emph() == FONT_ON) {
+ xs << StartTag("em");
+ emph_flag = true;
+ } else if (emph_flag && i != initial) {
+ xs << EndTag("em");
+ emph_flag = false;
+ }
+ }
+ // bold
+ if (font_old.series() != font.fontInfo().series()) {
+ if (font.fontInfo().series() == BOLD_SERIES) {
+ xs << StartTag("strong");
+ bold_flag = true;
+ } else if (bold_flag && i != initial) {
+ xs << EndTag("strong");
+ bold_flag = false;
+ }
+ }
+ // FIXME XHTML
+ // Other such tags? What about the other text ranges?
+
+ Inset const * inset = getInset(i);
+ if (inset) {
+ InsetCommand const * ic = inset->asInsetCommand();
+ InsetLayout const & il = inset->getLayout();
+ if (!fortoc || il.isInToc() || (ic && ic->isInToc())) {
+ OutputParams np = runparams;
+ if (!il.htmlisblock())
+ np.html_in_par = true;
+ retval += inset->xhtml(xs, np);
+ }
+ } else {
+ char_type c = d->text_[i];
+
+ if (style.pass_thru)
+ xs << c;
+ else if (c == '-') {
+ docstring str;
+ int j = i + 1;
+ if (j < size() && d->text_[j] == '-') {
+ j += 1;
+ if (j < size() && d->text_[j] == '-') {
+ str += from_ascii("—");
+ i += 2;
+ } else {
+ str += from_ascii("–");
+ i += 1;
+ }
+ }
+ else
+ str += c;
+ // We don't want to escape the entities. Note that
+ // it is safe to do this, since str can otherwise
+ // only be "-". E.g., it can't be "<".
+ xs << XHTMLStream::NextRaw() << str;
+ } else
+ xs << c;
+ }
+ font_old = font.fontInfo();
+ }
+
+ xs.closeFontTags();
+ return retval;
+}
+
+