]> git.lyx.org Git - lyx.git/blobdiff - lib/examples/noweb2lyx.lyx
Insert correct shortcut for environment split
[lyx.git] / lib / examples / noweb2lyx.lyx
index e9969882287775093de9b6854599bc9979f22010..5acd467f6492d14534bf9876adde545170426b5f 100644 (file)
@@ -1,8 +1,10 @@
-#LyX 1.4.0cvs created this file. For more info see http://www.lyx.org/
-\lyxformat 243
+#LyX 2.3 created this file. For more info see http://www.lyx.org/
+\lyxformat 544
 \begin_document
 \begin_header
-\textclass literate-article
+\save_transient_properties true
+\origin /systemlyxdir/examples/
+\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" "default"
+\font_sans "default" "default"
+\font_typewriter "default" "default"
+\font_math "auto" "auto"
+\font_default_family default
+\use_non_tex_fonts false
+\font_sc false
+\font_osf false
+\font_sf_scale 100 100
+\font_tt_scale 100 100
+\use_microtype false
+\use_dash_ligatures false
 \graphics default
+\default_output_format default
+\output_sync 0
+\bibtex_command default
+\index_command default
 \paperfontsize default
 \spacing single
+\use_hyperref false
 \papersize default
 \use_geometry false
-\use_amsmath 0
+\use_package amsmath 1
+\use_package amssymb 1
+\use_package cancel 1
+\use_package esint 1
+\use_package mathdots 1
+\use_package mathtools 1
+\use_package mhchem 1
+\use_package stackrel 1
+\use_package stmaryrd 1
+\use_package undertilde 1
 \cite_engine basic
+\cite_engine_type default
+\biblio_style plain
 \use_bibtopic false
+\use_indices false
 \paperorientation portrait
+\suppress_date false
+\justification true
+\use_refstyle 0
+\use_minted 0
+\index Index
+\shortcut idx
+\color #008000
+\end_index
 \secnumdepth 3
 \tocdepth 3
 \paragraph_separation indent
-\defskip medskip
-\quotes_language english
-\quotes_times 2
+\paragraph_indentation default
+\is_math_indent 0
+\math_numbering_side default
+\quotes_style english
+\dynamic_quotes 0
 \papercolumns 1
 \papersides 1
 \paperpagestyle default
 \tracking_changes false
-\output_changes true
+\output_changes false
+\html_math_output 0
+\html_css_as_file 0
+\html_be_strict false
 \end_header
 
 \begin_body
 
 \begin_layout Title
 
-
 \noun on
 noweb2lyx
 \end_layout
 
 \begin_layout Author
-
 Kayvan A.
  Sylvan <kayvan@sylvan.com>
 \end_layout
 
 \begin_layout Date
-
 May 6, 1999
 \end_layout
 
 \begin_layout Abstract
-
 This document describes and implements a perl script for importing noweb
- files into LyX
+ files into \SpecialChar LyX
+
 \end_layout
 
 \begin_layout Standard
-
-
-\begin_inset LatexCommand \tableofcontents{}
+\begin_inset CommandInset toc
+LatexCommand tableofcontents
 
 \end_inset
 
@@ -75,38 +121,37 @@ This document describes and implements a perl script for importing noweb
 \end_layout
 
 \begin_layout Standard
+\begin_inset Newpage newpage
+\end_inset
 
 
-\newpage
-
 \end_layout
 
-
 \begin_layout Section
-
 Introduction
 \end_layout
 
 \begin_layout Standard
-
-Since version 1.0.1, LyX now supports Literate Programming using 
+Since version 1.0.1, \SpecialChar LyX
+ now supports Literate Programming using 
 \noun on
 noweb
 \noun default
 .
- This addition to LyX made it very pleasant to write programs in the literate
+ This addition to \SpecialChar 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
 noweb
 \noun default
- code could be imported into LyX in some fashion.
+ code could be imported into \SpecialChar LyX
+ in some fashion.
  That's where this program comes in.
 \end_layout
 
 \begin_layout Standard
-
 The purpose of 
 \noun on
 noweb2lyx
@@ -115,59 +160,121 @@ noweb2lyx
 \noun on
 noweb
 \noun default
- file to LyX.
+ file to \SpecialChar LyX
+.
+\end_layout
+
+\begin_layout Standard
+\begin_inset Flex Chunk
+status open
+
+\begin_layout Plain Layout
+
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+noweb2lyx.in
 \end_layout
 
-\begin_layout Scrap
+\end_inset
 
