]> git.lyx.org Git - lyx.git/blobdiff - lib/examples/noweb2lyx.lyx
chkconfig.ltx: add lh fonts
[lyx.git] / lib / examples / noweb2lyx.lyx
index 60204b04eb01b000ecddadad5b2bd68b8cc80d95..9c4b72312454fde53796a8b14f0671f41329fafd 100644 (file)
@@ -1,6 +1,8 @@
-#LyX 1.2 created this file. For more info see http://www.lyx.org/
-\lyxformat 220
-\textclass literate-article
+#LyX 2.1 created this file. For more info see http://www.lyx.org/
+\lyxformat 448
+\begin_document
+\begin_header
+\textclass article
 \begin_preamble
 %
 % This relaxes the noweb constraint that chunks are
 \def\nwendcode{\endtrivlist \endgroup}
 \let\nwdocspar=\smallbreak
 \end_preamble
+\use_default_options false
+\begin_modules
+noweb
+\end_modules
+\maintain_unincluded_children false
 \language english
+\language_package default
 \inputencoding default
-\fontscheme default
+\fontencoding global
+\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
+\bibtex_command default
+\index_command default
 \paperfontsize default
-\spacing single 
-\papersize Default
-\paperpackage a4
-\use_geometry 0
-\use_amsmath 0
-\use_natbib 0
-\use_numerical_citations 0
+\spacing single
+\use_hyperref false
+\papersize default
+\use_geometry false
+\use_package amsmath 0
+\use_package amssymb 0
+\use_package esint 0
+\use_package mathdots 1
+\use_package mathtools 0
+\use_package mhchem 1
+\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
+\index Index
+\shortcut idx
+\color #008000
+\end_index
 \secnumdepth 3
 \tocdepth 3
 \paragraph_separation indent
-\defskip medskip
+\paragraph_indentation default
 \quotes_language english
-\quotes_times 2
 \papercolumns 1
 \papersides 1
 \paperpagestyle default
+\tracking_changes false
+\output_changes false
+\html_math_output 0
+\html_css_as_file 0
+\html_be_strict false
+\end_header
 
-\layout Title
+\begin_body
 
+\begin_layout Title
 
-\noun on 
+\noun on
 noweb2lyx
-\layout Author
+\end_layout
 
+\begin_layout Author
 Kayvan A.
  Sylvan <kayvan@sylvan.com>
-\layout Date
+\end_layout
 
+\begin_layout Date
 May 6, 1999
-\layout Abstract
+\end_layout
 
+\begin_layout Abstract
 This document describes and implements a perl script for importing noweb
  files into LyX
-\layout Standard
-\pagebreak_bottom 
+\end_layout
+
+\begin_layout Standard
+\begin_inset CommandInset toc
+LatexCommand tableofcontents
+
+\end_inset
+
 
-\begin_inset LatexCommand \tableofcontents{}
+\end_layout
 
-\end_inset 
+\begin_layout Standard
+\begin_inset Newpage newpage
+\end_inset
 
 
-\layout Section
+\end_layout
 
+\begin_layout Section
 Introduction
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 Since version 1.0.1, LyX now supports Literate Programming using 
-\noun on 
+\noun on
 noweb
-\noun default 
+\noun default
 .
  This addition to LyX made it very pleasant to write programs in the literate
  style (like this one).
  In addition to being able to write new literate programs, it would be quite
  useful if old 
-\noun on 
+\noun on
 noweb
-\noun default 
+\noun default
  code could be imported into LyX in some fashion.
  That's where this program comes in.
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 The purpose of 
-\noun on 
+\noun on
 noweb2lyx
-\noun default 
+\noun default
  is to convert a 
-\noun on 
+\noun on
 noweb
-\noun default 
+\noun default
  file to LyX.
-\layout Scrap
+\end_layout
+
+\begin_layout Chunk
 
 <<noweb2lyx.in>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 #!@PERL@
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 # 
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 # Copyright (C) 1999 Kayvan A.
  Sylvan <kayvan@sylvan.com>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 # You are free to use and modify this code under the terms of
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 # the GNU General Public Licence version 2 or later.
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 #
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 # Written with assistance from:
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 #   Edmar Wienskoski Jr.
  <edmar-w-jr@technologist.com>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 #   Amir Karger <karger@post.harvard.edu>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 #
