]> git.lyx.org Git - lyx.git/blobdiff - src/output_xhtml.cpp
Limit the nopassthurchars case in beamer to URL
[lyx.git] / src / output_xhtml.cpp
index a4aced68b0ac480bc2dc7d42a877d04deef30ce6..4cb1d2f7c0aa8e266daae86868a15315c3352e6c 100644 (file)
@@ -3,7 +3,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author Richard Heck
+ * \author Richard Kimberly Heck
  *
  * This code is based upon output_docbook.cpp
  *
@@ -19,7 +19,7 @@
 #include "Counters.h"
 #include "Font.h"
 #include "Layout.h"
-#include "OutputParams.h"
+#include "LayoutEnums.h"
 #include "Paragraph.h"
 #include "ParagraphList.h"
 #include "ParagraphParameters.h"
@@ -157,18 +157,27 @@ namespace {
 // convenience functions
 
 inline void openParTag(XMLStream & xs, Layout const & lay,
-                       const std::string & parlabel)
+                       std::string const & parlabel)
 {
-       string attrs = lay.htmlattr();
+       string attrs = lay.htmlGetAttrString();
        if (!parlabel.empty())
                attrs += " id='" + parlabel + "'";
        xs << xml::ParTag(lay.htmltag(), attrs);
 }
 
 
+void openParTag(XMLStream & xs, Layout const & lay,
+                std::string const & cssclass,
+                std::string const & parlabel) {
+    string attrs = "class='" + cssclass + "'";
+    if (!parlabel.empty())
+        attrs += " id='" + parlabel + "'";
+    xs << xml::ParTag(lay.htmltag(), attrs);
+}
+
 void openParTag(XMLStream & xs, Layout const & lay,
                 ParagraphParameters const & params,
-                const std::string & parlabel)
+                std::string const & parlabel)
 {
        // FIXME Are there other things we should handle here?
        string const align = alignmentToCSS(params.align());
@@ -176,7 +185,7 @@ void openParTag(XMLStream & xs, Layout const & lay,
                openParTag(xs, lay, parlabel);
                return;
        }
-       string attrs = lay.htmlattr() + " style='text-align: " + align + ";'";
+       string attrs = lay.htmlGetAttrString() + " style='text-align: " + align + ";'";
        if (!parlabel.empty())
                attrs += " id='" + parlabel + "'";
        xs << xml::ParTag(lay.htmltag(), attrs);
@@ -201,29 +210,42 @@ inline void closeLabelTag(XMLStream & xs, Layout const & lay)
 }
 
 
