mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Add a couple more HTML* tags to InsetLayout, in a way that improves the
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
This commit is contained in:
parent
924119797e
commit
ccf91c3bf0
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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 &);
|
||||
|
@ -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;
|
||||
|
@ -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_;
|
||||
///
|
||||
|
@ -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 &);
|
||||
///
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user