]> git.lyx.org Git - features.git/commitdiff
Add a couple more HTML* tags to InsetLayout, in a way that improves the
authorRichard Heck <rgheck@comcast.net>
Sat, 6 Jun 2009 03:02:43 +0000 (03:02 +0000)
committerRichard Heck <rgheck@comcast.net>
Sat, 6 Jun 2009 03:02:43 +0000 (03:02 +0000)
footnote output and allows a lot more flexibility. (In some ways, this now
seems to be more like what docbook does.)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29981 a592a061-630c-0410-9148-cb99ea01b6c8

lib/layouts/stdinsets.inc
src/insets/InsetCollapsable.cpp
src/insets/InsetCollapsable.h
src/insets/InsetFoot.cpp
src/insets/InsetFoot.h
src/insets/InsetLayout.cpp
src/insets/InsetLayout.h
src/insets/InsetText.h
src/output_xhtml.cpp

index f557a2e8148ca8c018d82c975b4863e62237922d..0e01f19793e28be39899ea10526ab5d269c88c95 100644 (file)
@@ -82,6 +82,7 @@ InsetLayout Foot
        LabelString           foot
        LatexType             command
        LatexName             footnote
+       Counter               footnote
        Font
          Color               foreground
          Size                Small
@@ -98,7 +99,10 @@ InsetLayout Foot
        EndFont
        MultiPar              true
        HTMLTag               span
-       HTMLAttr              class='footnote'
+       HTMLAttr              class='footwrapper'
+       HTMLLabel             "<span class='notenum'>\arabic{footnote}</span>"
+       HTMLInnerTag          span
+       HTMLInnerAttr         class='footnote'
        HTMLStyle
                span.notenum { 
                        vertical-align: super; 
index 5eec355c68c4adb635f03185a2a69fd2e371b453..ea639644793b89a22d5ea1961c7f5877f703e698 100644 (file)
@@ -875,11 +875,25 @@ int InsetCollapsable::docbook(odocstream & os, OutputParams const & runparams) c
 int InsetCollapsable::xhtml(odocstream & os, OutputParams const & runparams) const
 {
        InsetLayout const & il = getLayout();
-       bool opened = false;
-       if (!undefined())
-               opened = html::openTag(os, il.htmltag(), il.htmlattr());
+       if (undefined())
+               return InsetText::xhtml(os, runparams);
+
+       bool const opened = html::openTag(os, il.htmltag(), il.htmlattr());
+       if (!il.counter().empty()) {
+               // FIXME Master buffer?
+               LYXERR0(il.counter());
+               Counters & cntrs = buffer().params().documentClass().counters();
+               cntrs.step(il.counter());
+               if (!il.htmllabel().empty())
+                       os << cntrs.counterLabel(translateIfPossible(from_ascii(il.htmllabel())));
+       }
+       bool innertag_opened = false;
+       if (!il.htmlinnertag().empty())
+               innertag_opened = html::openTag(os, il.htmlinnertag(), il.htmlinnerattr());
        InsetText::xhtml(os, runparams);
-       if (opened && !undefined())
+       if (innertag_opened)
+               html::closeTag(os, il.htmlinnertag());
+       if (opened)
                html::closeTag(os, il.htmltag());
        return 0;
 }
index 4e69f893c3d92c3911d8013f46aea5ed971f36c0..654e28a7bf52865c6180aab3e915d5433d56c942 100644 (file)
@@ -143,7 +143,9 @@ public:
        int latex(odocstream &, OutputParams const &) const;
        ///
        int docbook(odocstream &, OutputParams const &) const;
-       ///
+       /// It will rarely be right to call this from subclasses, due
+       /// to the fact that it steps counters, etc. Instead, call
+       /// InsetText::xhtml().
        int xhtml(odocstream &, OutputParams const &) const;
        ///
        void validate(LaTeXFeatures &) const;
index 22fa7f6f83aa6aa762ec8151f6aa49645701820f..2b64cc3640e28eb2d52e00b174d44b53c5356af0 100644 (file)
@@ -127,15 +127,4 @@ int InsetFoot::docbook(odocstream & os, OutputParams const & runparams) const
        return i;
 }
 
