mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +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
|
LabelString foot
|
||||||
LatexType command
|
LatexType command
|
||||||
LatexName footnote
|
LatexName footnote
|
||||||
|
Counter footnote
|
||||||
Font
|
Font
|
||||||
Color foreground
|
Color foreground
|
||||||
Size Small
|
Size Small
|
||||||
@ -98,7 +99,10 @@ InsetLayout Foot
|
|||||||
EndFont
|
EndFont
|
||||||
MultiPar true
|
MultiPar true
|
||||||
HTMLTag span
|
HTMLTag span
|
||||||
HTMLAttr class='footnote'
|
HTMLAttr class='footwrapper'
|
||||||
|
HTMLLabel "<span class='notenum'>\arabic{footnote}</span>"
|
||||||
|
HTMLInnerTag span
|
||||||
|
HTMLInnerAttr class='footnote'
|
||||||
HTMLStyle
|
HTMLStyle
|
||||||
span.notenum {
|
span.notenum {
|
||||||
vertical-align: super;
|
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
|
int InsetCollapsable::xhtml(odocstream & os, OutputParams const & runparams) const
|
||||||
{
|
{
|
||||||
InsetLayout const & il = getLayout();
|
InsetLayout const & il = getLayout();
|
||||||
bool opened = false;
|
if (undefined())
|
||||||
if (!undefined())
|
return InsetText::xhtml(os, runparams);
|
||||||
opened = html::openTag(os, il.htmltag(), il.htmlattr());
|
|
||||||
|
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);
|
InsetText::xhtml(os, runparams);
|
||||||
if (opened && !undefined())
|
if (innertag_opened)
|
||||||
|
html::closeTag(os, il.htmlinnertag());
|
||||||
|
if (opened)
|
||||||
html::closeTag(os, il.htmltag());
|
html::closeTag(os, il.htmltag());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,9 @@ public:
|
|||||||
int latex(odocstream &, OutputParams const &) const;
|
int latex(odocstream &, OutputParams const &) const;
|
||||||
///
|
///
|
||||||
int docbook(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;
|
int xhtml(odocstream &, OutputParams const &) const;
|
||||||
///
|
///
|
||||||
void validate(LaTeXFeatures &) const;
|
void validate(LaTeXFeatures &) const;
|
||||||
|
@ -127,15 +127,4 @@ int InsetFoot::docbook(odocstream & os, OutputParams const & runparams) const
|
|||||||
return i;
|
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
|
} // namespace lyx
|
||||||
|
@ -38,8 +38,6 @@ private:
|
|||||||
///
|
///
|
||||||
int docbook(odocstream &, OutputParams const &) const;
|
int docbook(odocstream &, OutputParams const &) const;
|
||||||
///
|
///
|
||||||
int xhtml(odocstream &, OutputParams const &) const;
|
|
||||||
///
|
|
||||||
docstring editMessage() const;
|
docstring editMessage() const;
|
||||||
/// Update the counters of this inset and of its contents
|
/// Update the counters of this inset and of its contents
|
||||||
void updateLabels(ParIterator const &);
|
void updateLabels(ParIterator const &);
|
||||||
|
@ -75,6 +75,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
|
|||||||
enum {
|
enum {
|
||||||
IL_BGCOLOR,
|
IL_BGCOLOR,
|
||||||
IL_COPYSTYLE,
|
IL_COPYSTYLE,
|
||||||
|
IL_COUNTER,
|
||||||
IL_CUSTOMPARS,
|
IL_CUSTOMPARS,
|
||||||
IL_DECORATION,
|
IL_DECORATION,
|
||||||
IL_FONT,
|
IL_FONT,
|
||||||
@ -83,6 +84,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
|
|||||||
IL_FREESPACING,
|
IL_FREESPACING,
|
||||||
IL_HTMLTAG,
|
IL_HTMLTAG,
|
||||||
IL_HTMLATTR,
|
IL_HTMLATTR,
|
||||||
|
IL_HTMLINNERTAG,
|
||||||
|
IL_HTMLINNERATTR,
|
||||||
|
IL_HTMLLABEL,
|
||||||
IL_HTMLSTYLE,
|
IL_HTMLSTYLE,
|
||||||
IL_HTMLPREAMBLE,
|
IL_HTMLPREAMBLE,
|
||||||
IL_INTOC,
|
IL_INTOC,
|
||||||
@ -105,6 +109,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
|
|||||||
LexerKeyword elementTags[] = {
|
LexerKeyword elementTags[] = {
|
||||||
{ "bgcolor", IL_BGCOLOR },
|
{ "bgcolor", IL_BGCOLOR },
|
||||||
{ "copystyle", IL_COPYSTYLE },
|
{ "copystyle", IL_COPYSTYLE },
|
||||||
|
{ "counter", IL_COUNTER},
|
||||||
{ "custompars", IL_CUSTOMPARS },
|
{ "custompars", IL_CUSTOMPARS },
|
||||||
{ "decoration", IL_DECORATION },
|
{ "decoration", IL_DECORATION },
|
||||||
{ "end", IL_END },
|
{ "end", IL_END },
|
||||||
@ -113,6 +118,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
|
|||||||
{ "forceplain", IL_FORCEPLAIN },
|
{ "forceplain", IL_FORCEPLAIN },
|
||||||
{ "freespacing", IL_FREESPACING },
|
{ "freespacing", IL_FREESPACING },
|
||||||
{ "htmlattr", IL_HTMLATTR },
|
{ "htmlattr", IL_HTMLATTR },
|
||||||
|
{ "htmlinnerattr", IL_HTMLINNERATTR},
|
||||||
|
{ "htmlinnertag", IL_HTMLINNERTAG},
|
||||||
|
{ "htmllabel", IL_HTMLLABEL },
|
||||||
{ "htmlpreamble", IL_HTMLPREAMBLE },
|
{ "htmlpreamble", IL_HTMLPREAMBLE },
|
||||||
{ "htmlstyle", IL_HTMLSTYLE },
|
{ "htmlstyle", IL_HTMLSTYLE },
|
||||||
{ "htmltag", IL_HTMLTAG },
|
{ "htmltag", IL_HTMLTAG },
|
||||||
@ -205,6 +213,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
|
|||||||
custompars_ = multipar_;
|
custompars_ = multipar_;
|
||||||
forceplain_ = !multipar_;
|
forceplain_ = !multipar_;
|
||||||
break;
|
break;
|
||||||
|
case IL_COUNTER:
|
||||||
|
lex >> counter_;
|
||||||
|
break;
|
||||||
case IL_CUSTOMPARS:
|
case IL_CUSTOMPARS:
|
||||||
lex >> custompars_;
|
lex >> custompars_;
|
||||||
readCustomOrPlain = true;
|
readCustomOrPlain = true;
|
||||||
@ -272,6 +283,15 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
|
|||||||
case IL_HTMLATTR:
|
case IL_HTMLATTR:
|
||||||
lex >> htmlattr_;
|
lex >> htmlattr_;
|
||||||
break;
|
break;
|
||||||
|
case IL_HTMLINNERTAG:
|
||||||
|
lex >> htmlinnertag_;
|
||||||
|
break;
|
||||||
|
case IL_HTMLINNERATTR:
|
||||||
|
lex >> htmlinnerattr_;
|
||||||
|
break;
|
||||||
|
case IL_HTMLLABEL:
|
||||||
|
lex >> htmllabel_;
|
||||||
|
break;
|
||||||
case IL_HTMLSTYLE:
|
case IL_HTMLSTYLE:
|
||||||
htmlstyle_ = from_utf8(lex.getLongString("EndHTMLStyle"));
|
htmlstyle_ = from_utf8(lex.getLongString("EndHTMLStyle"));
|
||||||
break;
|
break;
|
||||||
|
@ -55,33 +55,41 @@ public:
|
|||||||
///
|
///
|
||||||
bool read(Lexer & lexrc, TextClass const & tclass);
|
bool read(Lexer & lexrc, TextClass const & tclass);
|
||||||
///
|
///
|
||||||
docstring name() const { return name_; };
|
docstring name() const { return name_; }
|
||||||
///
|
///
|
||||||
void setName(docstring const & n) { name_ = n; }
|
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 & htmltag() const { return htmltag_; }
|
||||||
///
|
///
|
||||||
std::string const & htmlattr() const { return htmlattr_; }
|
std::string const & htmlattr() const { return htmlattr_; }
|
||||||
|
///
|
||||||
|
std::string const & htmllabel() const { return htmllabel_; }
|
||||||
///
|
///
|
||||||
docstring htmlstyle() const { return htmlstyle_; }
|
docstring htmlstyle() const { return htmlstyle_; }
|
||||||
///
|
///
|
||||||
@ -132,11 +140,19 @@ private:
|
|||||||
///
|
///
|
||||||
ColorCode bgcolor_;
|
ColorCode bgcolor_;
|
||||||
///
|
///
|
||||||
|
docstring counter_;
|
||||||
|
///
|
||||||
docstring preamble_;
|
docstring preamble_;
|
||||||
///
|
///
|
||||||
std::string htmltag_;
|
std::string htmltag_;
|
||||||
///
|
///
|
||||||
std::string htmlattr_;
|
std::string htmlattr_;
|
||||||
|
///
|
||||||
|
std::string htmlinnertag_;
|
||||||
|
///
|
||||||
|
std::string htmlinnerattr_;
|
||||||
|
///
|
||||||
|
std::string htmllabel_;
|
||||||
///
|
///
|
||||||
docstring htmlstyle_;
|
docstring htmlstyle_;
|
||||||
///
|
///
|
||||||
|
@ -144,8 +144,8 @@ public:
|
|||||||
///
|
///
|
||||||
virtual bool allowMultiPar() const { return true; }
|
virtual bool allowMultiPar() const { return true; }
|
||||||
|
|
||||||
// Update the counters of this inset and of its contents
|
/// Update the counters of this inset and of its contents
|
||||||
void updateLabels(ParIterator const &);
|
virtual void updateLabels(ParIterator const &);
|
||||||
///
|
///
|
||||||
void addToToc(DocIterator const &);
|
void addToToc(DocIterator const &);
|
||||||
///
|
///
|
||||||
|
@ -194,8 +194,6 @@ ParagraphList::const_iterator makeParagraphs(Buffer const & buf,
|
|||||||
ParagraphList::const_iterator par = pbegin;
|
ParagraphList::const_iterator par = pbegin;
|
||||||
for (; par != pend; ++par) {
|
for (; par != pend; ++par) {
|
||||||
Layout const & lay = par->layout();
|
Layout const & lay = par->layout();
|
||||||
if (!lay.counter.empty())
|
|
||||||
buf.params().documentClass().counters().step(lay.counter);
|
|
||||||
if (par != pbegin)
|
if (par != pbegin)
|
||||||
os << '\n';
|
os << '\n';
|
||||||
bool const opened = openTag(os, lay);
|
bool const opened = openTag(os, lay);
|
||||||
@ -230,8 +228,6 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
|
|||||||
|
|
||||||
while (par != pend) {
|
while (par != pend) {
|
||||||
Layout const & style = par->layout();
|
Layout const & style = par->layout();
|
||||||
if (!style.counter.empty())
|
|
||||||
buf.params().documentClass().counters().step(style.counter);
|
|
||||||
ParagraphList::const_iterator send;
|
ParagraphList::const_iterator send;
|
||||||
// this will be positive, if we want to skip the initial word
|
// this will be positive, if we want to skip the initial word
|
||||||
// (if it's been taken for the label).
|
// (if it's been taken for the label).
|
||||||
@ -239,36 +235,35 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
|
|||||||
|
|
||||||
switch (style.latextype) {
|
switch (style.latextype) {
|
||||||
case LATEX_ENVIRONMENT:
|
case LATEX_ENVIRONMENT:
|
||||||
case LATEX_LIST_ENVIRONMENT:
|
// case LATEX_LIST_ENVIRONMENT??
|
||||||
case LATEX_ITEM_ENVIRONMENT: {
|
case LATEX_ITEM_ENVIRONMENT: {
|
||||||
// FIXME Factor this out.
|
|
||||||
// There are two possiblities in this case.
|
// There are two possiblities in this case.
|
||||||
// One is that we are still in the environment in which we
|
// One is that we are still in the environment in which we
|
||||||
// started---which we will be if the depth is the same.
|
// started---which we will be if the depth is the same.
|
||||||
if (par->params().depth() == origdepth) {
|
if (par->params().depth() == origdepth) {
|
||||||
Layout const & cstyle = par->layout();
|
|
||||||
if (lastlay != 0) {
|
if (lastlay != 0) {
|
||||||
closeItemTag(os, *lastlay);
|
closeItemTag(os, *lastlay);
|
||||||
lastlay = 0;
|
lastlay = 0;
|
||||||
}
|
}
|
||||||
bool const item_tag_opened = openItemTag(os, cstyle);
|
Layout const & cstyle = par->layout();
|
||||||
if (cstyle.labeltype == LABEL_MANUAL) {
|
if (cstyle.labeltype == LABEL_MANUAL) {
|
||||||
bool const label_tag_opened = openLabelTag(os, cstyle);
|
bool const label_tag_opened = openLabelTag(os, cstyle);
|
||||||
sep = par->firstWordLyXHTML(os, runparams);
|
sep = par->firstWordLyXHTML(os, runparams);
|
||||||
if (label_tag_opened)
|
if (label_tag_opened)
|
||||||
closeLabelTag(os, cstyle);
|
closeLabelTag(os, cstyle);
|
||||||
os << '\n';
|
os << '\n';
|
||||||
}
|
} else if (style.latextype == LATEX_ENVIRONMENT
|
||||||
// FIXME Why did I put that first condition??
|
|
||||||
else if (style.latextype == LATEX_ENVIRONMENT
|
|
||||||
&& style.labeltype != LABEL_NO_LABEL) {
|
&& style.labeltype != LABEL_NO_LABEL) {
|
||||||
bool const label_tag_opened = openLabelTag(os, cstyle);
|
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);
|
os << pbegin->expandLabel(style, buf.params(), false);
|
||||||
if (label_tag_opened)
|
if (label_tag_opened)
|
||||||
closeLabelTag(os, cstyle);
|
closeLabelTag(os, cstyle);
|
||||||
os << '\n';
|
os << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool const item_tag_opened = openItemTag(os, cstyle);
|
||||||
par->simpleLyXHTMLOnePar(buf, os, runparams,
|
par->simpleLyXHTMLOnePar(buf, os, runparams,
|
||||||
outerFont(distance(paragraphs.begin(), par), paragraphs), sep);
|
outerFont(distance(paragraphs.begin(), par), paragraphs), sep);
|
||||||
++par;
|
++par;
|
||||||
@ -303,7 +298,6 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
|
|||||||
// FIXME
|
// FIXME
|
||||||
case LATEX_BIB_ENVIRONMENT:
|
case LATEX_BIB_ENVIRONMENT:
|
||||||
case LATEX_COMMAND:
|
case LATEX_COMMAND:
|
||||||
++par;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -324,15 +318,14 @@ void makeCommand(Buffer const & buf,
|
|||||||
ParagraphList::const_iterator const & pbegin)
|
ParagraphList::const_iterator const & pbegin)
|
||||||
{
|
{
|
||||||
Layout const & style = pbegin->layout();
|
Layout const & style = pbegin->layout();
|
||||||
if (!style.counter.empty())
|
|
||||||
buf.params().documentClass().counters().step(style.counter);
|
|
||||||
|
|
||||||
bool const main_tag_opened = openTag(os, style);
|
bool const main_tag_opened = openTag(os, style);
|
||||||
|
|
||||||
// Label around sectioning number:
|
// Label around sectioning number:
|
||||||
// FIXME Probably need to account for LABEL_MANUAL
|
|
||||||
if (style.labeltype != LABEL_NO_LABEL) {
|
if (style.labeltype != LABEL_NO_LABEL) {
|
||||||
bool const label_tag_opened = openLabelTag(os, style);
|
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);
|
os << pbegin->expandLabel(style, buf.params(), false);
|
||||||
if (label_tag_opened)
|
if (label_tag_opened)
|
||||||
closeLabelTag(os, style);
|
closeLabelTag(os, style);
|
||||||
@ -359,7 +352,6 @@ void xhtmlParagraphs(ParagraphList const & paragraphs,
|
|||||||
ParagraphList::const_iterator pend = paragraphs.end();
|
ParagraphList::const_iterator pend = paragraphs.end();
|
||||||
|
|
||||||
while (par != pend) {
|
while (par != pend) {
|
||||||
LYXERR0(par->id());
|
|
||||||
Layout const & style = par->layout();
|
Layout const & style = par->layout();
|
||||||
ParagraphList::const_iterator lastpar = par;
|
ParagraphList::const_iterator lastpar = par;
|
||||||
ParagraphList::const_iterator send;
|
ParagraphList::const_iterator send;
|
||||||
@ -373,7 +365,6 @@ void xhtmlParagraphs(ParagraphList const & paragraphs,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LATEX_ENVIRONMENT:
|
case LATEX_ENVIRONMENT:
|
||||||
case LATEX_LIST_ENVIRONMENT:
|
|
||||||
case LATEX_ITEM_ENVIRONMENT: {
|
case LATEX_ITEM_ENVIRONMENT: {
|
||||||
send = searchEnvironment(par, pend);
|
send = searchEnvironment(par, pend);
|
||||||
par = makeEnvironment(buf, os, runparams, paragraphs, par,send);
|
par = makeEnvironment(buf, os, runparams, paragraphs, par,send);
|
||||||
@ -383,12 +374,9 @@ void xhtmlParagraphs(ParagraphList const & paragraphs,
|
|||||||
send = searchParagraph(par, pend);
|
send = searchParagraph(par, pend);
|
||||||
par = makeParagraphs(buf, os, runparams, paragraphs, par,send);
|
par = makeParagraphs(buf, os, runparams, paragraphs, par,send);
|
||||||
break;
|
break;
|
||||||
case LATEX_BIB_ENVIRONMENT:
|
default:
|
||||||
// FIXME
|
|
||||||
++par;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// FIXME??
|
|
||||||
// makeEnvironment may process more than one paragraphs and bypass pend
|
// makeEnvironment may process more than one paragraphs and bypass pend
|
||||||
if (distance(lastpar, par) >= distance(lastpar, pend))
|
if (distance(lastpar, par) >= distance(lastpar, pend))
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user