Implement XHTML output for InsetPrintNomencl.

This commit is contained in:
Richard Heck 2013-03-27 19:30:30 -04:00
parent 62d1e762c7
commit 4a6efbb102
4 changed files with 199 additions and 72 deletions

View File

@ -1,5 +1,5 @@
#LyX 2.0 created this file. For more info see http://www.lyx.org/
\lyxformat 413
#LyX 2.1 created this file. For more info see http://www.lyx.org/
\lyxformat 469
\begin_document
\begin_header
\textclass scrbook
@ -65,13 +65,13 @@ enumitem
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\default_output_format default
\output_sync 0
@ -96,15 +96,24 @@ enumitem
\pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue, pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false"
\papersize default
\use_geometry false
\use_amsmath 1
\use_esint 1
\use_mhchem 1
\use_mathdots 1
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 0
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 0
\use_package mhchem 1
\use_package stackrel 0
\use_package stmaryrd 0
\use_package undertilde 0
\cite_engine basic
\cite_engine_type numerical
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 0
\notefontcolor #0000ff
\branch Question
@ -136,6 +145,7 @@ enumitem
\html_be_strict true
\author -712698321 "Jürgen Spitzmüller"
\author 5863208 "ab"
\author 1414654397 "Richard Heck"
\author 2090807402 "usti"
\end_header
@ -200,6 +210,30 @@ LatexCommand tableofcontents
\end_inset
\change_inserted 1414654397 1364424689
\end_layout
\begin_layout Standard
\change_inserted 1414654397 1364424693
\begin_inset FloatList figure
\end_inset
\end_layout
\begin_layout Standard
\change_inserted 1414654397 1364424693
\begin_inset FloatList table
\end_inset
\change_unchanged
\end_layout
\begin_layout Chapter
@ -3001,7 +3035,7 @@ Each class has a default set of options.
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="5" columns="5">
<features tabularvalignment="middle">
<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top" width="0pt">
@ -4889,7 +4923,7 @@ Section headings ! Short titles
\end_inset
\begin_inset Argument
\begin_inset Argument 1
status collapsed
\begin_layout Plain Layout
@ -6380,7 +6414,7 @@ As example a list with custom numbering:
\end_layout
\begin_layout Enumerate
\begin_inset Argument
\begin_inset Argument 1
status collapsed
\begin_layout Plain Layout
@ -6410,7 +6444,7 @@ Level 1
\begin_deeper
\begin_layout Enumerate
\begin_inset Argument
\begin_inset Argument 1
status collapsed
\begin_layout Plain Layout
@ -6442,7 +6476,7 @@ Level 2
\begin_deeper
\begin_layout Enumerate
\begin_inset Argument
\begin_inset Argument 1
status collapsed
\begin_layout Plain Layout
@ -6470,7 +6504,7 @@ Level 3
\begin_deeper
\begin_layout Enumerate
\begin_inset Argument
\begin_inset Argument 1
status collapsed
\begin_layout Plain Layout
@ -6593,7 +6627,7 @@ Enumerations can be resumed after intermediate paragraphs:
\end_layout
\begin_layout Enumerate
\begin_inset Argument
\begin_inset Argument 1
status collapsed
\begin_layout Plain Layout
@ -6703,7 +6737,7 @@ Enumeration starting at a given value:
\end_layout
\begin_layout Enumerate
\begin_inset Argument
\begin_inset Argument 1
status open
\begin_layout Plain Layout
@ -6764,7 +6798,7 @@ nolistsep
\end_layout
\begin_layout Itemize
\begin_inset Argument
\begin_inset Argument 1
status open
\begin_layout Plain Layout
@ -6833,7 +6867,7 @@ cm so that the number is in the page margin:
\end_layout
\begin_layout Enumerate
\begin_inset Argument
\begin_inset Argument 1
status open
\begin_layout Plain Layout
@ -6922,7 +6956,7 @@ Ionizing
\end_inset
radiation:
\begin_inset Argument
\begin_inset Argument 1
status collapsed
\begin_layout Plain Layout
@ -7340,7 +7374,7 @@ status collapsed
\end_layout
\begin_layout Plain Layout
\begin_inset Caption
\begin_inset Caption Standard
\begin_layout Plain Layout
\begin_inset CommandInset label
@ -8317,7 +8351,7 @@ This is (a) and it's nested.
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="2">
<features tabularvalignment="middle">
<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top" width="0pt">
<row>
@ -8446,7 +8480,7 @@ This is (a) and it's nested.
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="2">
<features tabularvalignment="middle">
<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top" width="0pt">
<row>
@ -8584,7 +8618,7 @@ This is (a) and it's nested.
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="2">
<features tabularvalignment="middle">
<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top" width="0pt">
<row>
@ -9149,7 +9183,7 @@ Enumerate
Itemize
\family default
Environments
\begin_inset Argument
\begin_inset Argument 1
status collapsed
\begin_layout Plain Layout
@ -9534,7 +9568,7 @@ Here comes a table:
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="2">
<features tabularvalignment="middle">
<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top" width="0pt">
<row>
@ -10303,7 +10337,7 @@ status collapsed
\begin_layout Plain Layout
\align center
\begin_inset Caption
\begin_inset Caption Standard
\begin_layout Plain Layout
\begin_inset CommandInset label
@ -10324,7 +10358,7 @@ Width of the different horizontal spaces.
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="8" columns="2">
<features tabularvalignment="middle">
<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top" width="0">
<column alignment="center" valignment="top" width="0">
<row>
@ -15314,7 +15348,7 @@ em dash
\begin_layout Standard
\begin_inset Tabular
<lyxtabular version="3" rows="5" columns="3">
<features tabularvalignment="middle">
<features rotate="0" tabularvalignment="middle">
<column alignment="left" valignment="top" width="0">
<column alignment="left" valignment="top" width="0">
<column alignment="left" valignment="top" width="0">
@ -16681,7 +16715,7 @@ Here is an example to show the differences:
\begin_layout Standard
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="2">
<features tabularvalignment="middle">
<features rotate="0" tabularvalignment="middle">
<column alignment="left" valignment="top" width="0">
<column alignment="left" valignment="top" width="0">
<row>
@ -17963,7 +17997,7 @@ Table
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="4" columns="4">
<features tabularvalignment="middle">
<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top" width="0in">
@ -18255,7 +18289,7 @@ one
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="3" columns="4">
<features firstHeadTopDL="true" firstHeadBottomDL="true" tabularvalignment="middle">
<features rotate="0" firstHeadTopDL="true" firstHeadBottomDL="true" tabularvalignment="middle">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="middle" width="0">
<column alignment="center" valignment="top" width="0in">
@ -18610,7 +18644,7 @@ header
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="69" columns="3">
<features islongtable="true" longtabularalignment="center">
<features rotate="0" islongtable="true" longtabularalignment="center">
<column alignment="block" valignment="top" width="5cm">
<column alignment="left" valignment="top" width="0pt">
<column alignment="right" valignment="top" width="0pt">
@ -20806,7 +20840,7 @@ To have multi-line entries in table cells, you have to declare a fixed width
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="4" columns="3">
<features tabularvalignment="middle">
<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top" width="0pt">
<column alignment="block" valignment="top" width="3cm">
<column alignment="center" valignment="top" width="0pt">
@ -21279,7 +21313,7 @@ status open
\end_layout
\begin_layout Plain Layout
\begin_inset Caption
\begin_inset Caption Standard
\begin_layout Plain Layout
\begin_inset CommandInset label
@ -21427,7 +21461,7 @@ sideways false
status collapsed
\begin_layout Plain Layout
\begin_inset Caption
\begin_inset Caption Standard
\begin_layout Plain Layout
\begin_inset CommandInset label
@ -21467,7 +21501,7 @@ sideways false
status collapsed
\begin_layout Plain Layout
\begin_inset Caption
\begin_inset Caption Standard
\begin_layout Plain Layout
\begin_inset CommandInset label
@ -21505,7 +21539,7 @@ Platypus
\end_layout
\begin_layout Plain Layout
\begin_inset Caption
\begin_inset Caption Standard
\begin_layout Plain Layout
\begin_inset CommandInset label
@ -21578,7 +21612,7 @@ sideways false
status open
\begin_layout Plain Layout
\begin_inset Caption
\begin_inset Caption Standard
\begin_layout Plain Layout
\begin_inset CommandInset label
@ -21599,7 +21633,7 @@ A table float.
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="3" columns="3">
<features tabularvalignment="middle">
<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top" width="0pt">
@ -23165,7 +23199,7 @@ sideways false
status open
\begin_layout Plain Layout
\begin_inset Caption
\begin_inset Caption Standard
\begin_layout Plain Layout
\begin_inset CommandInset label
@ -23186,7 +23220,7 @@ Accent names and the corresponding commands.
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="11" columns="3">
<features tabularvalignment="middle">
<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top" width="0pt">
@ -24546,7 +24580,7 @@ sideways false
status open
\begin_layout Plain Layout
\begin_inset Caption
\begin_inset Caption Standard
\begin_layout Plain Layout
\begin_inset CommandInset label
@ -24567,7 +24601,7 @@ Typefaces and the corresponding commands.
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="9" columns="2">
<features tabularvalignment="middle">
<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top" width="0pt">
<row>
@ -29601,7 +29635,7 @@ Note:
\begin_layout Subsection
Short Introduction to the LaTeX Syntax
\begin_inset Argument
\begin_inset Argument 1
status collapsed
\begin_layout Plain Layout
@ -29853,7 +29887,7 @@ switches temporarily to a page style with custom header and footer line
\end_layout
\begin_layout Left Header
\begin_inset Argument
\begin_inset Argument 1
status collapsed
\begin_layout Plain Layout
@ -29889,7 +29923,7 @@ defines the header line as described below
\end_layout
\begin_layout Center Header
\begin_inset Argument
\begin_inset Argument 1
status collapsed
\begin_layout Plain Layout
@ -29902,7 +29936,7 @@ status collapsed
\end_layout
\begin_layout Right Header
\begin_inset Argument
\begin_inset Argument 1
status collapsed
\begin_layout Plain Layout
@ -29927,7 +29961,7 @@ leftmark
\end_layout
\begin_layout Left Footer
\begin_inset Argument
\begin_inset Argument 1
status collapsed
\begin_layout Plain Layout
@ -29952,7 +29986,7 @@ thepage
\end_layout
\begin_layout Center Footer
\begin_inset Argument
\begin_inset Argument 1
status collapsed
\begin_layout Plain Layout
@ -29977,7 +30011,7 @@ Magic code:
\end_layout
\begin_layout Right Footer
\begin_inset Argument
\begin_inset Argument 1
status collapsed
\begin_layout Plain Layout
@ -30156,7 +30190,7 @@ status collapsed
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="5" columns="3">
<features tabularvalignment="middle">
<features rotate="0" tabularvalignment="middle">
<column alignment="left" valignment="top" width="30line%">
<column alignment="center" valignment="top" width="30line%">
<column alignment="right" valignment="top" width="30line%">
@ -30317,7 +30351,7 @@ Right Footer
\end_layout
\begin_layout Plain Layout
\begin_inset Caption
\begin_inset Caption Standard
\begin_layout Plain Layout
\begin_inset CommandInset label
@ -32484,7 +32518,7 @@ The review toolbar as shown above contains from left to right the following
\begin_layout Standard
\begin_inset Tabular
<lyxtabular version="3" rows="10" columns="2">
<features islongtable="true" longtabularalignment="center">
<features rotate="0" islongtable="true" longtabularalignment="center">
<column alignment="left" valignment="top" width="0">
<column alignment="left" valignment="top" width="0">
<row interlinespace="2.5mm">
@ -33263,7 +33297,7 @@ sideways false
status collapsed
\begin_layout Plain Layout
\begin_inset Caption
\begin_inset Caption Standard
\begin_layout Plain Layout
\begin_inset CommandInset label
@ -33288,7 +33322,7 @@ latin1
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="17" columns="17">
<features tabularvalignment="middle">
<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top" width="0pt">
@ -41382,7 +41416,7 @@ Embedded Objects
\begin_layout Standard
\begin_inset Tabular
<lyxtabular version="3" rows="1" columns="2">
<features islongtable="true" longtabularalignment="center">
<features rotate="0" islongtable="true" longtabularalignment="center">
<column alignment="center" valignment="top" width="0">
<column alignment="center" valignment="top" width="0">
<row>
@ -41429,7 +41463,7 @@ pull-down box for the environments
\align left
\begin_inset Tabular
<lyxtabular version="3" rows="21" columns="2">
<features islongtable="true" longtabularalignment="center">
<features rotate="0" islongtable="true" longtabularalignment="center">
<column alignment="left" valignment="top" width="0">
<column alignment="left" valignment="top" width="0">
<row interlinespace="2.5mm">
@ -42139,7 +42173,7 @@ The extra toolbar as shown above contains from left to right the following
\begin_layout Standard
\begin_inset Tabular
<lyxtabular version="3" rows="25" columns="2">
<features islongtable="true" longtabularalignment="center">
<features rotate="0" islongtable="true" longtabularalignment="center">
<column alignment="left" valignment="top" width="0">
<column alignment="left" valignment="top" width="0">
<row interlinespace="2.5mm">
@ -42997,7 +43031,7 @@ The view / update toolbar as shown above contains from left to right the
\begin_layout Standard
\begin_inset Tabular
<lyxtabular version="3" rows="7" columns="2">
<features islongtable="true" longtabularalignment="center">
<features rotate="0" islongtable="true" longtabularalignment="center">
<column alignment="left" valignment="top" width="0">
<column alignment="left" valignment="top" width="0">
<row interlinespace="2.5mm">
@ -48099,7 +48133,7 @@ sideways false
status collapsed
\begin_layout Plain Layout
\begin_inset Caption
\begin_inset Caption Standard
\begin_layout Plain Layout
\begin_inset CommandInset label
@ -48127,7 +48161,7 @@ Units
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="20" columns="2">
<features tabularvalignment="middle">
<features rotate="0" tabularvalignment="middle">
<column alignment="center" valignment="top" width="0">
<column alignment="center" valignment="top" width="0">
<row>