-<<noweb2lyx.in>>=
-\newline
 #!@PERL@
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 # 
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 # Copyright (C) 1999 Kayvan A.
  Sylvan <kayvan@sylvan.com>
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 # You are free to use and modify this code under the terms of
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 # the GNU General Public Licence version 2 or later.
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 #
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 # Written with assistance from:
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 #   Edmar Wienskoski Jr.
  <edmar-w-jr@technologist.com>
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 #   Amir Karger <karger@post.harvard.edu>
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 #
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 # $Id: noweb2lyx.lyx,v 1.5 2005/07/18 09:42:27 jamatos Exp $
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 #
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 # NOTE: This file was automatically generated from noweb2lyx.lyx using noweb.
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 #
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 <<Setup variables from user supplied args>>
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 <<Subroutines>>
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 <<Convert noweb to LyX>>
-\newline
-@
 \end_layout
 
-\begin_layout Section
+\end_inset
+
+
+\end_layout
 
+\begin_layout Section
 The Noweb file defined
 \end_layout
 
 \begin_layout Standard
-
 A 
 \noun on
 noweb
@@ -177,27 +284,40 @@ noweb
 \end_layout
 
 \begin_layout LyX-Code
-
 @ Here is some documentation.
-\newline
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
 We can do arbitrary LaTeX code here.
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 [...
  blah blah blah ...]
 \end_layout
 
-\begin_layout Standard
+\end_inset
+
 
+\end_layout
+
+\begin_layout Standard
 Code chunks look like this:
 \end_layout
 
 \begin_layout LyX-Code
-
 <
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 {}
 \end_layout
 
@@ -207,33 +327,37 @@ status collapsed
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 {}
 \end_layout
 
 \end_inset
 
 >=
-\newline
+\begin_inset Newline newline
+\end_inset
+
 {...
  code for the chunk goes here ...}
-\newline
+\begin_inset Newline newline
+\end_inset
+
 @ 
 \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:
 \end_layout
 
 \begin_layout LyX-Code
-
 <
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 {}
 \end_layout
 
@@ -243,22 +367,26 @@ status collapsed
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 {}
 \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
 \end_layout
 
 \begin_layout Standard
-
 In the latter form, we are declaring to 
 \noun on
 noweb
@@ -267,15 +395,16 @@ noweb
 \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).
+When first tackling this problem, I spoke with members of the \SpecialChar LyX
+ team that
+ knew about the literate programming extensions and re\SpecialChar LyX
+ (the \SpecialChar LaTeX
+ importing code).
 \end_layout
 
 \begin_layout Standard
-
-One of the first ideas was to extend the reLyX code to understand the 
+One of the first ideas was to extend the re\SpecialChar LyX
+ code to understand the 
 \noun on
 noweb
 \noun default
@@ -284,68 +413,78 @@ noweb
 \begin_inset Foot
 status collapsed
 
-\begin_layout Standard
-
+\begin_layout Plain Layout
 Not the least of these problems is the fact that << is a quote in French.
 \end_layout
 
 \end_inset
 
 .
- On the other hand, it turns out that reLyX contains a very useful literal
+ On the other hand, it turns out that re\SpecialChar LyX
+ contains a very useful literal
  quoting mechanism.
  If the input file contains the construct
 \end_layout
 
 \begin_layout LyX-Code
 
-
 \backslash
-begin{reLyXskip}
-\newline
+begin{re\SpecialChar LyX
+skip}
+\begin_inset Newline newline
+\end_inset
+
 {...
- LaTeX stuff ...}
-\newline
+ \SpecialChar LaTeX
+ stuff ...}
+\begin_inset Newline newline
+\end_inset
+
 
 \backslash
-end{reLyXskip}
+end{re\SpecialChar LyX
+skip}
 \end_layout
 
 \begin_layout Standard
-
-then reLyX will copy the surrounded code to the output file verbatim.
+then re\SpecialChar LyX
+ 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
 
 \backslash
-begin{reLyXskip}
+begin{re\SpecialChar LyX
+skip}
 \family default
  and 
 \family typewriter
 
 \backslash
-end{reLyXskip}
+end{re\SpecialChar LyX
+skip}
 \family default
 .
 \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.
+Once re\SpecialChar LyX
+ is done with the input file, the problem is reduced to changing
+ the code chunks from \SpecialChar LyX
+'s \SpecialChar LaTeX
+ layout to the Chunk layout.
 \end_layout
 
 \begin_layout Standard
-
 There is one final constraint on 
 \noun on
 noweb2lyx
 \noun default
 .
  We want to be able to run it as a simple pre-processor and post-processor
- from within reLyX.
+ from within re\SpecialChar LyX
+.
  We can accomplish this by setting the flags 
 \family roman
 \series medium
@@ -359,7 +498,8 @@ noweb2lyx
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[pre_only]]
 \end_layout
 
@@ -373,8 +513,11 @@ status collapsed
 \emph default
 \bar default
 \noun default
 \color inherit
- and 
+and
+\color none
 \family roman
 \series medium
 \shape up
@@ -382,12 +525,12 @@ status collapsed
 \emph off
 \bar no
 \noun off
-\color none
 
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[post_only]]
 \end_layout
 