-\newline 
-# $Id: noweb2lyx.lyx,v 1.3 2002/01/07 10:17:42 lasgouttes Exp $
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
+# $Id: noweb2lyx.lyx,v 1.5 2005/07/18 09:42:27 jamatos Exp $
+\end_layout
+
+\begin_layout Chunk
+
 #
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 # NOTE: This file was automatically generated from noweb2lyx.lyx using noweb.
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 #
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 <<Setup variables from user supplied args>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 <<Subroutines>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 <<Convert noweb to LyX>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @
-\layout Section
+\end_layout
 
+\begin_layout Section
 The Noweb file defined
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 A 
-\noun on 
+\noun on
 noweb
-\noun default 
+\noun default
  file is a collection of documentation and code chunks.
  Documentation chunks simply start with an ``@'' and have no name:
-\layout LyX-Code
+\end_layout
 
+\begin_layout LyX-Code
 @ Here is some documentation.
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
+
 We can do arbitrary LaTeX code here.
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 [...
  blah blah blah ...]
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 Code chunks look like this:
-\layout LyX-Code
+\end_layout
 
+\begin_layout LyX-Code
 <
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 {}
-\end_inset 
+\end_layout
+
+\end_inset
 
 <Name of chunk here>
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 {}
-\end_inset 
+\end_layout
+
+\end_inset
 
 >=
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 {...
  code for the chunk goes here ...}
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 @ 
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 The ``@'' is a necessary delimiter to end the code chunk.
  The other form that the ``@'' line takes is as follows:
-\layout LyX-Code
+\end_layout
 
+\begin_layout LyX-Code
 <
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 {}
-\end_inset 
+\end_layout
+
+\end_inset
 
 <Name of chunk here>
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 {}
-\end_inset 
+\end_layout
+
+\end_inset
 
 >=
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 {...
  code for the chunk ...}
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 @ %def identifier1 identifier2
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 In the latter form, we are declaring to 
-\noun on 
+\noun on
 noweb
-\noun default 
+\noun default
  that this code chunk defines identifier1, identifier2, etc.
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 When first tackling this problem, I spoke with members of the LyX team that
  knew about the literate programming extensions and reLyX (the LaTeX importing
  code).
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 One of the first ideas was to extend the reLyX code to understand the 
-\noun on 
+\noun on
 noweb
-\noun default 
+\noun default
  code chunks.
  This proved to be too hard and presents other problems
 \begin_inset Foot
-collapsed true
-
-\layout Standard
+status collapsed
 
+\begin_layout Plain Layout
 Not the least of these problems is the fact that << is a quote in French.
-\end_inset 
+\end_layout
+
+\end_inset
 
 .
  On the other hand, it turns out that reLyX contains a very useful literal
  quoting mechanism.
  If the input file contains the construct
-\layout LyX-Code
+\end_layout
 
+\begin_layout LyX-Code
 
-\backslash 
+\backslash
 begin{reLyXskip}
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 {...
  LaTeX stuff ...}
-\newline 
+\begin_inset Newline newline
+\end_inset
 
-\backslash 
+
+\backslash
 end{reLyXskip}
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 then reLyX will copy the surrounded code to the output file verbatim.
  Given this, the first part of the translation is easy; we simply have to
  copy the code chunks into an intermediate file that surrounds them with
  
-\family typewriter 
+\family typewriter
 
-\backslash 
+\backslash
 begin{reLyXskip}
-\family default 
+\family default
  and 
-\family typewriter 
+\family typewriter
 
-\backslash 
+\backslash
 end{reLyXskip}
-\family default 
+\family default
 .
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 Once reLyX is done with the input file, the problem is reduced to changing
- the code chunks from LyX's LaTeX layout to the Scrap layout.
-\layout Standard
+ the code chunks from LyX's LaTeX layout to the Chunk layout.
+\end_layout
 
+\begin_layout Standard
 There is one final constraint on 
-\noun on 
+\noun on
 noweb2lyx
-\noun default 
+\noun default
 .
  We want to be able to run it as a simple pre-processor and post-processor
  from within reLyX.
  We can accomplish this by setting the flags 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
 \color none
 
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 [[pre_only]]
-\end_inset 
+\end_layout
 
+\end_inset
 
-\family default 
-\series default 
-\shape default 
-\size default 
-\emph default 
-\bar default 
-\noun default 
-\color default
- and 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
+
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+\color inherit
+and
 \color none
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
 
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 [[post_only]]
-\end_inset 
+\end_layout
 
+\end_inset
 
