From 864773d7d94d17c588860af6357a7e6dea53fbb9 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 28 May 2009 08:59:25 +0000 Subject: [PATCH] Allow literate documents other than noweb to work out of the box. Currently only sweave is supported (for building documentation, not programs). Layout files allow a new OutputFormat tag Modules can be conditionned on a feature of the type from->to, indicating that it should be possible to convert from format 'from' to format 'to'. Layout format incremented to 15. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29874 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/doc/Customization.lyx | 459 ++++++++++++++++++++++++++++------- lib/layouts/noweb.module | 2 +- lib/layouts/sweave.module | 4 +- lib/scripts/layout2layout.py | 11 +- src/Buffer.cpp | 21 +- src/LaTeXFeatures.cpp | 9 + src/TextClass.cpp | 23 +- src/TextClass.h | 6 +- src/frontends/qt4/GuiLog.cpp | 1 + 9 files changed, 428 insertions(+), 108 deletions(-) diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx index 0febd05769..8945a49c7e 100644 --- a/lib/doc/Customization.lyx +++ b/lib/doc/Customization.lyx @@ -1,5 +1,5 @@ #LyX 2.0.0svn created this file. For more info see http://www.lyx.org/ -\lyxformat 355 +\lyxformat 361 \begin_document \begin_header \textclass scrbook @@ -74,6 +74,8 @@ End \graphics default \default_output_format default +\bibtex_command default +\index_command default \paperfontsize 12 \spacing single \use_hyperref true @@ -99,7 +101,6 @@ End \use_bibtopic false \use_indices false \paperorientation portrait -\backgroundcolor #ffffff \branch OutDated \selected 0 \color #f5fae7 @@ -112,9 +113,9 @@ End \papercolumns 1 \papersides 2 \paperpagestyle headings -\tracking_changes false +\tracking_changes true \output_changes false -\author "" +\author "Jean-Marc Lasgouttes" \author "" \end_header @@ -150,7 +151,11 @@ type "mailto:" \end_inset in the subject header, and please cc the current maintainer of this file, - Richard Heck . + Richard Heck < +rgheck +@ +comcast +.net>. \end_layout \end_inset @@ -199,7 +204,9 @@ Introduction This manual covers the customization features present in LyX. In it, we discuss issues like keyboard shortcuts, screen previewing options, printer options, sending commands to LyX via the LyX Server, internationalizati -on, installing new LaTeX classes and LyX layouts, etc. +on, installing new +LaTeX + classes and LyX layouts, etc. We can't possibly hope to touch on everything you can change—our developers add new features faster than we can document them—but we will explain the most common customizations and hopefully point you in the right direction @@ -212,8 +219,12 @@ status open \begin_layout Standard Information from previous versions of this document that now seems to be - outdated is contained in the OutDated branch of this document. - By default, this information will not appear in the LaTeX output. + outdated is contained in the +OutDated + branch of this document. + By default, this information will not appear in the +LaTeX + output. \end_layout \end_inset @@ -252,6 +263,7 @@ on files; the user directory is where you can place your modified versions. status collapsed \begin_layout Plain Layout + LyXDir \end_layout @@ -262,6 +274,7 @@ LyXDir status collapsed \begin_layout Plain Layout + UserDir \end_layout @@ -277,6 +290,7 @@ What's in status collapsed \begin_layout Plain Layout + LyXDir \end_layout @@ -290,6 +304,7 @@ LyXDir status collapsed \begin_layout Plain Layout + LyXDir \end_layout @@ -317,6 +332,7 @@ Preferences status collapsed \begin_layout Plain Layout + LyXDir \end_layout @@ -337,6 +353,7 @@ The files, which are to be found in status collapsed \begin_layout Plain Layout + UserDir \end_layout @@ -368,7 +385,8 @@ lyxrc.defaults status collapsed \begin_layout Plain Layout -packages.lst +packages. +lst \end_layout \end_inset @@ -381,7 +399,9 @@ status collapsed \begin_layout Plain Layout Help\SpecialChar \menuseparator + LaTeX + \begin_inset space ~ \end_inset @@ -399,7 +419,10 @@ Configuration status collapsed \begin_layout Plain Layout -textclass.lst + +textclass +. +lst \end_layout \end_inset @@ -414,8 +437,9 @@ layout/ \end_inset - directories, along with the associated LaTeX document class and their descripti -on. + directories, along with the associated +LaTeX + document class and their description. \end_layout \begin_layout Labeling @@ -424,7 +448,10 @@ on. status collapsed \begin_layout Plain Layout -lyxmodules.lst + +lyxmodules +. +lst \end_layout \end_inset @@ -448,12 +475,15 @@ layout/ status collapsed \begin_layout Plain Layout -*files.lst +*files. +lst \end_layout \end_inset - lists of various sorts of LaTeX-related files found on your system + lists of various sorts of +LaTeX +-related files found on your system \end_layout \begin_layout Labeling @@ -462,7 +492,9 @@ status collapsed status collapsed \begin_layout Plain Layout -doc/LaTeXConfig.lyx +doc/ +LaTeXConfig +.lyx \end_layout \end_inset @@ -472,13 +504,17 @@ doc/LaTeXConfig.lyx status collapsed \begin_layout Plain Layout -LaTeXConfig.lyx.in + +LaTeXConfig +.lyx.in \end_layout \end_inset . - It contains information on your LaTeX configuration. + It contains information on your +LaTeX + configuration. \end_layout \begin_layout Subsection @@ -491,6 +527,7 @@ These directories are duplicated between status collapsed \begin_layout Plain Layout + LyXDir \end_layout @@ -501,6 +538,7 @@ LyXDir status collapsed \begin_layout Plain Layout + UserDir \end_layout @@ -512,6 +550,7 @@ UserDir status collapsed \begin_layout Plain Layout + UserDir \end_layout @@ -541,7 +580,9 @@ status collapsed \end_inset - that define the keybindings used in LyX. + that define the +keybindings + used in LyX. If there exists an internationalized version of the bind file named \begin_inset Flex CharStyle:Code status collapsed @@ -561,7 +602,9 @@ $LANG_xxx.bind status collapsed \begin_layout Plain Layout -clipart/ + +clipart +/ \end_layout \end_inset @@ -587,13 +630,17 @@ doc/ status collapsed \begin_layout Plain Layout -LaTeXConfig.lyx + +LaTeXConfig +.lyx \end_layout \end_inset deserves special attention, as noted above. - The internationalized help docs are in subdirectories + The internationalized help docs are in +subdirectories + \begin_inset Flex CharStyle:Code status collapsed @@ -683,12 +730,16 @@ Document status collapsed \begin_layout Plain Layout -kbd/ + +kbd +/ \end_layout \end_inset - contains keyboard keymapping files. + contains keyboard +keymapping + files. See Chapter \begin_inset space ~ \end_inset @@ -734,6 +785,7 @@ reference "cha:Installing-New-Document" status collapsed \begin_layout Plain Layout + lyx2lyx \end_layout @@ -744,6 +796,7 @@ lyx2lyx status collapsed \begin_layout Plain Layout + lyx2lyx \end_layout @@ -814,7 +867,9 @@ reference "sec:Creating-Templates" status collapsed \begin_layout Plain Layout -ui/ + +ui +/ \end_layout \end_inset @@ -824,7 +879,8 @@ ui/ status collapsed \begin_layout Plain Layout -.ui +. +ui \end_layout \end_inset @@ -879,12 +935,17 @@ LyX status collapsed \begin_layout Plain Layout -chkconfig.ltx + +chkconfig +. +ltx \end_layout \end_inset - this is a LaTeX script used during the configuration process. + this is a +LaTeX + script used during the configuration process. Do not run directly. \end_layout @@ -894,7 +955,8 @@ chkconfig.ltx status collapsed \begin_layout Plain Layout -configure.py +configure. +py \end_layout \end_inset @@ -913,13 +975,15 @@ Other files needing a line or two... status collapsed \begin_layout Plain Layout + encodings \end_layout \end_inset - this contains tables describing how different character encodings can be - mapped to Unicode + this contains tables describing how different character +encodings + can be mapped to Unicode \end_layout \begin_layout Labeling @@ -976,6 +1040,7 @@ Even if you are using LyX as an unprivileged user, you might want to change status collapsed \begin_layout Plain Layout + UserDir \end_layout @@ -1011,6 +1076,7 @@ LyX status collapsed \begin_layout Plain Layout + LyXDir \end_layout @@ -1021,6 +1087,7 @@ LyXDir status collapsed \begin_layout Plain Layout + UserDir \end_layout @@ -1031,6 +1098,7 @@ UserDir status collapsed \begin_layout Plain Layout + LyXDir \end_layout @@ -1073,6 +1141,7 @@ preferences status collapsed \begin_layout Plain Layout + UserDir \end_layout @@ -1098,7 +1167,8 @@ Reconfigure status collapsed \begin_layout Plain Layout -configure.py +configure. +py \end_layout \end_inset @@ -1111,7 +1181,9 @@ configure.py status collapsed \begin_layout Plain Layout -UserDir/layouts + +UserDir +/layouts \end_layout \end_inset @@ -1138,7 +1210,9 @@ If you get some updated documentation from LyX ftp site and cannot install status collapsed \begin_layout Plain Layout -UserDir/doc/ + +UserDir +/doc/ \end_layout \end_inset @@ -1175,7 +1249,8 @@ Invoking LyX with the command line switch status collapsed \begin_layout Plain Layout --userdir +- +userdir \end_layout \end_inset @@ -1191,7 +1266,8 @@ status collapsed status collapsed \begin_layout Plain Layout --userdir +- +userdir \end_layout \end_inset @@ -1207,7 +1283,10 @@ status collapsed status collapsed \begin_layout Plain Layout -LYX_USERDIR_VER +LYX_ +USERDIR +_ +VER \end_layout \end_inset @@ -1222,7 +1301,9 @@ Having several configurations also requires more maintenance: if you want status collapsed \begin_layout Plain Layout -NewUserDir/layouts + +NewUserDir +/layouts \end_layout \end_inset @@ -1230,10 +1311,15 @@ NewUserDir/layouts which you want available from all your configurations, you must add it to each directory separately. You can avoid this with the following trick: after LyX creates the additional - directory, most of the subdirectories (see above) are empty. + directory, most of the +subdirectories + (see above) are empty. If you want the new configuration to mirror an existing one, replace the - empty subdirectory with a symbolic link to the matching subdirectory in - the existing configuration. + empty +subdirectory + with a symbolic link to the matching +subdirectory + in the existing configuration. Take care with the \begin_inset Flex CharStyle:Code status collapsed @@ -1244,8 +1330,10 @@ doc/ \end_inset - subdirectory, however, since it contains a file written by the configuration - script (also accessible through + +subdirectory +, however, since it contains a file written by the configuration script + (also accessible through \begin_inset Flex CharStyle:MenuItem status collapsed @@ -1410,6 +1498,7 @@ Editor status collapsed \begin_layout Plain Layout + Ghostview \end_layout @@ -1496,6 +1585,7 @@ View status collapsed \begin_layout Plain Layout + png \end_layout @@ -1507,6 +1597,7 @@ png status collapsed \begin_layout Plain Layout + pdf \end_layout @@ -1533,6 +1624,7 @@ Vector graphics format status collapsed \begin_layout Plain Layout + pdflatex \end_layout @@ -1544,6 +1636,7 @@ pdflatex status collapsed \begin_layout Plain Layout + pdf \end_layout @@ -1554,6 +1647,7 @@ pdf status collapsed \begin_layout Plain Layout + png \end_layout @@ -1564,6 +1658,7 @@ png status collapsed \begin_layout Plain Layout + jpg \end_layout @@ -1574,6 +1669,7 @@ jpg status collapsed \begin_layout Plain Layout + pdflatex \end_layout @@ -1585,6 +1681,7 @@ pdflatex status collapsed \begin_layout Plain Layout + pdf \end_layout @@ -1595,6 +1692,7 @@ pdf status collapsed \begin_layout Plain Layout + png \end_layout @@ -1605,6 +1703,7 @@ png status collapsed \begin_layout Plain Layout + jpg \end_layout @@ -1615,6 +1714,7 @@ jpg status collapsed \begin_layout Plain Layout + pdf \end_layout @@ -1625,6 +1725,7 @@ pdf status collapsed \begin_layout Plain Layout + png \end_layout @@ -1731,11 +1832,18 @@ $$l \end_inset - The `LaTeX name' + The ` +LaTeX + +name' \end_layout \begin_layout Standard -The latter should be the filename as it would be used in a LaTeX's +The latter should be the +filename + as it would be used in a +LaTeX's + \series bold \backslash @@ -1747,13 +1855,16 @@ include \begin_layout Standard Copiers can be used to do almost anything with output files. - For example, suppose you want generated pdf files to be copied to a special - directory, + For example, suppose you want generated +pdf + files to be copied to a special directory, \begin_inset Flex CharStyle:Code status collapsed \begin_layout Plain Layout -/home/you/pdf/ +/home/you/ +pdf +/ \end_layout \end_inset @@ -1794,7 +1905,9 @@ Save it in your local LyX directory—say, status collapsed \begin_layout Plain Layout -/home/you/.lyx/scripts/pdfcopier.sh +/home/you/.lyx/scripts/ +pdfcopier +.sh \end_layout \end_inset @@ -1827,17 +1940,25 @@ File formats status collapsed \begin_layout Plain Layout -PDF(pdflatex) + +PDF +( +pdflatex +) \end_layout \end_inset - format—or one of the other pdf formats—and enter + format—or one of the other +pdf + formats—and enter \begin_inset Flex CharStyle:Code status collapsed \begin_layout Plain Layout -pdfcopier.sh $$i $$o + +pdfcopier +.sh $$i $$o \end_layout \end_inset @@ -1887,8 +2008,9 @@ HTML When these formats are exported, the copier sees that not just the main HTML file but various associated files (style files, images, etc.) are also copied. - All these files are written to a subdirectory of the directory in which - the original LyX file was found. + All these files are written to a +subdirectory + of the directory in which the original LyX file was found. \begin_inset Foot status collapsed @@ -1922,6 +2044,7 @@ This copier can be customized. status collapsed \begin_layout Plain Layout + LyXconv \end_layout @@ -1936,7 +2059,9 @@ LyXconv status collapsed \begin_layout Plain Layout -/path/to/filename.lyx +/path/to/ +filename +.lyx \end_layout \end_inset @@ -1946,7 +2071,12 @@ status collapsed status collapsed \begin_layout Plain Layout -/path/to/filename.html.LyXconv +/path/to/ +filename +. +html +. +LyXconv \end_layout \end_inset @@ -2086,7 +2216,9 @@ $$b \end_inset - The base filename of the input file (i. + The base +filename + of the input file (i. \begin_inset space \thinspace{} \end_inset @@ -2151,8 +2283,12 @@ latex \end_inset - This converter runs some form of LaTeX. - This will make LyX's LaTeX error logs available. + This converter runs some form of +LaTeX +. + This will make LyX's +LaTeX + error logs available. \end_layout \begin_layout Labeling @@ -2161,12 +2297,15 @@ latex status collapsed \begin_layout Plain Layout + needaux \end_layout \end_inset - Needs the LaTeX + Needs the +LaTeX + \begin_inset Flex CharStyle:MenuItem status collapsed @@ -2185,6 +2324,7 @@ status collapsed status collapsed \begin_layout Plain Layout + xml \end_layout @@ -2222,6 +2362,7 @@ value status collapsed \begin_layout Plain Layout + parselog \end_layout @@ -2232,7 +2373,9 @@ parselog status collapsed \begin_layout Plain Layout -infile.out + +infile +.out \end_layout \end_inset @@ -2242,7 +2385,11 @@ infile.out status collapsed \begin_layout Plain Layout -script < infile.out > infile.log +script < +infile +.out > +infile +.log \end_layout \end_inset @@ -2267,6 +2414,7 @@ $$s status collapsed \begin_layout Plain Layout + resultdir \end_layout @@ -2291,7 +2439,11 @@ $$b \begin_inset Newline newline \end_inset -Note that resultdir and usetempdir make no sense together. +Note that +resultdir + and +usetempdir + make no sense together. The latter will be ignored if the former is given. \end_layout @@ -2301,6 +2453,7 @@ Note that resultdir and usetempdir make no sense together. status collapsed \begin_layout Plain Layout + resultfile \end_layout @@ -2317,8 +2470,11 @@ $$b \end_inset . - Sensible only with resultdir and optional even then; if not given, it defaults - to `index'. + Sensible only with +resultdir + and optional even then; if not given, it defaults to ` +index' +. \end_layout \begin_layout Standard @@ -2330,21 +2486,34 @@ None of these last three are presently used in any of the converters that \begin_layout Standard You do not have to define converters for all formats between which you want to convert. - For example, you will note that there is no `LyX to PostScript' converter, - but LyX will export PostScript. - It does so by first creating a LaTeX file (no converter needs to be defined - for this) which is then converted to DVI using the `LaTeX to DVI' converter, - and finally converting the resulting DVI file to PostScript. - LyX finds such `chains' of converters automatically, and it will always - choose the shortest possible chain. + For example, you will note that there is no `LyX to +PostScript' + converter, but LyX will export PostScript. + It does so by first creating a +LaTeX + file (no converter needs to be defined for this) which is then converted + to DVI using the ` +LaTeX + to +DVI' + converter, and finally converting the resulting DVI file to PostScript. + LyX finds such ` +chains' + of converters automatically, and it will always choose the shortest possible + chain. You can, though, still define multiple conversion methods between file formats. For example, the standard LyX configuration provides three ways to convert - LaTeX to PDF: Directly, using + +LaTeX + to +PDF +: Directly, using \begin_inset Flex CharStyle:MenuItem status collapsed \begin_layout Plain Layout + pdflatex \end_layout @@ -2355,6 +2524,7 @@ pdflatex status collapsed \begin_layout Plain Layout + ps2pdf \end_layout @@ -2365,6 +2535,7 @@ ps2pdf status collapsed \begin_layout Plain Layout + dvipdfm \end_layout @@ -2372,7 +2543,9 @@ dvipdfm . To define such alternate chains, you must define multiple target `file - formats', as described in section + +formats' +, as described in section \begin_inset CommandInset ref LatexCommand ref reference "sec:Formats" @@ -2385,6 +2558,7 @@ reference "sec:Formats" status collapsed \begin_layout Plain Layout + pdf \end_layout @@ -2395,6 +2569,7 @@ pdf status collapsed \begin_layout Plain Layout + pdf2 \end_layout @@ -2405,6 +2580,7 @@ pdf2 status collapsed \begin_layout Plain Layout + pdf3 \end_layout @@ -2415,7 +2591,8 @@ pdf3 status collapsed \begin_layout Plain Layout -.pdf +. +pdf \end_layout \end_inset @@ -2495,6 +2672,7 @@ LyX uses the GNU status collapsed \begin_layout Plain Layout + gettext \end_layout @@ -2507,6 +2685,7 @@ gettext status collapsed \begin_layout Plain Layout + po \end_layout @@ -2540,6 +2719,7 @@ mo status collapsed \begin_layout Plain Layout + gettext \end_layout @@ -2549,8 +2729,9 @@ gettext It is possible to do this just for yourself, but if you're going to do it, you might as well share the results of your labors with the rest of the LyX community. - Send a message to the LyX developers' list for more information about how - to proceed. + Send a message to the LyX +developers' + list for more information about how to proceed. \end_layout \begin_layout Standard @@ -2586,7 +2767,8 @@ lyx.pot status collapsed \begin_layout Plain Layout -**.po +**. +po \end_layout \end_inset @@ -2597,7 +2779,8 @@ status collapsed status collapsed \begin_layout Plain Layout -xx.po +xx. +po \end_layout \end_inset @@ -2623,8 +2806,9 @@ make lyx.pot \end_inset - in that directory, or you can use an existing po-file for some other language - as a template). + in that directory, or you can use an existing +po +-file for some other language as a template). \end_layout \begin_layout Itemize @@ -2633,7 +2817,8 @@ Edit status collapsed \begin_layout Plain Layout -xx.po +xx. +po \end_layout \end_inset @@ -2653,16 +2838,21 @@ Poedit \family typewriter KBabel \family default - (for KDE). + (for +KDE +). \family typewriter Emacs \family default - contains a `mode' for editing + contains a ` +mode' + for editing \begin_inset Flex CharStyle:Code status collapsed \begin_layout Plain Layout + po \end_layout @@ -2683,6 +2873,7 @@ po status collapsed \begin_layout Plain Layout + po \end_layout @@ -2713,7 +2904,10 @@ xx.mo status collapsed \begin_layout Plain Layout -msgfmt -o xx.mo < xx.po + +msgfmt + -o xx.mo < xx. +po \end_layout \end_inset @@ -2776,6 +2970,7 @@ As said, however, it would be best if the new status collapsed \begin_layout Plain Layout + po \end_layout @@ -2783,8 +2978,9 @@ po -file could be added to the LyX distribution, so others can use it. Adding it involves making additional changes to LyX. - So send an email to the developers' mailing list if you're interested in - doing that. + So send an email to the +developers' + mailing list if you're interested in doing that. \end_layout \begin_layout Subsubsection @@ -2826,6 +3022,7 @@ to status collapsed \begin_layout Plain Layout + gettext \end_layout @@ -2848,7 +3045,11 @@ To status collapsed \begin_layout Plain Layout -To[[as in 'From format x to format y']] +To[[as in +'From + format x to format +y' +]] \end_layout \end_inset @@ -2858,7 +3059,11 @@ To[[as in 'From format x to format y']] status collapsed \begin_layout Plain Layout -To[[as in 'From page x to page y']]. +To[[as in +'From + page x to page +y' +]]. \end_layout \end_inset @@ -2878,6 +3083,7 @@ To status collapsed \begin_layout Plain Layout + gettext \end_layout @@ -5953,7 +6159,13 @@ Settings \end_inset . - The argument in square brackets is optional: It declares any LaTeX packages + +\change_inserted 0 1243500588 + +\end_layout + +\begin_layout Standard +The argument in square brackets is optional: It declares any LaTeX packages on which the module depends. Please note that only packages about which LyX knows should be listed in the square brackets. @@ -5967,6 +6179,24 @@ The list of such packages is documented only in the source code. \end_inset LyX will not check for arbitrary packages. + +\change_inserted 0 1243500694 + It is also possible to use the form +\begin_inset Flex CharStyle:MenuItem +status collapsed + +\begin_layout Plain Layout + +\change_inserted 0 1243500706 +from->to +\end_layout + +\end_inset + +, which declares that the module can only be used when there exists a conversion + chain between formats `from' and `to'. +\change_unchanged + \end_layout \begin_layout Standard @@ -7297,6 +7527,55 @@ OutputType A string indicating what sort of output documents using this class will produce. At present, the options are: `docbook', `latex', and `literate'. +\change_inserted 0 1243500198 + +\end_layout + +\begin_layout Description + +\change_inserted 0 1243500505 +\begin_inset Flex CharStyle:Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 0 1243500208 +OutputFormat +\end_layout + +\end_inset + + A string indicating the file format (as defined in the Preferences dialog) + produced by this class. + It is mainly useful when +\begin_inset Flex CharStyle:Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 0 1243500394 +OutputType +\end_layout + +\end_inset + + is `literate' and one wants to define a new type of literate document. + This string is reset to `docbook', `latex', or `literate' when the correspondin +g +\begin_inset Flex CharStyle:Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 0 1243500473 +OutputType +\end_layout + +\end_inset + + parameter is encountered. +\change_unchanged + \end_layout \begin_layout Description diff --git a/lib/layouts/noweb.module b/lib/layouts/noweb.module index 0d97c4d3e8..f0ad6f6f8d 100644 --- a/lib/layouts/noweb.module +++ b/lib/layouts/noweb.module @@ -1,4 +1,4 @@ -#\DeclareLyXModule[noweb.sty]{Noweb literate programming} +#\DeclareLyXModule[literate->latex,noweb.sty]{Noweb literate programming} #DescriptionBegin #Allows to use Noweb as a literate programming tool. #DescriptionEnd diff --git a/lib/layouts/sweave.module b/lib/layouts/sweave.module index d579fb5897..8bd9fd3135 100644 --- a/lib/layouts/sweave.module +++ b/lib/layouts/sweave.module @@ -1,4 +1,4 @@ -#\DeclareLyXModule[Sweave.sty]{Sweave - S/R literate programming} +#\DeclareLyXModule[sweave->latex]{Sweave - S/R literate programming} #DescriptionBegin #Allows to use the statistical language S/R as a literate programming tool - Sweave. #DescriptionEnd @@ -11,7 +11,7 @@ Format 11 OutputType literate -#OutputFormat sweave +OutputFormat sweave Style Chunk Category Sweave diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index 27837f40c9..53fa54f9e3 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -48,10 +48,14 @@ import os, re, string, sys # Incremented to format 14, 14 February 2009 by gb # Rename I18NPreamble to BabelPreamble and add LangPreamble +# Incremented to format 15, 28 May 2009 by lasgouttes +# Add new tag OutputFormat; modules can be conditionned on feature +# "from->to". + # Do not forget to document format change in Customization # Manual (section "Declaring a new text class"). -currentFormat = 14 +currentFormat = 15 def usage(prog_name): @@ -227,6 +231,11 @@ def convert(lines): i += 1 continue + # This just involved new features, not any changes to old ones + if format == 14: + i += 1 + continue + # Rename I18NPreamble to BabelPreamble if format == 13: match = re_I18nPreamble.match(lines[i]) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index cbda6b010a..50374145dc 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -459,10 +459,12 @@ string Buffer::logName(LogType * type) const FileName const fname(addName(temppath(), onlyFilename(changeExtension(filename, ".log")))); + + // FIXME: how do we know this is the name of the build log? FileName const bname( addName(path, onlyFilename( changeExtension(filename, - formats.extension("literate") + ".out")))); + formats.extension(bufferFormat()) + ".out")))); // If no Latex log or Build log is newer, show Build log @@ -2662,15 +2664,14 @@ void Buffer::autoSave() const string Buffer::bufferFormat() const { - if (isDocBook()) - return "docbook"; - if (isLiterate()) - return "literate"; - if (params().useXetex) - return "xetex"; - if (params().encoding().package() == Encoding::japanese) - return "platex"; - return "latex"; + string format = params().documentClass().outputFormat(); + if (format == "latex") { + if (params().useXetex) + return "xetex"; + if (params().encoding().package() == Encoding::japanese) + return "platex"; + } + return format; } diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index efc3fc6a3b..cf26ea719b 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -19,6 +19,7 @@ #include "Buffer.h" #include "BufferParams.h" #include "ColorSet.h" +#include "Converter.h" #include "Encoding.h" #include "Floating.h" #include "FloatList.h" @@ -370,6 +371,14 @@ bool LaTeXFeatures::mustProvide(string const & name) const bool LaTeXFeatures::isAvailable(string const & name) { + string::size_type const i = name.find("->"); + if (i != string::npos) { + string const from = name.substr(0,i); + string const to = name.substr(i+2); + LYXERR0("from=[" << from << "] to=[" << to << "]"); + return theConverters().isReachable(from, to); + } + if (packages_.empty()) getAvailable(); string n = name; diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 79e8b0e7d1..de60bb1e96 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -62,7 +62,7 @@ private: }; // Keep the changes documented in the Customization manual. -int const FORMAT = 14; +int const FORMAT = 15; bool layout2layout(FileName const & filename, FileName const & tempfile) @@ -127,6 +127,7 @@ InsetLayout DocumentClass::plain_insetlayout_; TextClass::TextClass() { outputType_ = LATEX; + outputFormat_ = "latex"; columns_ = 1; sides_ = OneSide; secnumdepth_ = 3; @@ -160,6 +161,7 @@ bool TextClass::readStyle(Lexer & lexrc, Layout & lay) const enum TextClassTags { TC_OUTPUTTYPE = 1, + TC_OUTPUTFORMAT, TC_INPUT, TC_STYLE, TC_DEFAULTSTYLE, @@ -208,6 +210,7 @@ namespace { { "leftmargin", TC_LEFTMARGIN }, { "nofloat", TC_NOFLOAT }, { "nostyle", TC_NOSTYLE }, + { "outputformat", TC_OUTPUTFORMAT }, { "outputtype", TC_OUTPUTTYPE }, { "pagestyle", TC_PAGESTYLE }, { "preamble", TC_PREAMBLE }, @@ -352,8 +355,24 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt) format = lexrc.getInteger(); break; - case TC_OUTPUTTYPE: // output type definition + case TC_OUTPUTFORMAT: + if (lexrc.next()) + outputFormat_ = lexrc.getString(); + break; + + case TC_OUTPUTTYPE: readOutputType(lexrc); + switch(outputType_) { + case LATEX: + outputFormat_ = "latex"; + break; + case DOCBOOK: + outputFormat_ = "docbook"; + break; + case LITERATE: + outputFormat_ = "literate"; + break; + } break; case TC_INPUT: // Include file diff --git a/src/TextClass.h b/src/TextClass.h index 7255165c23..2ea9bba86c 100644 --- a/src/TextClass.h +++ b/src/TextClass.h @@ -191,6 +191,8 @@ public: std::string const & latexname() const { return latexname_; } /// Can be LaTeX, DocBook, etc. OutputType outputType() const { return outputType_; } + /// Can be latex, docbook ... (the name of a format) + std::string outputFormat() const { return outputFormat_; } protected: /// Protect construction TextClass(); @@ -272,6 +274,8 @@ protected: int tocdepth_; /// Can be LaTeX, DocBook, etc. OutputType outputType_; + /// Can be latex, docbook ... (the name of a format) + std::string outputFormat_; /** Base font. The paragraph and layout fonts are resolved against this font. This has to be fully instantiated. Attributes FONT_INHERIT, FONT_IGNORE, and FONT_TOGGLE are @@ -406,8 +410,6 @@ public: int max_toclevel() const { return max_toclevel_; } /// returns true if the class has a ToC structure bool hasTocLevels() const; - /// Can be LaTeX, DocBook, etc. - OutputType outputType() const { return outputType_; } protected: /// Constructs a DocumentClass based upon a LayoutFile. DocumentClass(LayoutFile const & tc); diff --git a/src/frontends/qt4/GuiLog.cpp b/src/frontends/qt4/GuiLog.cpp index 466c75fa4c..abdd0eafdc 100644 --- a/src/frontends/qt4/GuiLog.cpp +++ b/src/frontends/qt4/GuiLog.cpp @@ -150,6 +150,7 @@ bool GuiLog::initialiseParams(string const & data) if (logtype == "latex") type_ = LatexLog; + // FIXME: not sure "literate" still works. else if (logtype == "literate") type_ = LiterateLog; else if (logtype == "lyx2lyx") -- 2.39.2