@@ -401,66 +544,129 @@ status collapsed
 \emph default
 \bar default
 \noun default
 \color inherit
- before we reach the main conversion code.
+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:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset Flex Chunk
+status open
+
+\begin_layout Plain Layout
+
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+Convert noweb to \SpecialChar LyX
+
+\end_layout
+
+\end_inset
 
-<<Convert noweb to LyX>>=
-\newline
 if (!$post_only) {
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   <<Transform noweb for reLyX>>
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 }
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 if ((!$pre_only) && (!$post_only)) {
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   <<Run reLyX on intermediate file>>
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 }
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 if (!$pre_only) {
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   <<Fix up LyX file>>
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 }
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 <<Clean up>>
-\newline
-@
 \end_layout
 
-\begin_layout Section
+\end_inset
+
 
-Making a file that reLyX can process
 \end_layout
 
-\begin_layout Standard
+\begin_layout Section
+Making a file that re\SpecialChar LyX
+ can process
+\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.
+ the intermediate file that re\SpecialChar LyX
+ can process, using the algorithm that we
+ just outlined.
  This algorithm is outlined in the code that follows:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset Flex Chunk
+status open
+
+\begin_layout Plain Layout
+
+\end_layout
+
+\begin_layout Plain Layout
 
 <<Transform noweb for reLyX>>=
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 <<Setup INPUT and OUTPUT>>
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 inputline: while(<INPUT>)
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 {
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   if (/^
 \backslash
 s*
@@ -471,16 +677,28 @@ s*
 \backslash
 >
 \backslash
->=/) { # Beginning of a noweb scrap
-\newline
+>=/) { # Beginning of a noweb chunk
+\end_layout
+
+\begin_layout Plain Layout
+
     <<Read in and output the noweb code chunk>>
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   } elsif (/^@
 \backslash
 s+(.*)/) { # Beginning of a documentation chunk
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
     print OUTPUT $1; # We do not need the ``@'' part
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   } elsif (/
 \backslash
 [
@@ -490,33 +708,61 @@ s+(.*)/) { # Beginning of a documentation chunk
 ]
 \backslash
 ]/) { # noweb quoted code
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
     <<Perform special input quoting of [[var]]>>
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   } else {
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
     print OUTPUT; # Just let the line pass through
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   }
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 }
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 <<Close INPUT and OUTPUT>>
-\newline
-@
 \end_layout
 
-\begin_layout Standard
+\end_inset
+
+
+\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 ``[[...]]''
+ This avoids some problems with re\SpecialChar LyX
+ confusing lists composed of ``[[...]]''
  constructs.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
 
 <<Perform special input quoting of [[var]]>>=
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 s/
 \backslash
 [
@@ -524,15 +770,25 @@ s/
 [.+?
 \backslash
 ]{2,}/{$&}/g;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 print OUTPUT;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 @
 \end_layout
 
-\begin_layout Standard
+\end_inset
 
-While reading in the 
+
+\end_layout
+
+\begin_layout Standard
+While reading in the 
 \family roman
 \series medium
 \shape up
@@ -545,7 +801,8 @@ While reading in the
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[INPUT]]
 \end_layout
 
@@ -559,34 +816,55 @@ status collapsed
 \emph default
 \bar default
 \noun default
 \color inherit
- file, once we have identified a 
+file, once we have identified a 
 \noun on
 noweb
 \noun default
- code chunk, we transform it into a form that is usable by reLyX.
+ code chunk, we transform it into a form that is usable by re\SpecialChar LyX
+.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset Flex Chunk
+status open
+
+\begin_layout Plain Layout
 
-<<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
-@
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+Read in and output the noweb code chunk
 \end_layout
 
-\begin_layout Subsection
+\end_inset
 
+<<Save the beginning of the chunk to savedchunk>>
+\end_layout
+
+\begin_layout Plain Layout
+
+<<Concatenate the rest of the chunk>>
+\end_layout
+
+\begin_layout Plain Layout
+
+<<print out the chunk in a reLyXskip block>>
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
 File input and output for the pre-processing step
 \end_layout
 
 \begin_layout Standard
-
 In 
 \noun on
 noweb2lyx
@@ -604,7 +882,8 @@ noweb2lyx
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[INPUT]]
 \end_layout
 
@@ -618,8 +897,11 @@ status collapsed
 \emph default
 \bar default
 \noun default
 \color inherit
- and 
+and
+\color none
 \family roman
 \series medium
 \shape up
@@ -627,12 +909,12 @@ status collapsed
 \emph off
 \bar no
 \noun off
-\color none
 
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[OUTPUT]]
 \end_layout
 
@@ -646,35 +928,66 @@ status collapsed
 \emph default
 \bar default
 \noun default
 \color inherit