-\family default 
-\series default 
-\shape default 
-\size default 
-\emph default 
-\bar default 
-\noun default 
-\color default
- before we reach the main conversion code.
-\layout Standard
 
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+\color inherit
+before we reach the main conversion code.
+\end_layout
+
+\begin_layout Standard
 With all that preamble out of the way, we now have the basic high-level
  outline for our code:
-\layout Scrap
+\end_layout
+
+\begin_layout Chunk
 
 <<Convert noweb to LyX>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 if (!$post_only) {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   <<Transform noweb for reLyX>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 }
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 if ((!$pre_only) && (!$post_only)) {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   <<Run reLyX on intermediate file>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 }
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 if (!$pre_only) {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   <<Fix up LyX file>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 }
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 <<Clean up>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @
-\layout Section
+\end_layout
 
+\begin_layout Section
 Making a file that reLyX can process
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 In this section, we present the code that performs the task of creating
  the intermediate file that reLyX can process, using the algorithm that
  we just outlined.
  This algorithm is outlined in the code that follows:
-\layout Scrap
+\end_layout
+
+\begin_layout Chunk
+
+\end_layout
+
+\begin_layout Chunk
 
 <<Transform noweb for reLyX>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 <<Setup INPUT and OUTPUT>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 inputline: while(<INPUT>)
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   if (/^
-\backslash 
+\backslash
 s*
-\backslash 
+\backslash
 <
-\backslash 
+\backslash
 <.*
-\backslash 
+\backslash
 >
-\backslash 
->=/) { # Beginning of a noweb scrap
-\newline 
+\backslash
+>=/) { # Beginning of a noweb chunk
+\end_layout
+
+\begin_layout Chunk
+
     <<Read in and output the noweb code chunk>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   } elsif (/^@
-\backslash 
+\backslash
 s+(.*)/) { # Beginning of a documentation chunk
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
     print OUTPUT $1; # We do not need the ``@'' part
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   } elsif (/
-\backslash 
+\backslash
 [
-\backslash 
+\backslash
 [.+
-\backslash 
+\backslash
 ]
-\backslash 
+\backslash
 ]/) { # noweb quoted code
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
     <<Perform special input quoting of [[var]]>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   } else {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
     print OUTPUT; # Just let the line pass through
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   }
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 }
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 <<Close INPUT and OUTPUT>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 In the code above, we do some pre-processing of the noweb ``[[...]]'' construct.
  This avoids some problems with reLyX confusing lists composed of ``[[...]]''
  constructs.
-\layout Scrap
+\end_layout
+
+\begin_layout Chunk
 
 <<Perform special input quoting of [[var]]>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 s/
