From 1832a388c5495210c30acb134414dd5b2edf3e7d Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Tue, 19 Jan 2010 19:43:15 +0000 Subject: [PATCH] Collect the title for XHTML output, and use it. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33097 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/doc/Customization.lyx | 72 ++++++++++++++++++++++++++++++++++- lib/layouts/amsdefs.inc | 1 + lib/layouts/apa.layout | 1 + lib/layouts/broadway.layout | 1 + lib/layouts/cl2emult.layout | 1 + lib/layouts/egs.layout | 2 + lib/layouts/elsart.layout | 1 + lib/layouts/elsarticle.layout | 1 + lib/layouts/entcs.layout | 1 + lib/layouts/iopart.layout | 1 + lib/layouts/isprs.layout | 2 +- lib/layouts/kluwer.layout | 1 + lib/layouts/llncs.layout | 1 + lib/layouts/paper.layout | 2 + lib/layouts/powerdot.layout | 1 + lib/layouts/scrlettr.layout | 1 + lib/layouts/scrlttr2.layout | 1 + lib/layouts/siamltex.layout | 1 + lib/layouts/simplecv.layout | 1 + lib/layouts/stdtitle.inc | 1 + lib/layouts/svmult.layout | 1 + lib/scripts/layout2layout.py | 2 +- src/Buffer.cpp | 4 +- src/LaTeXFeatures.h | 6 +++ src/Layout.cpp | 8 +++- src/Layout.h | 4 ++ src/Paragraph.cpp | 5 +++ 27 files changed, 116 insertions(+), 8 deletions(-) diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx index 01ad48be57..36f4d08e37 100644 --- a/lib/doc/Customization.lyx +++ b/lib/doc/Customization.lyx @@ -15600,7 +15600,11 @@ HTMLForceCSS status collapsed \begin_layout Plain Layout -0,1 + +\emph on +0 +\emph default +,1 \end_layout \end_inset @@ -15830,7 +15834,11 @@ HTMLLabelFirst status collapsed \begin_layout Plain Layout -0,1 + +\emph on +0 +\emph default +,1 \end_layout \end_inset @@ -15976,6 +15984,66 @@ div . \end_layout +\begin_layout Description +\begin_inset Flex CharStyle:Code +status collapsed + +\begin_layout Plain Layout +HTMLTitle +\end_layout + +\end_inset + + [ +\begin_inset Flex CharStyle:Code +status collapsed + +\begin_layout Plain Layout + +\emph on +0 +\emph default +,1 +\end_layout + +\end_inset + +] Marks this style as the one to be used to generate the +\begin_inset Flex CharStyle:Code +status collapsed + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + tag for the XHTML file. + By default, it is false. + The +\begin_inset Flex CharStyle:Code +status collapsed + +\begin_layout Plain Layout +stdtitle.inc +\end_layout + +\end_inset + + file sets it to true for the +\begin_inset Flex CharStyle:Code +status collapsed + +\begin_layout Plain Layout +title +\end_layout + +\end_inset + + environment. + +\end_layout + \begin_layout Subsection InsetLayout XHTML \end_layout diff --git a/lib/layouts/amsdefs.inc b/lib/layouts/amsdefs.inc index 2ad5e5e402..37e2fe1332 100644 --- a/lib/layouts/amsdefs.inc +++ b/lib/layouts/amsdefs.inc @@ -46,6 +46,7 @@ Style Title Series Bold Size Larger EndFont + HTMLTitle true End diff --git a/lib/layouts/apa.layout b/lib/layouts/apa.layout index 0d857e1597..09bb0f752b 100644 --- a/lib/layouts/apa.layout +++ b/lib/layouts/apa.layout @@ -44,6 +44,7 @@ Style Title Size Huge EndFont Align Center + HTMLTitle true End diff --git a/lib/layouts/broadway.layout b/lib/layouts/broadway.layout index b2b9ac061e..6fb509b220 100644 --- a/lib/layouts/broadway.layout +++ b/lib/layouts/broadway.layout @@ -192,6 +192,7 @@ Style Title ParSep 1.5 Align Center AlignPossible Left, Right, Center + HTMLTitle true End diff --git a/lib/layouts/cl2emult.layout b/lib/layouts/cl2emult.layout index 38186c16c5..d096ffa720 100644 --- a/lib/layouts/cl2emult.layout +++ b/lib/layouts/cl2emult.layout @@ -51,6 +51,7 @@ Style Title Size Largest Series Bold EndFont + HTMLTitle true End diff --git a/lib/layouts/egs.layout b/lib/layouts/egs.layout index 458519ba1e..c87eb05154 100644 --- a/lib/layouts/egs.layout +++ b/lib/layouts/egs.layout @@ -266,6 +266,7 @@ Style Title Series Bold Size Largest EndFont + HTMLTitle true End @@ -286,6 +287,7 @@ Style LaTeX_Title Series Bold Size Largest EndFont + HTMLTitle true End diff --git a/lib/layouts/elsart.layout b/lib/layouts/elsart.layout index 833e562aa7..3455e45c94 100644 --- a/lib/layouts/elsart.layout +++ b/lib/layouts/elsart.layout @@ -105,6 +105,7 @@ Style Title Series Bold Size Largest EndFont + HTMLTitle true End diff --git a/lib/layouts/elsarticle.layout b/lib/layouts/elsarticle.layout index cf84e8edd6..45dafff6f5 100644 --- a/lib/layouts/elsarticle.layout +++ b/lib/layouts/elsarticle.layout @@ -67,6 +67,7 @@ Style Title Font Size Largest EndFont + HTMLTitle true End diff --git a/lib/layouts/entcs.layout b/lib/layouts/entcs.layout index 52101d2d9f..fcd4cc59db 100644 --- a/lib/layouts/entcs.layout +++ b/lib/layouts/entcs.layout @@ -43,6 +43,7 @@ Style Title Preamble \newcommand{\settitle}[1]{\def\theTitle{#1}} EndPreamble + HTMLTitle true End diff --git a/lib/layouts/iopart.layout b/lib/layouts/iopart.layout index 603cb5b416..0464189343 100644 --- a/lib/layouts/iopart.layout +++ b/lib/layouts/iopart.layout @@ -69,6 +69,7 @@ Style Title Font Size Largest EndFont + HTMLTitle true End diff --git a/lib/layouts/isprs.layout b/lib/layouts/isprs.layout index 046c4eb6ce..1cc966f1a6 100644 --- a/lib/layouts/isprs.layout +++ b/lib/layouts/isprs.layout @@ -107,7 +107,7 @@ Style Title Series Bold Size LARGE EndFont - + HTMLTitle true End Style Address diff --git a/lib/layouts/kluwer.layout b/lib/layouts/kluwer.layout index eac5e9f4ea..20659883e2 100644 --- a/lib/layouts/kluwer.layout +++ b/lib/layouts/kluwer.layout @@ -120,6 +120,7 @@ Style Title Font Size Largest EndFont + HTMLTitle true End diff --git a/lib/layouts/llncs.layout b/lib/layouts/llncs.layout index 11af4e26a9..1d2954ba80 100644 --- a/lib/layouts/llncs.layout +++ b/lib/layouts/llncs.layout @@ -123,6 +123,7 @@ Style Title Series Bold Size Largest EndFont + HTMLTitle true End diff --git a/lib/layouts/paper.layout b/lib/layouts/paper.layout index e6cf69d233..ef13e3a1e0 100644 --- a/lib/layouts/paper.layout +++ b/lib/layouts/paper.layout @@ -150,6 +150,7 @@ Style SubTitle Series Medium Size Large EndFont + HTMLTitle false End @@ -161,6 +162,7 @@ Style Institution Series Medium Size Normal EndFont + HTMLTitle false End diff --git a/lib/layouts/powerdot.layout b/lib/layouts/powerdot.layout index 1df2cc2925..f810dd2428 100644 --- a/lib/layouts/powerdot.layout +++ b/lib/layouts/powerdot.layout @@ -56,6 +56,7 @@ Style Title Size Largest Color Blue EndFont + HTMLTitle true End ### diff --git a/lib/layouts/scrlettr.layout b/lib/layouts/scrlettr.layout index 9d87acfce6..c15bc65ef7 100644 --- a/lib/layouts/scrlettr.layout +++ b/lib/layouts/scrlettr.layout @@ -189,6 +189,7 @@ Style Title CopyStyle Name LatexName title LabelString "Title:" + HTMLTitle true End diff --git a/lib/layouts/scrlttr2.layout b/lib/layouts/scrlttr2.layout index 5664f419dc..2e9d7fe347 100644 --- a/lib/layouts/scrlttr2.layout +++ b/lib/layouts/scrlttr2.layout @@ -271,6 +271,7 @@ Style Title LatexName setkomavar LatexParam {title} LabelString "Title:" + HTMLTitle true End diff --git a/lib/layouts/siamltex.layout b/lib/layouts/siamltex.layout index 8acfa7f655..d2bdada4ef 100644 --- a/lib/layouts/siamltex.layout +++ b/lib/layouts/siamltex.layout @@ -198,6 +198,7 @@ Style Title Series Bold Size Larger EndFont + HTMLTitle true End diff --git a/lib/layouts/simplecv.layout b/lib/layouts/simplecv.layout index 6a460150e6..a350eccef4 100644 --- a/lib/layouts/simplecv.layout +++ b/lib/layouts/simplecv.layout @@ -135,6 +135,7 @@ Style Title Series Bold Size Largest EndFont + HTMLTitle true End diff --git a/lib/layouts/stdtitle.inc b/lib/layouts/stdtitle.inc index 3bc482ec38..0b2c42d548 100644 --- a/lib/layouts/stdtitle.inc +++ b/lib/layouts/stdtitle.inc @@ -61,6 +61,7 @@ Style Title Size Largest EndFont HTMLTag h1 + HTMLTitle true End diff --git a/lib/layouts/svmult.layout b/lib/layouts/svmult.layout index 8d6b8da6a6..286da4f586 100644 --- a/lib/layouts/svmult.layout +++ b/lib/layouts/svmult.layout @@ -28,6 +28,7 @@ End Style Title* CopyStyle Title LatexName title* + HTMLTitle true End Style TOC_Title diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index ad6fefb6ff..a6abc7eebf 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -76,7 +76,7 @@ import os, re, string, sys # Added ContentAsLabel tag. # Incremented to format 21, 12 January 2010 by rgh -# Added HTMLTocLayout tag. +# Added HTMLTocLayout and HTMLTitle tags. # Do not forget to document format change in Customization # Manual (section "Declaring a new text class"). diff --git a/src/Buffer.cpp b/src/Buffer.cpp index e33948b728..16976a12e8 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -1506,12 +1506,10 @@ void Buffer::writeLyXHTMLSource(odocstream & os, os << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN\" \"http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd\">\n"; // FIXME Language should be set properly. os << "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"; - // FIXME Header os << "<head>\n"; // FIXME Presumably need to set this right os << "<meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\" />\n"; - // FIXME Get this during validation? What about other meta-data? - os << "<title>TBA\n"; + os << "" << features.htmlTitle() << "\n"; os << "\n\n" << features.getTClassHTMLPreamble() diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h index 77497a854d..3fc223a287 100644 --- a/src/LaTeXFeatures.h +++ b/src/LaTeXFeatures.h @@ -119,6 +119,10 @@ public: void inFloat(bool const b) { in_float_ = b; } /// Runparams that will be used for exporting this file. OutputParams const & runparams() const { return runparams_; } + /// + void setHTMLTitle(docstring const & t) { htmltitle_ = t; } + /// + docstring const & htmlTitle() const { return htmltitle_; } private: /// @@ -163,6 +167,8 @@ private: OutputParams const & runparams_; /// bool in_float_; + /// + docstring htmltitle_; }; diff --git a/src/Layout.cpp b/src/Layout.cpp index 85fe11a8ab..ae045f130f 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -103,6 +103,7 @@ enum LayoutTags { LT_HTMLSTYLE, LT_HTMLFORCECSS, LT_INPREAMBLE, + LT_HTMLTITLE, LT_INTITLE // keep this last! }; @@ -144,6 +145,7 @@ Layout::Layout() commanddepth = 0; htmllabelfirst_ = false; htmlforcecss_ = false; + htmltitle_ = false; } @@ -176,6 +178,7 @@ bool Layout::read(Lexer & lex, TextClass const & tclass) { "htmlpremable", LT_HTMLPREAMBLE }, { "htmlstyle", LT_HTMLSTYLE }, { "htmltag", LT_HTMLTAG }, + { "htmltitle", LT_HTMLTITLE }, { "innertag", LT_INNERTAG }, { "inpreamble", LT_INPREAMBLE }, { "intitle", LT_INTITLE }, @@ -530,7 +533,10 @@ bool Layout::read(Lexer & lex, TextClass const & tclass) case LT_HTMLPREAMBLE: htmlpreamble_ = from_utf8(lex.getLongString("EndPreamble")); break; - + + case LT_HTMLTITLE: + lex >> htmltitle_; + break; } } lex.popTable(); diff --git a/src/Layout.h b/src/Layout.h index 596c082b5d..1aaf966942 100644 --- a/src/Layout.h +++ b/src/Layout.h @@ -130,6 +130,8 @@ public: /// docstring const & htmlpreamble() const { return htmlpreamble_; } /// + bool htmltitle() const { return htmltitle_; } + /// bool isParagraph() const { return latextype == LATEX_PARAGRAPH; } /// bool isCommand() const { return latextype == LATEX_COMMAND; } @@ -347,6 +349,8 @@ private: mutable docstring htmldefaultstyle_; /// Any other info for the HTML header. docstring htmlpreamble_; + /// Whether this is the paragraph. + bool htmltitle_; /// calculating this is expensive, so we cache it. mutable std::string defaultcssclass_; /// This is the `category' for this layout. The following are diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index b568a93e0b..a096caa3c2 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1086,6 +1086,11 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const features.addPreambleSnippet(to_utf8(d)); } + if (features.runparams().flavor == OutputParams::HTML + && layout_->htmltitle()) { + features.setHTMLTitle(owner_->asString(AS_STR_INSETS)); + } + // check the params. if (!params_.spacing().isDefault()) features.require("setspace");