- to read and write files.
+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.
+ to a file that will be later transformed by re\SpecialChar LyX
+.
  If we are being called only to pre-process the input file, then there is
  no need to create a temporary file.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset Flex Chunk
+status open
+
+\begin_layout Plain Layout
+
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+Setup INPUT and OUTPUT
+\end_layout
+
+\end_inset
 
-<<Setup INPUT and OUTPUT>>=
-\newline
 if ($pre_only) {
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   &setup_files($input_file, $output_file);
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 } else {
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   $relyx_file = "temp$$";
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   &setup_files($input_file, $relyx_file);
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 }
-\newline
-@
 \end_layout
 
-\begin_layout Standard
+\end_inset
 
+
+\end_layout
+
+\begin_layout Standard
 This code uses a small perl subroutine, 
 \family roman
 \series medium
@@ -688,7 +1001,8 @@ This code uses a small perl subroutine,
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[setup_files]]
 \end_layout
 
@@ -706,104 +1020,197 @@ status collapsed
 , which we define below:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
 
 <<Subroutines>>=
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 sub setup_files {
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   my($in, $out) = @_;
-\newline
-  open(INPUT, "<$in") || die "Can not read $in: $!
+\end_layout
+
+\begin_layout Plain Layout
+
+  open(INPUT, "<$in") || die "Cannot read $in: $!
 \backslash
 n";
-\newline
-  open(OUTPUT, ">$out") || die "Can not write $out: $!
+\end_layout
+
+\begin_layout Plain Layout
+
+  open(OUTPUT, ">$out") || die "Cannot write $out: $!
 \backslash
 n";
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 }
-\newline
-@ %def setup_files   
 \end_layout
 
-\begin_layout Subsection
+\begin_layout Plain Layout
+
+@ %def setup_files
+\end_layout
+
+\end_inset
+
+
+\end_layout
 
+\begin_layout Subsection
 Reading in the 
 \noun on
 noweb
 \noun default
- scrap
+ 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 Standard
+\begin_inset Flex Chunk
+status open
 
-After we see the beginning of the scrap, we need to read in and save the
- rest of the scrap for output.
+\begin_layout Plain Layout
+
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+Save the beginning of the chunk to savedchunk
+\end_layout
+
+\end_inset
+
+$savedchunk = $_;
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
-<<Save the beginning of the scrap to savedScrap>>=
-\newline
-$savedScrap = $_;
-\newline
 $endLine = "";
-\newline
-@
 \end_layout
 
-\begin_layout Scrap
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
 
-<<Concatenate the rest of the scrap>>=
-\newline
-scrapline: while (<INPUT>) {
-\newline
-  last scrapline if /^@
+<<Concatenate the rest of the chunk>>=
+\end_layout
+
+\begin_layout Plain Layout
+
+chunkline: while (<INPUT>) {
+\end_layout
+
+\begin_layout Plain Layout
+
+ last chunkline if /^@
 \backslash
 s+/;
-\newline
-  $savedScrap .= $_;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
+ $savedchunk .= $_;
+\end_layout
+
+\begin_layout Plain Layout
+
 };
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 switch: {
-\newline
-  if (/^@
+\end_layout
+
+\begin_layout Plain Layout
+
+ if (/^@
 \backslash
-s+$/) {$savedScrap .= $_; last switch; }
-\newline
-  if (/^@
+s+$/) {$savedchunk .= $_; last switch; }
+\end_layout
+
+\begin_layout Plain Layout
+
+ if (/^@
 \backslash
-s+%def.*$/) {$savedScrap .= $_; last switch; }
-\newline
-  if (/^@
+s+%def.*$/) {$savedchunk .= $_; last switch; }
+\end_layout
+
+\begin_layout Plain Layout
+
+ if (/^@
 \backslash
-s+(.*)$/) {$savedScrap .= "@
+s+(.*)$/) {$savedchunk .= "@
 \backslash
 n"; $endLine = "$1
 \backslash
 n"; }
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 }
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 @
 \end_layout
 
+\end_inset
+
+
+\end_layout
+
 \begin_layout Subsection
+Printing out the chunk
+\end_layout
 
-Printing out the scrap
+\begin_layout Standard
+The final piece of the first pass of the conversion is done by this code.
 \end_layout
 
 \begin_layout Standard
+\begin_inset Flex Chunk
+status open
 
-The final piece of the first pass of the conversion is done by this code.
+\begin_layout Plain Layout
+
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+print out the chunk in a re\SpecialChar LyX
+skip block
 \end_layout
 
-\begin_layout Scrap
+\end_inset
 
-<<print out the scrap in a reLyXskip block>>=
-\newline
 print OUTPUT "
 \backslash
 
@@ -811,9 +1218,15 @@ print OUTPUT "
 begin{reLyXskip}
 \backslash
 n";
-\newline
-print OUTPUT $savedScrap;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
+print OUTPUT $savedchunk;
+\end_layout
+
+\begin_layout Plain Layout
+
 print OUTPUT "
 \backslash
 
@@ -823,14 +1236,19 @@ end{reLyXskip}
 n
 \backslash
 n";
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 print OUTPUT "$endLine";
-\newline
-@
 \end_layout
 
-\begin_layout Standard
+\end_inset
+
 
+\end_layout
+
+\begin_layout Standard
 Finally, we need to close the 
 \family roman
 \series medium
@@ -844,7 +1262,8 @@ Finally, we need to close the
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[INPUT]]
 \end_layout
 
@@ -858,8 +1277,11 @@ status collapsed
 \emph default
 \bar default
 \noun default
 \color inherit
- and 
+and
+\color none
 \family roman
 \series medium
 \shape up
@@ -867,12 +1289,12 @@ status collapsed
 \emph off
 \bar no
 \noun off
-\color none
 
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[OUTPUT]]
 \end_layout
 
@@ -886,29 +1308,48 @@ status collapsed
 \emph default
 \bar default
 \noun default
 \color inherit
- files.
+files.
+\end_layout
+
+\begin_layout Standard
+\begin_inset Flex Chunk
+status open
+
+\begin_layout Plain Layout
+
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+Close INPUT and OUTPUT
 \end_layout
 
-\begin_layout Scrap
+\end_inset
 
-<<Close INPUT and OUTPUT>>=
-\newline
 close(INPUT);
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 close(OUTPUT);
-\newline
-@
+\end_layout
+
+\end_inset
+
+
 \end_layout
 
 \begin_layout Section
+Running re\SpecialChar LyX
 
-Running reLyX
 \end_layout
 
 \begin_layout Standard
-
-In this section, we describe and implement the code that runs reLyX on the
+In this section, we describe and implement the code that runs re\SpecialChar LyX
+ on the
  intermediate file 
 \family roman
 \series medium
@@ -922,7 +1363,8 @@ In this section, we describe and implement the code that runs reLyX on the
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[relyx_file]]
 \end_layout
 