-\backslash 
+\backslash
 [
-\backslash 
+\backslash
 [.+?
-\backslash 
+\backslash
 ]{2,}/{$&}/g;
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 print OUTPUT;
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 @
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 While reading in the 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
 \color none
 
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 [[INPUT]]
-\end_inset 
-
-
-\family default 
-\series default 
-\shape default 
-\size default 
-\emph default 
-\bar default 
-\noun default 
-\color default
- file, once we have identified a 
-\noun on 
+\end_layout
+
+\end_inset
+
+
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+\color inherit
+file, once we have identified a 
+\noun on
 noweb
-\noun default 
+\noun default
  code chunk, we transform it into a form that is usable by reLyX.
-\layout Scrap
+\end_layout
+
+\begin_layout Chunk
 
 <<Read in and output the noweb code chunk>>= 
-\newline 
-<<Save the beginning of the scrap to savedScrap>>
-\newline 
-<<Concatenate the rest of the scrap>>
-\newline 
-<<print out the scrap in a reLyXskip block>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
+<<Save the beginning of the chunk to savedchunk>>
+\end_layout
+
+\begin_layout Chunk
+
+<<Concatenate the rest of the chunk>>
+\end_layout
+
+\begin_layout Chunk
+
+<<print out the chunk in a reLyXskip block>>
+\end_layout
+
+\begin_layout Chunk
+
 @
-\layout Subsection
+\end_layout
 
+\begin_layout Subsection
 File input and output for the pre-processing step
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 In 
-\noun on 
+\noun on
 noweb2lyx
-\noun default 
+\noun default
 , we will use 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
 \color none
 
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 [[INPUT]]
-\end_inset 
+\end_layout
 
+\end_inset
 
-\family default 
-\series default 
-\shape default 
-\size default 
-\emph default 
-\bar default 
-\noun default 
-\color default
- and 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
+
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+\color inherit
+and
 \color none
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
 
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 [[OUTPUT]]
-\end_inset 
-
-
-\family default 
-\series default 
-\shape default 
-\size default 
-\emph default 
-\bar default 
-\noun default 
-\color default
- to read and write files.
+\end_layout
+
+\end_inset
+
+
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+\color inherit
+to read and write files.
  In the code fragment above, we need to read from the input file and write
  to a file that will be later transformed by reLyX.
  If we are being called only to pre-process the input file, then there is
  no need to create a temporary file.
-\layout Scrap
+\end_layout
+
+\begin_layout Chunk
 
 <<Setup INPUT and OUTPUT>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 if ($pre_only) {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   &setup_files($input_file, $output_file);
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 } else {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   $relyx_file = "temp$$";
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   &setup_files($input_file, $relyx_file);
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 }
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 This code uses a small perl subroutine, 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
 \color none
 
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 [[setup_files]]
-\end_inset 
+\end_layout
 
+\end_inset
 
-\family default 
-\series default 
-\shape default 
-\size default 
-\emph default 
-\bar default 
-\noun default 
-\color default
+
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+\color inherit
 , which we define below:
-\layout Scrap
+\end_layout
+
+\begin_layout Chunk
 
 <<Subroutines>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 sub setup_files {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   my($in, $out) = @_;
-\newline 
-  open(INPUT, "<$in") || die "Can not read $in: $!
-\backslash 
+\end_layout
+
+\begin_layout Chunk
+
+  open(INPUT, "<$in") || die "Cannot read $in: $!
+\backslash
 n";
-\newline 
-  open(OUTPUT, ">$out") || die "Can not write $out: $!
-\backslash 
+\end_layout
+
+\begin_layout Chunk
+
+  open(OUTPUT, ">$out") || die "Cannot write $out: $!
+\backslash
 n";
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 }
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @ %def setup_files   
-\layout Subsection
+\end_layout
 
+\begin_layout Subsection
 Reading in the 
-\noun on 
+\noun on
 noweb
-\noun default 
- scrap
-\layout Standard
-
-After we see the beginning of the scrap, we need to read in and save the
- rest of the scrap for output.
-\layout Scrap
-
-<<Save the beginning of the scrap to savedScrap>>=
-\newline 
-$savedScrap = $_;
-\newline 
+\noun default
+ chunk
+\end_layout
+
+\begin_layout Standard
+After we see the beginning of the chunk, we need to read in and save the
+ rest of the chunk for output.
+\end_layout
+
+\begin_layout Chunk
+
+<<Save the beginning of the chunk to savedchunk>>=
+\end_layout
+
+\begin_layout Chunk
+
+$savedchunk = $_;
+\end_layout
+
+\begin_layout Chunk
+
 $endLine = "";
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @
-\layout Scrap
-
-<<Concatenate the rest of the scrap>>=
-\newline 
-scrapline: while (<INPUT>) {
-\newline 
-  last scrapline if /^@
-\backslash 
+\end_layout
+
+\begin_layout Chunk
+
+<<Concatenate the rest of the chunk>>=
+\begin_inset Newline newline
+\end_inset
+
+chunkline: while (<INPUT>) {
+\begin_inset Newline newline
+\end_inset
+
+  last chunkline if /^@
+\backslash
 s+/;
-\newline 
-  $savedScrap .= $_;
-\newline 
+\begin_inset Newline newline
+\end_inset
+
+  $savedchunk .= $_;
+\begin_inset Newline newline
+\end_inset
+
 };
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 switch: {
-\newline 
+\begin_inset Newline newline
+\end_inset
+
   if (/^@
-\backslash 
-s+$/) {$savedScrap .= $_; last switch; }
-\newline 
+\backslash
+s+$/) {$savedchunk .= $_; last switch; }
+\begin_inset Newline newline
+\end_inset
+
   if (/^@
-\backslash 
-s+%def.*$/) {$savedScrap .= $_; last switch; }
-\newline 
+\backslash
+s+%def.*$/) {$savedchunk .= $_; last switch; }
+\begin_inset Newline newline
+\end_inset
+
   if (/^@
-\backslash 
-s+(.*)$/) {$savedScrap .= "@
-\backslash 
+\backslash
+s+(.*)$/) {$savedchunk .= "@
+\backslash
 n"; $endLine = "$1
-\backslash 
+\backslash
 n"; }
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 }
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 @
-\layout Subsection
+\end_layout
 
-Printing out the scrap
-\layout Standard
+\begin_layout Subsection
+Printing out the chunk
+\end_layout
 
+\begin_layout Standard
 The final piece of the first pass of the conversion is done by this code.
-\layout Scrap
+\end_layout
+
+\begin_layout Chunk
+
+<<print out the chunk in a reLyXskip block>>=
+\end_layout
+
+\begin_layout Chunk
 
-<<print out the scrap in a reLyXskip block>>=
-\newline 
 print OUTPUT "
-\backslash 
+\backslash
 
-\backslash 
+\backslash
 begin{reLyXskip}
-\backslash 
+\backslash
 n";
-\newline 
-print OUTPUT $savedScrap;
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
+print OUTPUT $savedchunk;
+\end_layout
+
+\begin_layout Chunk
+
 print OUTPUT "
-\backslash 
+\backslash
 
-\backslash 
+\backslash
 end{reLyXskip}
-\backslash 
+\backslash
 n
-\backslash 
+\backslash
 n";
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 print OUTPUT "$endLine";
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 Finally, we need to close the 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
 \color none
 
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 [[INPUT]]
-\end_inset 
+\end_layout
 
+\end_inset
 
-\family default 
-\series default 
-\shape default 
-\size default 
-\emph default 
-\bar default 
-\noun default 
-\color default
- and 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
+
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+\color inherit
+and
 \color none
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
 
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 [[OUTPUT]]
-\end_inset 
+\end_layout
 
+\end_inset
 
-\family default 
-\series default 
-\shape default 
-\size default 
-\emph default 
-\bar default 
-\noun default 
-\color default
- files.
-\layout Scrap
+
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+\color inherit
+files.
+\end_layout
+
+\begin_layout Chunk
 
 <<Close INPUT and OUTPUT>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 close(INPUT);
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 close(OUTPUT);
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @
-\layout Section
+\end_layout
 
+\begin_layout Section
 Running reLyX
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 In this section, we describe and implement the code that runs reLyX on the
  intermediate file 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
 \color none
 
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 [[relyx_file]]
-\end_inset 
+\end_layout
 
+\end_inset
 
-\family default 
-\series default 
-\shape default 
-\size default 
-\emph default 
-\bar default 
-\noun default 
-\color default
+
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+\color inherit
 .
  
-\layout Subsection
+\end_layout
 
+\begin_layout Subsection
 Selecting the document class
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 In order to run reLyX, we need to know the article class of the input document
  (to choose the corresponding literate document layout).
  For this, we need to parse the intermediate file.
-\layout Scrap
+\end_layout
+
+\begin_layout Chunk
 
 <<Run reLyX on intermediate file>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 <<Parse for document class>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 <<Run reLyX with document class>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 In the code below, you'll see a strange regular expression to search for
  the document class.
  The reason for this kludge is that without it, we can't run 
-\noun on 
+\noun on
 noweb2lyx
-\noun default 
+\noun default
  on the 
-\emph on 
+\emph on
 noweb2lyx.nw
-\emph default 
+\emph default
  file that is generated by LyX
 \begin_inset Foot
-collapsed true
-
-\layout Standard
+status collapsed
 
+\begin_layout Plain Layout
 reLyX searches for 
-\backslash 
+\backslash
 
-\backslash 
+\backslash
 doc
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
 \color none
 
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 {}
-\end_inset 
+\end_layout
+
+\end_inset
 
 
-\family default 
-\series default 
-\shape default 
-\size default 
-\emph default 
-\bar default 
-\noun default 
-\color default
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+\color inherit
 ument
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
 \color none
 
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 {}
-\end_inset 
+\end_layout
+
+\end_inset
 
 
-\family default 
-\series default 
-\shape default 
-\size default 
-\emph default 
-\bar default 
-\noun default 
-\color default
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+\color inherit
 class and gets confused, so we have to obfuscate it slightly.
-\end_inset 
+\end_layout
+
+\end_inset
 
 .
  With the regular expression as it is, we can actually run 
-\noun on 
+\noun on
 noweb2lyx
-\noun default 
+\noun default
  on itself and a produce a quite reasonable LyX file.
-\layout Scrap
+\end_layout
+
+\begin_layout Chunk
 
 <<Parse for document class>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 open(INPUT, "<$relyx_file") ||
-\newline 
-  die "Can not read $relyx_file: $!
-\backslash 
+\end_layout
+
+\begin_layout Chunk
+
+  die "Cannot read $relyx_file: $!
+\backslash
 n";
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 $class = "article"; # default if none found
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 parse: while(<INPUT>) {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   if (/
-\backslash 
+\backslash
 
-\backslash 
+\backslash
 docu[m]entclass{(.*)}/) {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
     $class = $1;
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
     last parse;
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   }
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 }
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 close(INPUT);
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @
-\layout Subsection
+\end_layout
 
+\begin_layout Subsection
 Running reLyX with the corresponding literate document layout
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 Now that we know what the document class ought to be, we do:
-\layout Scrap
+\end_layout
+
+\begin_layout Chunk
 
 <<Run reLyX with document class>>= 
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 $doc_class = "literate-" .
  $class;
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 die "reLyX returned non-zero: $!
-\backslash 
+\backslash
 n"
-\newline 
+\begin_inset Newline newline
+\end_inset
+
   if (system("reLyX -c $doc_class $relyx_file"));
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 @
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 reLyX performs the main bulk of the translation work.
  Note that if the ``literate-
-\emph on 
+\emph on
 class
-\emph default 
+\emph default
 '' document layout is not found, then reLyX will fail with an error.
  In that case, you may need to modify your 
-\noun on 
+\noun on
 noweb
-\noun default 
+\noun default
  input file to a supported document type.
-\layout Section
+\end_layout
 
+\begin_layout Section
 Fixing the reLyX output
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 We need to perform some post-processing of what reLyX produces in order
  to have the best output for our literate document.
  The outline of the post-processing steps are:
-\layout Scrap
+\end_layout
+
+\begin_layout Chunk
 
 <<Fix up LyX file>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 <<Setup INPUT and OUTPUT for the final output>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 line: while(<INPUT>)
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   <<Fix code chunks in latex layout>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   <<Fix [[var]] noweb construct>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   print OUTPUT; # default
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 } 
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 <<Close INPUT and OUTPUT>>
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 Note that in the perl code that is contained in the 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
 \color none
 
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 [[while(<INPUT>)]]
-\end_inset 
-
-
-\family default 
-\series default 
-\shape default 
-\size default 
-\emph default 
-\bar default 
-\noun default 
-\color default
- loop above, the perl construct 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
+\end_layout
+
+\end_inset
+
+
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+\color inherit
+loop above, the perl construct
 \color none
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
 
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 [[next line]]
-\end_inset 
-
-
-\family default 
-\series default 
-\shape default 
-\size default 
-\emph default 
-\bar default 
-\noun default 
-\color default
- is sufficient to restart the loop.
+\end_layout
+
+\end_inset
+
+
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+\color inherit
+is sufficient to restart the loop.
  We can use this construct to do some relatively complex parsing of the
  reLyX generated file.