View File

@ -201,14 +201,14 @@ InsetLayout TOC
font-weight: bold;
}
div.lyxtoc-2 {
margin: 0em 0em 0em 1em;
margin: 0em 0.1em 0em 1em;
font-size: large;
font-weight: normal;
}
div.lyxtoc-3 { margin: 0em 0em 0em 0.5em; font-size: medium; }
div.lyxtoc-4 { margin: 0em 0em 0em 0.5em; }
div.lyxtoc-5 { margin: 0em 0em 0em 0.5em; }
div.lyxtoc-6 { margin: 0em 0em 0em 0.5em; }
div.lyxtoc-3 { margin: 0em 0.1em 0em 0.5em; font-size: medium; }
div.lyxtoc-4 { margin: 0em 0.1em 0em 0.5em; }
div.lyxtoc-5 { margin: 0em 0.1em 0em 0.5em; }
div.lyxtoc-6 { margin: 0em 0.1em 0em 0.5em; }
a.tocentry {
text-decoration: none;
color: black;
@ -569,9 +569,15 @@ InsetLayout Script:superscript
HTMLTag sup
End
InsetLayout Script:subscript
CopyStyle Script
Requires subscript
LaTeXName textsubscript
HTMLTag sub
End
InsetLayout PrintNomencl
HTMLTag h2
End

View File

@ -24,6 +24,7 @@
#include "FuncStatus.h"
#include "InsetIterator.h"
#include "InsetList.h"
#include "Language.h"
#include "LaTeXFeatures.h"
#include "Length.h"
#include "LyX.h"
@ -172,6 +173,96 @@ docstring InsetPrintNomencl::screenLabel() const
}
struct NomenclEntry {
NomenclEntry() {}
NomenclEntry(docstring s, docstring d, Paragraph const * p)
: symbol(s), desc(d), par(p)
{}
docstring symbol;
docstring desc;
Paragraph const * par;
};
typedef map<docstring, NomenclEntry > EntryMap;
docstring InsetPrintNomencl::xhtml(XHTMLStream &, OutputParams const & op) const
{
Toc const & toc = buffer().tocBackend().toc("nomencl");
EntryMap entries;
Toc::const_iterator it = toc.begin();
Toc::const_iterator const en = toc.end();
for (; it != en; ++it) {
DocIterator dit = it->dit();
Paragraph const & par = dit.innerParagraph();
Inset const * inset = par.getInset(dit.top().pos());
if (!inset)
return docstring();
InsetCommand const * ic = inset->asInsetCommand();
if (!ic)
return docstring();
// FIXME We need a link to the paragraph here, so we
// need some kind of struct.
docstring const symbol = ic->getParam("symbol");
docstring const desc = ic->getParam("description");
docstring const prefix = ic->getParam("prefix");
docstring const sortas = prefix.empty() ? symbol : prefix;
entries[sortas] = NomenclEntry(symbol, desc, &par);
}
if (entries.empty())
return docstring();
// we'll use our own stream, because we are going to defer everything.
// that's how we deal with the fact that we're probably inside a standard
// paragraph, and we don't want to be.
odocstringstream ods;
XHTMLStream xs(ods);
InsetLayout const & il = getLayout();
string const & tag = il.htmltag();
docstring toclabel = translateIfPossible(from_ascii("Nomenclature"),
op.local_font->language()->lang());
xs << html::StartTag("div", "class='nomencl'")
<< html::StartTag(tag, "class='nomencl'")
<< toclabel
<< html::EndTag(tag)
<< html::CR()
<< html::StartTag("dl")
<< html::CR();
EntryMap::const_iterator eit = entries.begin();
EntryMap::const_iterator const een = entries.end();
for (; eit != een; ++eit) {
NomenclEntry const & ne = eit->second;
string const parid = ne.par->magicLabel();
xs << html::StartTag("dt")
<< html::StartTag("a", "href='#" + parid + "' class='nomencl'")
<< ne.symbol
<< html::EndTag("a")
<< html::EndTag("dt")
<< html::CR()
<< html::StartTag("dd")
<< ne.desc
<< html::EndTag("dd")
<< html::CR();
}
xs << html::EndTag("dl")
<< html::CR()
<< html::EndTag("div")
<< html::CR();
return ods.str();
}
void InsetPrintNomencl::doDispatch(Cursor & cur, FuncRequest & cmd)
{
switch (cmd.action()) {
@ -213,12 +304,6 @@ bool InsetPrintNomencl::getStatus(Cursor & cur, FuncRequest const & cmd,
}
docstring InsetPrintNomencl::xhtml(XHTMLStream &, OutputParams const &) const
{
return docstring();
}
// FIXME This should be changed to use the TOC. Perhaps
// that could be done when XHTML output is added.
int InsetPrintNomencl::docbook(odocstream & os, OutputParams const &) const

View File

@ -89,7 +89,7 @@ public:
void validate(LaTeXFeatures & features) const;
///
int docbook(odocstream &, OutputParams const &) const;
/// Does nothing at the moment.
///
docstring xhtml(XHTMLStream &, OutputParams const &) const;
///
InsetCode lyxCode() const;
@ -123,6 +123,8 @@ private:
bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & status) const;
///
void doDispatch(Cursor & cur, FuncRequest & cmd);
///
docstring layoutName() const { return from_ascii("PrintNomencl"); }
//@}
/// \name Private functions inherited from InsetCommand class