@@ -942,30 +1384,47 @@ status collapsed
 \end_layout
 
 \begin_layout Subsection
-
 Selecting the document class
 \end_layout
 
 \begin_layout Standard
-
-In order to run reLyX, we need to know the article class of the input document
+In order to run re\SpecialChar LyX
+, 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.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset Flex Chunk
+status open
+
+\begin_layout Plain Layout
+
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+Run re\SpecialChar LyX
+ on intermediate file
+\end_layout
+
+\end_inset
 
-<<Run reLyX on intermediate file>>=
-\newline
 <<Parse for document class>>
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 <<Run reLyX with document class>>
-\newline
-@
 \end_layout
 
-\begin_layout Standard
+\end_inset
+
+
+\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 
@@ -976,13 +1435,14 @@ noweb2lyx
 \emph on
 noweb2lyx.nw
 \emph default
- file that is generated by LyX
+ file that is generated by \SpecialChar LyX
+
 \begin_inset Foot
 status collapsed
 
-\begin_layout Standard
-
-reLyX searches for 
+\begin_layout Plain Layout
+re\SpecialChar LyX
+ searches for 
 \backslash
 
 \backslash
@@ -999,7 +1459,8 @@ doc
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 {}
 \end_layout
 
@@ -1027,7 +1488,8 @@ ument
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 {}
 \end_layout
 
@@ -1052,76 +1514,140 @@ class and gets confused, so we have to obfuscate it slightly.
 \noun on
 noweb2lyx
 \noun default
- on itself and a produce a quite reasonable LyX file.
+ on itself and a produce a quite reasonable \SpecialChar LyX
+ file.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset Flex Chunk
+status open
 
-<<Parse for document class>>=
-\newline
-open(INPUT, "<$relyx_file") ||
-\newline
-  die "Can not read $relyx_file: $!
-\backslash
-n";
-\newline
-$class = "article"; # default if none found
-\newline
-parse: while(<INPUT>) {
-\newline
-  if (/
-\backslash
+\begin_layout Plain Layout
 
-\backslash
-docu[m]entclass{(.*)}/) {
-\newline
-    $class = $1;
-\newline
-    last parse;
-\newline
-  }
-\newline
-}
-\newline
-close(INPUT);
-\newline
-@
-\end_layout
+\begin_inset Argument 1
+status open
 
-\begin_layout Subsection
+\begin_layout Plain Layout
 
-Running reLyX with the corresponding literate document layout
+Parse for document class
 \end_layout
 