-inline void openItemTag(XMLStream & xs, Layout const & lay)
+inline void openItemTag(XMLStream & xs, Layout const & lay,
+                        std::string const & parlabel)
 {
-       xs << xml::StartTag(lay.htmlitemtag(), lay.htmlitemattr(), true);
+       if (lay.htmlitemtag() != "NONE") {
+               string attrs = lay.htmlitemattr();
+               if (!parlabel.empty())
+                       attrs += " id='" + parlabel + "'";
+               xs << xml::StartTag(lay.htmlitemtag(), attrs, true);
+       }
 }
 
 
 void openItemTag(XMLStream & xs, Layout const & lay,
-             ParagraphParameters const & params)
+                 ParagraphParameters const & params,
+                 std::string const & parlabel)
 {
-       // FIXME Are there other things we should handle here?
-       string const align = alignmentToCSS(params.align());
-       if (align.empty()) {
-               openItemTag(xs, lay);
-               return;
+       if (lay.htmlitemtag() != "NONE") {
+               // FIXME Are there other things we should handle here?
+               string const align = alignmentToCSS(params.align());
+               if (align.empty()) {
+                       openItemTag(xs, lay, parlabel);
+                       return;
+               }
+               string attrs = lay.htmlGetAttrString() + " style='text-align: " + align + ";'";
+               if (!parlabel.empty())
+                       attrs += " id='" + parlabel + "'";
+               xs << xml::StartTag(lay.htmlitemtag(), attrs);
        }
-       string attrs = lay.htmlattr() + " style='text-align: " + align + ";'";
-       xs << xml::StartTag(lay.htmlitemtag(), attrs);
 }
 
 
 inline void closeItemTag(XMLStream & xs, Layout const & lay)
 {
-       xs << xml::EndTag(lay.htmlitemtag());
+       if (lay.htmlitemtag() != "NONE") {
+               xs << xml::EndTag(lay.htmlitemtag());
+       }
 }
 
 // end of convenience functions
@@ -396,10 +418,46 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
        ParagraphList::const_iterator const begin = text.paragraphs().begin();
        ParagraphList::const_iterator par = pbegin;
        Layout const & bstyle = par->layout();
-       depth_type const origdepth = pbegin->params().depth();
+       depth_type const origdepth = par->params().depth();
+       string const parId = bstyle.htmlitemtag().empty() ? par->magicLabel() : "";
 
        // open tag for this environment
-       openParTag(xs, bstyle, pbegin->magicLabel());
+       if ((bstyle.labeltype == LABEL_ENUMERATE || bstyle.labeltype == LABEL_ITEMIZE)
+               && bstyle.htmlclass().empty()) {
+               // In this case, we have to calculate the CSS class ourselves, each time
+               // through
+               // FIXME We assume in these cases that the standard counters are being used.
+               // (We also do not deal with 'resume' counters, though I'm not sure that can
+               // be done at all in HTML.)
+
+               // Code adapted from Buffer::Impl::setLabel
+               bool const isenum = bstyle.labeltype == LABEL_ENUMERATE;
+               docstring enumcounter = bstyle.counter.empty() ?
+                                       ( isenum ? from_ascii("enum") : from_ascii("lyxitem") ) :
+                                       bstyle.counter;
+               switch (par->itemdepth) {
+               case 2:
+                       enumcounter += 'i';
+                       // fall through
+               case 1:
+                       enumcounter += 'i';
+                       // fall through
+               case 0:
+                       enumcounter += 'i';
+                       break;
+               case 3:
+                       enumcounter += "iv";
+                       break;
+               default:
+                       // not a valid enumdepth...
+                       break;
+               }
+               const string cssClass = string(isenum ? "lyxenum" : "lyxitem") + " "
+                                     + to_utf8(enumcounter);
+               openParTag(xs, bstyle, cssClass, parId);
+       }
+       else
+               openParTag(xs, bstyle, parId);
        xs << xml::CR();
 
        // we will on occasion need to remember a layout from before.
@@ -418,7 +476,7 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
                if (!style.counter.empty()
                    && (par == pbegin || !isNormalEnv(style))
                                && cnts.hasCounter(cntr)
-               )
+                       )
                        cnts.step(cntr, OutputUpdate);
                ParagraphList::const_iterator send;
 
@@ -441,7 +499,7 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
                                pos_type sep = 0;
                                bool const labelfirst = style.htmllabelfirst();
                                if (!labelfirst)
-                                       openItemTag(xs, style, par->params());
+                                       openItemTag(xs, style, par->params(), par->magicLabel());
 
                                // label output
                                if (style.labeltype != LABEL_NO_LABEL &&
@@ -467,16 +525,19 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
                                                        xs << xml::CR();
                                                }
                                                else {
-                                                       openLabelTag(xs, style);
-                                                       xs << par->params().labelString();
-                                                       closeLabelTag(xs, style);
-                                                       xs << xml::CR();
+                                                       docstring const & ls = par->params().labelString();
+                                                       if (!ls.empty()) {
+                                                               openLabelTag(xs, style);
+                                                               xs << ls;
+                                                               closeLabelTag(xs, style);
+                                                               xs << xml::CR();
+                                                       }
                                                }
                                        }
                                } // end label output
 
                                if (labelfirst)
-                                       openItemTag(xs, style, par->params());
+                                       openItemTag(xs, style, par->params(), par->magicLabel());
 
                                docstring deferred = par->simpleLyXHTMLOnePar(buf, xs, runparams,
                                        text.outerFont(distance(begin, par)), true, true, sep);
@@ -541,8 +602,7 @@ void makeCommand(Buffer const & buf,
                buf.masterBuffer()->params().
                    documentClass().counters().step(style.counter, OutputUpdate);
 
-       bool const make_parid = !runparams.for_toc && runparams.html_make_pars;
-
+       bool const make_parid = !runparams.for_toc && runparams.html_make_pars && style.itemtag().empty();
        openParTag(xs, style, pbegin->params(),
                   make_parid ? pbegin->magicLabel() : "");