-\layout Subsection
+\end_layout
 
+\begin_layout Subsection
 File input and output for the post-processing
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 Setting up the 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
 \color none
 
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 [[INPUT]]
-\end_inset 
+\end_layout
 
+\end_inset
 
-\family default 
-\series default 
-\shape default 
-\size default 
-\emph default 
-\bar default 
-\noun default 
-\color default
- and 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
+
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+\color inherit
+and
 \color none
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
 
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 [[OUTPUT]]
-\end_inset 
+\end_layout
+
+\end_inset
 
 
-\family default 
-\series default 
-\shape default 
-\size default 
-\emph default 
-\bar default 
-\noun default 
-\color default
- is taken care of by this code:
-\layout Scrap
+\family default
+\series default
+\shape default
+\size default
+\emph default
+\bar default
+\noun default
+\color inherit
+is taken care of by this code:
+\end_layout
+
+\begin_layout Chunk
 
 <<Setup INPUT and OUTPUT for the final output>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 if ($post_only) {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   &setup_files("$input_file", "$output_file");
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 } else {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   &setup_files("$relyx_file.lyx", "$output_file");
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 }
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @
-\layout Subsection
+\end_layout
 
-Making sure the code chunks are in the Scrap layout
-\layout Standard
+\begin_layout Subsection
+Making sure the code chunks are in the Chunk layout
+\end_layout
 