-\begin_layout Standard
+\end_inset
+
+open(INPUT, "<$relyx_file") ||
+\end_layout
+
+\begin_layout Plain Layout
+
+  die "Cannot read $relyx_file: $!
+\backslash
+n";
+\end_layout
+
+\begin_layout Plain Layout
+
+$class = "article"; # default if none found
+\end_layout
+
+\begin_layout Plain Layout
+
+parse: while(<INPUT>) {
+\end_layout
+
+\begin_layout Plain Layout
+
+  if (/
+\backslash
+
+\backslash
+docu[m]entclass{(.*)}/) {
+\end_layout
+
+\begin_layout Plain Layout
+
+    $class = $1;
+\end_layout
+
+\begin_layout Plain Layout
+
+    last parse;
+\end_layout
+
+\begin_layout Plain Layout
+
+  }
+\end_layout
+
+\begin_layout Plain Layout
+
+}
+\end_layout
+
+\begin_layout Plain Layout
+
+close(INPUT);
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Running re\SpecialChar LyX
+ with the corresponding literate document layout
+\end_layout
 
+\begin_layout Standard
 Now that we know what the document class ought to be, we do:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
 
 <<Run reLyX with document class>>= 
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 $doc_class = "literate-" .
  $class;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 die "reLyX returned non-zero: $!
 \backslash
 n"
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   if (system("reLyX -c $doc_class $relyx_file"));
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 @
 \end_layout
 
-\begin_layout Standard
+\end_inset
+
+
+\end_layout
 
-reLyX performs the main bulk of the translation work.
+\begin_layout Standard
+re\SpecialChar LyX
+ performs the main bulk of the translation work.
  Note that if the ``literate-
 \emph on
 class
 \emph default
-'' document layout is not found, then reLyX will fail with an error.
+'' document layout is not found, then re\SpecialChar LyX
+ will fail with an error.
  In that case, you may need to modify your 
 \noun on
 noweb
@@ -1130,42 +1656,78 @@ noweb
 \end_layout
 
 \begin_layout Section
+Fixing the re\SpecialChar LyX
+ output
+\end_layout
 
-Fixing the reLyX output
+\begin_layout Standard
+We need to perform some post-processing of what re\SpecialChar LyX
+ produces in order to
+ have the best output for our literate document.
+ The outline of the post-processing steps are:
 \end_layout
 
 \begin_layout Standard
+\begin_inset Flex Chunk
+status open
 
-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:
+\begin_layout Plain Layout
+
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+Fix up \SpecialChar LyX
+ file
 \end_layout
 
-\begin_layout Scrap
+\end_inset
 
-<<Fix up LyX file>>=
-\newline
 <<Setup INPUT and OUTPUT for the final output>>
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 line: while(<INPUT>)
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 {
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   <<Fix code chunks in latex layout>>
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   <<Fix [[var]] noweb construct>>
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   print OUTPUT; # default
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 } 
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 <<Close INPUT and OUTPUT>>
-\newline
-@
 \end_layout
 
-\begin_layout Standard
+\end_inset
+
+
+\end_layout
 
+\begin_layout Standard
 Note that in the perl code that is contained in the 
 \family roman
 \series medium
@@ -1179,7 +1741,8 @@ Note that in the perl code that is contained in the
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[while(<INPUT>)]]
 \end_layout
 
@@ -1193,8 +1756,11 @@ status collapsed
 \emph default
 \bar default
 \noun default
 \color inherit
- loop above, the perl construct 
+loop above, the perl construct
+\color none
 \family roman
 \series medium
 \shape up
@@ -1202,12 +1768,12 @@ status collapsed
 \emph off
 \bar no
 \noun off
-\color none
 
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[next line]]
 \end_layout
 
@@ -1221,19 +1787,19 @@ status collapsed
 \emph default
 \bar default
 \noun default
 \color inherit
- is sufficient to restart the loop.
+is sufficient to restart the loop.
  We can use this construct to do some relatively complex parsing of the
- reLyX generated file.
+ re\SpecialChar LyX
+ generated file.
 \end_layout
 
 \begin_layout Subsection
-
 File input and output for the post-processing
 \end_layout
 
 \begin_layout Standard
-
 Setting up the 
 \family roman
 \series medium
@@ -1247,7 +1813,8 @@ Setting up the
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[INPUT]]
 \end_layout
 
@@ -1261,8 +1828,11 @@ status collapsed
 \emph default
 \bar default
 \noun default
 \color inherit
- and 
+and
+\color none
 \family roman
 \series medium
 \shape up
@@ -1270,12 +1840,12 @@ status collapsed
 \emph off
 \bar no
 \noun off
-\color none
 
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[OUTPUT]]
 \end_layout
 
@@ -1289,145 +1859,276 @@ status collapsed
 \emph default
 \bar default
 \noun default
 \color inherit
- is taken care of by this code:
+is taken care of by this code:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset Flex Chunk
+status open
+
+\begin_layout Plain Layout
+
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+Setup INPUT and OUTPUT for the final output
+\end_layout
+
+\end_inset
 