-
-int InsetFoot::xhtml(odocstream & os, OutputParams const & runparams) const
-{
-       // FIXME It'd be nice to output the note number, but we'd need to save 
-       // that when we go through updateLabels.
-       os << "<span class='footwrapper'><span class='notenum'>Note</span>\n";
-       InsetCollapsable::xhtml(os, runparams);
-       os << "\n</span>\n";
-       return 0;
-}
-
 } // namespace lyx
index e25e93138dd1d690d189730a7393df67eccd94a9..a2c1b7421c9aa73aafbb09359c5a07cf90791f8f 100644 (file)
@@ -38,8 +38,6 @@ private:
        ///
        int docbook(odocstream &, OutputParams const &) const;
        ///
-       int xhtml(odocstream &, OutputParams const &) const;
-       ///
        docstring editMessage() const;
        /// Update the counters of this inset and of its contents
        void updateLabels(ParIterator const &);
index 7ffff946a0359b1bdfe2a71fac01b23a105c4b74..14b9ee2b431eee17da9dff7e8151ff532bbbc79d 100644 (file)
@@ -75,6 +75,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
        enum {
                IL_BGCOLOR,
                IL_COPYSTYLE,
+               IL_COUNTER,
                IL_CUSTOMPARS,
                IL_DECORATION,
                IL_FONT,
@@ -83,6 +84,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
                IL_FREESPACING,
                IL_HTMLTAG,
                IL_HTMLATTR,
+               IL_HTMLINNERTAG,
+               IL_HTMLINNERATTR,
+               IL_HTMLLABEL,
                IL_HTMLSTYLE,
                IL_HTMLPREAMBLE,
                IL_INTOC,
@@ -105,6 +109,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
        LexerKeyword elementTags[] = {
                { "bgcolor", IL_BGCOLOR },
                { "copystyle", IL_COPYSTYLE }, 
+               { "counter", IL_COUNTER},
                { "custompars", IL_CUSTOMPARS },
                { "decoration", IL_DECORATION },
                { "end", IL_END },
@@ -113,6 +118,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
                { "forceplain", IL_FORCEPLAIN },
                { "freespacing", IL_FREESPACING },
                { "htmlattr", IL_HTMLATTR },
+               { "htmlinnerattr", IL_HTMLINNERATTR},
+               { "htmlinnertag", IL_HTMLINNERTAG},
+               { "htmllabel", IL_HTMLLABEL },
                { "htmlpreamble", IL_HTMLPREAMBLE },
                { "htmlstyle", IL_HTMLSTYLE },
                { "htmltag", IL_HTMLTAG },
@@ -205,6 +213,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
                        custompars_ = multipar_;
                        forceplain_ = !multipar_;
                        break;
+               case IL_COUNTER:
+                       lex >> counter_;
+                       break;
                case IL_CUSTOMPARS:
                        lex >> custompars_;
                        readCustomOrPlain = true;
@@ -272,6 +283,15 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
                case IL_HTMLATTR:
                        lex >> htmlattr_;
                        break;
+               case IL_HTMLINNERTAG:
+                       lex >> htmlinnertag_;
+                       break;
+               case IL_HTMLINNERATTR:
+                       lex >> htmlinnerattr_;
+                       break;
+               case IL_HTMLLABEL:
+                       lex >> htmllabel_;
+                       break;
                case IL_HTMLSTYLE:
                        htmlstyle_ = from_utf8(lex.getLongString("EndHTMLStyle"));
                        break;
index 673b4d26be13d482e808b43d128e52790f4e04c5..b7a109eaf4ed1c8c28c6b9fc840194e56a7e8063 100644 (file)
@@ -55,33 +55,41 @@ public:
        ///
        bool read(Lexer & lexrc, TextClass const & tclass);
        ///
-       docstring name() const { return name_; };
+       docstring name() const { return name_; }
        ///
        void setName(docstring const & n) { name_ = n; }
        ///
-       InsetLyXType lyxtype() const { return lyxtype_; };
+       InsetLyXType lyxtype() const { return lyxtype_; }
        ///
-       docstring labelstring() const { return labelstring_; };
+       docstring labelstring() const { return labelstring_; }
        ///
-       InsetDecoration decoration() const { return decoration_; };
+       InsetDecoration decoration() const { return decoration_; }
        ///
-       InsetLaTeXType latextype() const { return latextype_; };
+       InsetLaTeXType latextype() const { return latextype_; }
        ///
-       std::string latexname() const { return latexname_; };
+       std::string latexname() const { return latexname_; }
        ///
-       std::string latexparam() const { return latexparam_; };
+       std::string latexparam() const { return latexparam_; }
        ///
-       FontInfo font() const { return font_; };
+       FontInfo font() const { return font_; }
        ///
-       FontInfo labelfont() const { return labelfont_; };
+       FontInfo labelfont() const { return labelfont_; }
        ///
-       ColorCode bgcolor() const { return bgcolor_; };
+       ColorCode bgcolor() const { return bgcolor_; }
        ///
-       docstring preamble() const { return preamble_; };
+       docstring preamble() const { return preamble_; }
+       ///
+       docstring counter() const { return counter_; }
+       /// 
+       std::string const & htmlinnertag() const { return htmlinnertag_; }
        /// 
+       std::string const & htmlinnerattr() const { return htmlinnerattr_; }
+       ///
        std::string const & htmltag() const { return htmltag_; }
        /// 
        std::string const & htmlattr() const { return htmlattr_; }
+       ///
+       std::string const & htmllabel() const { return htmllabel_; }
        /// 
        docstring htmlstyle() const { return htmlstyle_; }
        /// 
@@ -132,11 +140,19 @@ private:
        ///
        ColorCode bgcolor_;
        ///
+       docstring counter_;
+       ///
        docstring preamble_;
        /// 
        std::string htmltag_;
        /// 
        std::string htmlattr_;
+       ///
+       std::string htmlinnertag_;
+       /// 
+       std::string htmlinnerattr_;
+       ///
+       std::string htmllabel_;
        /// 
        docstring htmlstyle_;
        /// 
index 6f509ada4572c470fad3b69b39a9b0c51ae8c640..f2af57fb5f3b2afc523277c7e27fb08640b81ec3 100644 (file)
@@ -144,8 +144,8 @@ public:
        ///
        virtual bool allowMultiPar() const { return true; }
 
-       // Update the counters of this inset and of its contents
-       void updateLabels(ParIterator const &);
+       /// Update the counters of this inset and of its contents
+       virtual void updateLabels(ParIterator const &);
        ///
        void addToToc(DocIterator const &);
        ///
index 0dea4602de8043f76fabff6400bf89f32be0b541..58cf3d3c8966acf86076d67165db7f53cb1cd5ca 100644 (file)
@@ -194,8 +194,6 @@ ParagraphList::const_iterator makeParagraphs(Buffer const & buf,
        ParagraphList::const_iterator par = pbegin;
        for (; par != pend; ++par) {
                Layout const & lay = par->layout();
-               if (!lay.counter.empty())
-                       buf.params().documentClass().counters().step(lay.counter);
                if (par != pbegin)
                        os << '\n';
                bool const opened = openTag(os, lay);
@@ -230,8 +228,6 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
 
        while (par != pend) {
                Layout const & style = par->layout();
-               if (!style.counter.empty())
-                       buf.params().documentClass().counters().step(style.counter);
                ParagraphList::const_iterator send;
                // this will be positive, if we want to skip the initial word
                // (if it's been taken for the label).
@@ -239,36 +235,35 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
 
                switch (style.latextype) {
                case LATEX_ENVIRONMENT:
-               case LATEX_LIST_ENVIRONMENT:
+               // case LATEX_LIST_ENVIRONMENT??
                case LATEX_ITEM_ENVIRONMENT: {
-                       // FIXME Factor this out.
                        // There are two possiblities in this case. 
                        // One is that we are still in the environment in which we 
                        // started---which we will be if the depth is the same.
                        if (par->params().depth() == origdepth) {
-                               Layout const & cstyle = par->layout();
                                if (lastlay != 0) {
                                        closeItemTag(os, *lastlay);
                                        lastlay = 0;
                                }
-                               bool const item_tag_opened = openItemTag(os, cstyle);
+                               Layout const & cstyle = par->layout();
                                if (cstyle.labeltype == LABEL_MANUAL) {
                                        bool const label_tag_opened = openLabelTag(os, cstyle);
                                        sep = par->firstWordLyXHTML(os, runparams);
                                        if (label_tag_opened)
                                                closeLabelTag(os, cstyle);
                                        os << '\n';
-                               }
-                               // FIXME Why did I put that first condition??
-                               else if (style.latextype == LATEX_ENVIRONMENT 
+                               } else if (style.latextype == LATEX_ENVIRONMENT 
                                           && style.labeltype != LABEL_NO_LABEL) {
                                        bool const label_tag_opened = openLabelTag(os, cstyle);
+                                       if (!style.counter.empty())
+                                               buf.params().documentClass().counters().step(cstyle.counter);
                                        os << pbegin->expandLabel(style, buf.params(), false);
                                        if (label_tag_opened)
                                                closeLabelTag(os, cstyle);
                                        os << '\n';
                                }
 
+                               bool const item_tag_opened = openItemTag(os, cstyle);
                                par->simpleLyXHTMLOnePar(buf, os, runparams, 
                                        outerFont(distance(paragraphs.begin(), par), paragraphs), sep);
                                ++par;
@@ -303,7 +298,6 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
                // FIXME
                case LATEX_BIB_ENVIRONMENT:
                case LATEX_COMMAND:
-                       ++par;
                        break;
                }
        }
@@ -324,15 +318,14 @@ void makeCommand(Buffer const & buf,
                                          ParagraphList::const_iterator const & pbegin)
 {
        Layout const & style = pbegin->layout();
-       if (!style.counter.empty())
-               buf.params().documentClass().counters().step(style.counter);
 
        bool const main_tag_opened = openTag(os, style);
 
        // Label around sectioning number:
-       // FIXME Probably need to account for LABEL_MANUAL
        if (style.labeltype != LABEL_NO_LABEL) {
                bool const label_tag_opened = openLabelTag(os, style);
+               if (!style.counter.empty())
+                       buf.params().documentClass().counters().step(style.counter);
                os << pbegin->expandLabel(style, buf.params(), false);
                if (label_tag_opened)
                        closeLabelTag(os, style);
@@ -359,7 +352,6 @@ void xhtmlParagraphs(ParagraphList const & paragraphs,
        ParagraphList::const_iterator pend = paragraphs.end();
 
        while (par != pend) {
-               LYXERR0(par->id());
                Layout const & style = par->layout();
                ParagraphList::const_iterator lastpar = par;
                ParagraphList::const_iterator send;
@@ -373,7 +365,6 @@ void xhtmlParagraphs(ParagraphList const & paragraphs,
                        break;
                }
                case LATEX_ENVIRONMENT:
-               case LATEX_LIST_ENVIRONMENT:
                case LATEX_ITEM_ENVIRONMENT: {
                        send = searchEnvironment(par, pend);
                        par = makeEnvironment(buf, os, runparams, paragraphs, par,send);
@@ -383,12 +374,9 @@ void xhtmlParagraphs(ParagraphList const & paragraphs,
                        send = searchParagraph(par, pend);
                        par = makeParagraphs(buf, os, runparams, paragraphs, par,send);
                        break;
-               case LATEX_BIB_ENVIRONMENT:
-                       // FIXME
-                       ++par;
+               default:
                        break;
                }
-               // FIXME??
                // makeEnvironment may process more than one paragraphs and bypass pend
                if (distance(lastpar, par) >= distance(lastpar, pend))
                        break;