+\begin_layout Standard
 Now, as we outlined before, the final step is transforming the code-chunks
- which have been put into a LaTeX layout by LyX into the scrap layout.
-\layout Scrap
+ which have been put into a LaTeX layout by LyX into the Chunk layout.
+\end_layout
+
+\begin_layout Chunk
 
 <<Fix code chunks in latex layout>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 if (/
-\backslash 
+\backslash
 
-\backslash 
+\backslash
 latex latex/) { # Beginning of some latex code
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   if (($line = <INPUT>) =~ /^
-\backslash 
-s*<</) { # code scrap
-\newline 
-    <<Transform this chunk into layout scrap>>
-\newline 
+\backslash
+s*<</) { # code chunk
+\end_layout
+
+\begin_layout Chunk
+
+    <<Transform this chunk into layout chunk>>
+\end_layout
+
+\begin_layout Chunk
+
   } else {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
     # print the 
-\backslash 
+\backslash
 latex latex line + next line
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
     print OUTPUT "$_$line";
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   }
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   next line;
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 }
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 When we are sure that we are in a code chunk, we must read in the rest of
- the code chunk and output a scrap layout for it:
-\layout Scrap
+ the code chunk and output a chunk layout for it:
+\end_layout
+
+\begin_layout Chunk
+
+<<Transform this chunk into layout chunk>>=
+\end_layout
 