-<<Setup INPUT and OUTPUT for the final output>>=
-\newline
 if ($post_only) {
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   &setup_files("$input_file", "$output_file");
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 } else {
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   &setup_files("$relyx_file.lyx", "$output_file");
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 }
-\newline
-@
+\end_layout
+
+\end_inset
+
+
 \end_layout
 
 \begin_layout Subsection
+Making sure the code chunks are in the Chunk layout
+\end_layout
 
-Making sure the code chunks are in the Scrap layout
+\begin_layout Standard
+Now, as we outlined before, the final step is transforming the code-chunks
+ which have been put into a \SpecialChar LaTeX
+ layout by \SpecialChar LyX
+ into the Chunk layout.
 \end_layout
 
 \begin_layout Standard
+\begin_inset Flex Chunk
+status open
 
-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.
+\begin_layout Plain Layout
+
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+Fix code chunks in latex layout
 \end_layout
 
-\begin_layout Scrap
+\end_inset
 
-<<Fix code chunks in latex layout>>=
-\newline
 if (/
 \backslash
 
 \backslash
 latex latex/) { # Beginning of some latex code
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   if (($line = <INPUT>) =~ /^
 \backslash
-s*<</) { # code scrap
-\newline
-    <<Transform this chunk into layout scrap>>
-\newline
+s*<</) { # code chunk
+\end_layout
+
+\begin_layout Plain Layout
+
+    <<Transform this chunk into layout chunk>>
+\end_layout
+
+\begin_layout Plain Layout
+
   } else {
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
     # print the 
 \backslash
 latex latex line + next line
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
     print OUTPUT "$_$line";
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   }
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   next line;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 }
-\newline
-@
 \end_layout
 
-\begin_layout Standard
+\end_inset
+
+
+\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:
+ the code chunk and output a chunk layout for it:
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
+
+<<Transform this chunk into layout chunk>>=
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
+
+\end_layout
 
-<<Transform this chunk into layout scrap>>=
-\newline
-$savedScrap = "
+\begin_layout Plain Layout
+
+$savedchunk = "
 \backslash
 
 \backslash
-layout Scrap
+layout Chunk
 \backslash
 n
 \backslash
 n$line";
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 codeline: while (<INPUT>) {
-\newline
-  $savedScrap .= $_;
-\newline
-  last codeline if /^@
+\end_layout
+
+\begin_layout Plain Layout
+
+ $savedchunk .= $_;
+\end_layout
+
+\begin_layout Plain Layout
+
+ last codeline if /^@
 \backslash
 s+/;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 };
-\newline
-print OUTPUT $savedScrap;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
+print OUTPUT $savedchunk;
+\end_layout
+
+\begin_layout Plain Layout
+
 <<Slurp up to the end of the latex layout>>
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 @
 \end_layout
 
-\begin_layout Standard
+\end_inset
+
+
+\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:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset Flex Chunk
+status open
+
+\begin_layout Plain Layout
+
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+Slurp up to the end of the latex layout
+\end_layout
+
+\end_inset
 
-<<Slurp up to the end of the latex layout>>=
-\newline
 slurp: while (<INPUT>) {
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   last slurp if /
 \backslash
 
 \backslash
 latex /;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   next slurp if /
 \backslash
 
 \backslash
 newline/;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   next slurp if /^
 \backslash
 s*$/;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   warn "confused by line: $_";
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 }
-\newline
-@
 \end_layout
 
-\begin_layout Subsection
+\end_inset
+
+
+\end_layout
 
+\begin_layout Subsection
 Taking care of the 
 \noun on
 noweb
@@ -1441,7 +2142,6 @@ noweb
 
 \begin_layout Standard
 
-
 \noun on
 noweb
 \noun default
@@ -1451,20 +2151,35 @@ noweb
 \noun on
 noweb
 \noun default
- syntax means putting the ``[[quoted-code]]'' in a LaTeX layout in the LyX
+ syntax means putting the ``[[quoted-code]]'' in a \SpecialChar LaTeX
+ layout in the \SpecialChar LyX
  file.
- Otherwise, LyX will backslash-quote the brackets, creating ugly output.
+ Otherwise, \SpecialChar LyX
+ will backslash-quote the brackets, creating ugly output.
  The quoted-code is transformed by 
 \noun on
 noweb
 \noun default
- when it generates the final LaTeX code.
+ when it generates the final \SpecialChar LaTeX
+ code.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset Flex Chunk
+status open
+
+\begin_layout Plain Layout
+
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+Fix [[var]] noweb construct
+\end_layout
+
+\end_inset
 
-<<Fix [[var]] noweb construct>>=
-\newline
 if (/
 \backslash
 [
@@ -1474,7 +2189,10 @@ if (/
 ]
 \backslash
 ]/) { # special code for [[var]]
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   s/
 \backslash
 [
 latex default
 \backslash
 n/g;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   print OUTPUT;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   next line;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 }
-\newline
-@
 \end_layout
 
-\begin_layout Section
+\end_inset
+
+
+\end_layout
 
+\begin_layout Section
 Cleaning up intermediate files
 \end_layout
 
 \begin_layout Standard
-
 The cleanup code is very simple:
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset Flex Chunk
+status open
+
+\begin_layout Plain Layout
+
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+Clean up
+\end_layout
+
+\end_inset
 
-<<Clean up>>=
-\newline
 system("rm -f $relyx_file*") unless ($post_only || $pre_only);
-\newline
-@
 \end_layout
 
-\begin_layout Section
+\end_inset
 
+
+\end_layout
+
+\begin_layout Section
 User supplied arguments
 \end_layout
 
 \begin_layout Standard
-
 The 
 \noun on
 noweb2lyx
 \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
+ It is also set up to be used internally by re\SpecialChar LyX
+ to pre-process or postprocess
  files in the import pipeline.
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Plain Layout
 
 <<Setup variables from user supplied args>>=
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 &usage() if ($#ARGV < 1); # zero or one argument 
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 if ($ARGV[0] eq "-pre") {
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   &usage unless ($#ARGV == 2);
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   $input_file = $ARGV[1]; $output_file = $ARGV[2]; $pre_only = 1;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 } elsif ($ARGV[0] eq "-post") {
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   &usage unless ($#ARGV == 2);
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   $input_file = $ARGV[1]; $output_file = $ARGV[2]; $post_only = 1;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 } else {
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   &usage unless ($#ARGV == 1);
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   $input_file = $ARGV[0]; $output_file = $ARGV[1];
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   $pre_only = 0; $post_only = 0;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 }
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 @ %def input_file output_file pre_only post_only
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Plain Layout
 
 <<Subroutines>>=
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 sub usage() {
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   print "Usage: noweb2lyx [-pre | -post] input-file output-file
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
+\end_layout
+
+\begin_layout Plain Layout
 
-\newline
 If -pre is specified, only pre-processes the input-file for reLyX.
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 Similarly, in the case of -post, post-processes reLyX output.
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 In case of bugs, Email Kayvan Sylvan <kayvan
 \backslash
 @sylvan.com>.
 \backslash
 n";
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
   exit;
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 }
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 @ %def usage
 \end_layout
 
-\begin_layout Section
+\end_inset
+
 
+\end_layout
+
+\begin_layout Section
 Generating the 
 \noun on
 noweb2lyx
@@ -1611,14 +2426,14 @@ noweb2lyx
 \end_layout
 
 \begin_layout Standard
-
-The noweb2lyx script can be tangled from LyX if you set 
+The noweb2lyx script can be tangled from \SpecialChar LyX
+ if you set 
 \family typewriter
 
 \backslash
 build_command
 \family default
- to call a generic script that always extracts a scrap named 
+ to call a generic script that always extracts a chunk named 
 \family typewriter
 build-script
 \family default
@@ -1627,43 +2442,65 @@ build-script
 \end_layout
 
 \begin_layout LyX-Code
-
 #!/bin/sh
-\newline
-notangle -Rbuild-script $1 | sh
+\begin_inset Newline newline
+\end_inset
+
+notangle -Rbuild-script $1 | env NOWEB_SOURCE=$1 NOWEB_OUTPUT_DIR=$2 sh
 \end_layout
 
-\begin_layout Scrap
+\begin_layout Standard
+\begin_inset Flex Chunk
+status open
+
+\begin_layout Plain Layout
+
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+
+build-script
+\end_layout
+
+\end_inset
 
-<<build-script>>=
-\newline
 PREFIX=/usr
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 notangle -Rnoweb2lyx.in noweb2lyx.nw > noweb2lyx.in
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 sed -e "s=@PERL@=$PREFIX/bin/perl=" noweb2lyx.in > noweb2lyx
-\newline
+\end_layout
+
+\begin_layout Plain Layout
+
 chmod +x noweb2lyx
-\newline
-@
 \end_layout
 
+\end_inset
 
-\begin_layout Standard
 
+\end_layout
+
+\begin_layout Standard
+\begin_inset Newpage newpage
+\end_inset
 
-\newpage
 
 \end_layout
 
 \begin_layout Section*
-
 Macros
 \end_layout
 
 \begin_layout Standard
 
-
 \family roman
 \series medium
 \shape up
@@ -1672,11 +2509,11 @@ Macros
 \bar no
 \noun off
 \color none
-
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 
 \backslash
 nowebchunks
@@ -1688,13 +2525,11 @@ nowebchunks
 \end_layout
 
 \begin_layout Section*
-
 Identifiers
 \end_layout
 
 \begin_layout Standard
 
-
 \family roman
 \series medium
 \shape up
@@ -1703,11 +2538,11 @@ Identifiers
 \bar no
 \noun off
 \color none
-
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 
 \backslash
 nowebindex