-<<Transform this chunk into layout scrap>>=
-\newline 
-$savedScrap = "
-\backslash 
+\begin_layout Chunk
 
-\backslash 
-layout Scrap
-\backslash 
+\end_layout
+
+\begin_layout Chunk
+
+$savedchunk = "
+\backslash
+
+\backslash
+layout Chunk
+\backslash
 n
-\backslash 
+\backslash
 n$line";
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 codeline: while (<INPUT>) {
-\newline 
-  $savedScrap .= $_;
-\newline 
+\begin_inset Newline newline
+\end_inset
+
+  $savedchunk .= $_;
+\begin_inset Newline newline
+\end_inset
+
   last codeline if /^@
-\backslash 
+\backslash
 s+/;
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 };
-\newline 
-print OUTPUT $savedScrap;
-\newline 
+\begin_inset Newline newline
+\end_inset
+
+print OUTPUT $savedchunk;
+\begin_inset Newline newline
+\end_inset
+
 <<Slurp up to the end of the latex layout>>
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 @
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 Okay, now we just need to eat the rest of the latex layout.
  There should only be a few different types of lines for us to match:
-\layout Scrap
+\end_layout
+
+\begin_layout Chunk
 
 <<Slurp up to the end of the latex layout>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 slurp: while (<INPUT>) {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   last slurp if /
-\backslash 
+\backslash
 
-\backslash 
+\backslash
 latex /;
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   next slurp if /
-\backslash 
+\backslash
 
-\backslash 
+\backslash
 newline/;
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   next slurp if /^
-\backslash 
+\backslash
 s*$/;
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   warn "confused by line: $_";
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 }
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @
-\layout Subsection
+\end_layout
 
+\begin_layout Subsection
 Taking care of the 
-\noun on 
+\noun on
 noweb
-\noun default 
+\noun default
  
-\emph on 
+\emph on
 [[quoted code]]
-\emph default 
+\emph default
  construct
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 
-\noun on 
+\noun on
 noweb
-\noun default 
+\noun default
  allows the user to use a special code quoting mechanism in documentation
  chunks.
  Fixing this ``[[quoted-code]]'' 
-\noun on 
+\noun on
 noweb
-\noun default 
+\noun default
  syntax means putting the ``[[quoted-code]]'' in a LaTeX layout in the LyX
  file.
  Otherwise, LyX will backslash-quote the brackets, creating ugly output.
  The quoted-code is transformed by 
-\noun on 
+\noun on
 noweb
-\noun default 
+\noun default
  when it generates the final LaTeX code.
-\layout Scrap
+\end_layout
+
+\begin_layout Chunk
 
 <<Fix [[var]] noweb construct>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 if (/
-\backslash 
+\backslash
 [
-\backslash 
+\backslash
 [.+
-\backslash 
+\backslash
 ]
-\backslash 
+\backslash
 ]/) { # special code for [[var]]
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   s/
-\backslash 
+\backslash
 [
-\backslash 
+\backslash
 [.+?
-\backslash 
+\backslash
 ]{2,}/
-\backslash 
+\backslash
 n
-\backslash 
+\backslash
 
-\backslash 
+\backslash
 latex latex
-\backslash 
+\backslash
 n$&
-\backslash 
+\backslash
 n
-\backslash 
+\backslash
 
-\backslash 
+\backslash
 latex default
-\backslash 
+\backslash
 n/g;
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   print OUTPUT;
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   next line;
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 }
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @
-\layout Section
+\end_layout
 
+\begin_layout Section
 Cleaning up intermediate files
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 The cleanup code is very simple:
-\layout Scrap
+\end_layout
+
+\begin_layout Chunk
 
 <<Clean up>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 system("rm -f $relyx_file*") unless ($post_only || $pre_only);
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @
-\layout Section
+\end_layout
 
+\begin_layout Section
 User supplied arguments
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 The 
-\noun on 
+\noun on
 noweb2lyx
-\noun default 
+\noun default
  script understands two arguments, input-file and output-file.
  It is also set up to be used internally by reLyX to pre-process or postprocess
  files in the import pipeline.
-\layout Scrap
+\end_layout
+
+\begin_layout Chunk
 
 <<Setup variables from user supplied args>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 &usage() if ($#ARGV < 1); # zero or one argument 
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 if ($ARGV[0] eq "-pre") {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   &usage unless ($#ARGV == 2);
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   $input_file = $ARGV[1]; $output_file = $ARGV[2]; $pre_only = 1;
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 } elsif ($ARGV[0] eq "-post") {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   &usage unless ($#ARGV == 2);
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   $input_file = $ARGV[1]; $output_file = $ARGV[2]; $post_only = 1;
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 } else {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   &usage unless ($#ARGV == 1);
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   $input_file = $ARGV[0]; $output_file = $ARGV[1];
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   $pre_only = 0; $post_only = 0;
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 }
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @ %def input_file output_file pre_only post_only
-\layout Scrap
+\end_layout
+
+\begin_layout Chunk
 
 <<Subroutines>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 sub usage() {
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
   print "Usage: noweb2lyx [-pre | -post] input-file output-file
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
+\begin_inset Newline newline
+\end_inset
 
-\newline 
 If -pre is specified, only pre-processes the input-file for reLyX.
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 Similarly, in the case of -post, post-processes reLyX output.
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 In case of bugs, Email Kayvan Sylvan <kayvan
-\backslash 
+\backslash
 @sylvan.com>.
-\backslash 
+\backslash
 n";
-\newline 
+\begin_inset Newline newline
+\end_inset
+
   exit;
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 }
-\newline 
+\begin_inset Newline newline
+\end_inset
+
 @ %def usage
-\layout Section
+\end_layout
 
+\begin_layout Section
 Generating the 
-\noun on 
+\noun on
 noweb2lyx
-\noun default 
+\noun default
  script
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 The noweb2lyx script can be tangled from LyX if you set 
-\family typewriter 
+\family typewriter
 
-\backslash 
+\backslash
 build_command
-\family default 
- to call a generic script that always extracts a scrap named 
-\family typewriter 
+\family default
+ to call a generic script that always extracts a chunk named 
+\family typewriter
 build-script
-\family default 
+\family default
  and executes it.
  Here is an example of such a script:
-\layout LyX-Code
+\end_layout
 
+\begin_layout LyX-Code
 #!/bin/sh
-\newline 
-notangle -Rbuild-script $1 | sh
-\layout Scrap
+\begin_inset Newline newline
+\end_inset
+
+notangle -Rbuild-script $1 | env NOWEB_SOURCE=$1 NOWEB_OUTPUT_DIR=$2 sh
+\end_layout
+
+\begin_layout Chunk
 
 <<build-script>>=
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 PREFIX=/usr
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 notangle -Rnoweb2lyx.in noweb2lyx.nw > noweb2lyx.in
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 sed -e "s=@PERL@=$PREFIX/bin/perl=" noweb2lyx.in > noweb2lyx
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 chmod +x noweb2lyx
-\newline 
+\end_layout
+
+\begin_layout Chunk
+
 @
-\layout Section*
-\pagebreak_top 
+\end_layout
+
+\begin_layout Standard
+\begin_inset Newpage newpage
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section*
 Macros
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
 \color none
-
 \begin_inset ERT
-status Collapsed
+status collapsed
+
+\begin_layout Plain Layout
 
-\layout Standard
 
-\backslash 
+\backslash
 nowebchunks
-\end_inset 
+\end_layout
 
+\end_inset
 
-\layout Section*
 
+\end_layout
+
+\begin_layout Section*
 Identifiers
-\layout Standard
+\end_layout
 
+\begin_layout Standard
 
-\family roman 
-\series medium 
-\shape up 
-\size normal 
-\emph off 
-\bar no 
-\noun off 
+\family roman
+\series medium
+\shape up
+\size normal
+\emph off
+\bar no
+\noun off
 \color none
-
 \begin_inset ERT
-status Collapsed
+status collapsed
 
-\layout Standard
+\begin_layout Plain Layout
 
-\backslash 
+
+\backslash
 nowebindex
-\end_inset 
+\end_layout
+
+\end_inset
+
 
+\end_layout
 
-\the_end
+\end_body
+\end_document