]> git.lyx.org Git - lyx.git/blobdiff - lib/examples/noweb2lyx.lyx
Restore change from OpenOffice to LibreOffice.
[lyx.git] / lib / examples / noweb2lyx.lyx
index e9969882287775093de9b6854599bc9979f22010..3bba1fc09efc4fe3913f1ddeba7eee942eb669c7 100644 (file)
@@ -1,5 +1,5 @@
-#LyX 1.4.0cvs created this file. For more info see http://www.lyx.org/
-\lyxformat 243
+#LyX 2.0 created this file. For more info see http://www.lyx.org/
+\lyxformat 413
 \begin_document
 \begin_header
 \textclass literate-article
 \def\nwendcode{\endtrivlist \endgroup}
 \let\nwdocspar=\smallbreak
 \end_preamble
+\use_default_options false
+\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_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
+\use_hyperref false
 \papersize default
 \use_geometry false
 \use_amsmath 0
+\use_esint 0
+\use_mhchem 1
+\use_mathdots 1
 \cite_engine basic
 \use_bibtopic false
+\use_indices false
 \paperorientation portrait
+\suppress_date false
+\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 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
 \end_layout
 
 \begin_layout Standard
-
-
-\begin_inset LatexCommand \tableofcontents{}
+\begin_inset CommandInset toc
+LatexCommand tableofcontents
 
 \end_inset
 
@@ -75,20 +100,17 @@ 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 
 \noun on
 noweb
@@ -106,7 +128,6 @@ noweb
 \end_layout
 
 \begin_layout Standard
-
 The purpose of 
 \noun on
 noweb2lyx
@@ -119,55 +140,88 @@ noweb
 \end_layout
 
 \begin_layout Scrap
-
 <<noweb2lyx.in>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 #!@PERL@
-\newline
+\end_layout
+
+\begin_layout Scrap
 # 
-\newline
+\end_layout
+
+\begin_layout Scrap
 # Copyright (C) 1999 Kayvan A.
  Sylvan <kayvan@sylvan.com>
-\newline
+\end_layout
+
+\begin_layout Scrap
 # You are free to use and modify this code under the terms of
-\newline
+\end_layout
+
+\begin_layout Scrap
 # the GNU General Public Licence version 2 or later.
-\newline
+\end_layout
+
+\begin_layout Scrap
 #
-\newline
+\end_layout
+
+\begin_layout Scrap
 # Written with assistance from:
-\newline
+\end_layout
+
+\begin_layout Scrap
 #   Edmar Wienskoski Jr.
  <edmar-w-jr@technologist.com>
-\newline
+\end_layout
+
+\begin_layout Scrap
 #   Amir Karger <karger@post.harvard.edu>
-\newline
+\end_layout
+
+\begin_layout Scrap
 #
-\newline
+\end_layout
+
+\begin_layout Scrap
 # $Id: noweb2lyx.lyx,v 1.5 2005/07/18 09:42:27 jamatos Exp $
-\newline
+\end_layout
+
+\begin_layout Scrap
 #
-\newline
+\end_layout
+
+\begin_layout Scrap
 # NOTE: This file was automatically generated from noweb2lyx.lyx using noweb.
-\newline
+\end_layout
+
+\begin_layout Scrap
 #
-\newline
+\end_layout
+
+\begin_layout Scrap
 <<Setup variables from user supplied args>>
-\newline
+\end_layout
+
+\begin_layout Scrap
 <<Subroutines>>
-\newline
+\end_layout
+
+\begin_layout Scrap
 <<Convert noweb to LyX>>
-\newline
+\end_layout
+
+\begin_layout Scrap
 @
 \end_layout
 
 \begin_layout Section
-
 The Noweb file defined
 \end_layout
 
 \begin_layout Standard
-
 A 
 \noun on
 noweb
@@ -177,27 +231,33 @@ noweb
 \end_layout
 
 \begin_layout LyX-Code
-
 @ Here is some documentation.
-\newline
+\end_layout
+
+\begin_layout Scrap
+
+\end_layout
+
+\begin_layout Scrap
 We can do arbitrary LaTeX code here.
-\newline
+\begin_inset Newline newline
+\end_inset
+
 [...
  blah blah blah ...]
 \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 +267,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 +307,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,14 +335,12 @@ 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).
 \end_layout
 
 \begin_layout Standard
-
 One of the first ideas was to extend the reLyX code to understand the 
 \noun on
 noweb
@@ -284,8 +350,7 @@ 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
 
@@ -299,20 +364,22 @@ Not the least of these problems is the fact that << is a quote in French.
 
 \begin_layout LyX-Code
 
-
 \backslash
 begin{reLyXskip}
-\newline
+\begin_inset Newline newline
+\end_inset
+
 {...
  LaTeX stuff ...}
-\newline
+\begin_inset Newline newline
+\end_inset
+
 
 \backslash
 end{reLyXskip}
 \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
@@ -332,13 +399,11 @@ end{reLyXskip}
 \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.
 \end_layout
 
 \begin_layout Standard
-
 There is one final constraint on 
 \noun on
 noweb2lyx
@@ -359,7 +424,8 @@ noweb2lyx
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[pre_only]]
 \end_layout
 
@@ -373,8 +439,11 @@ status collapsed
 \emph default
 \bar default
 \noun default
 \color inherit
- and 
+and
+\color none
 \family roman
 \series medium
 \shape up
@@ -382,12 +451,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,50 +470,69 @@ 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
-
 <<Convert noweb to LyX>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 if (!$post_only) {
-\newline
+\end_layout
+
+\begin_layout Scrap
   <<Transform noweb for reLyX>>
-\newline
+\end_layout
+
+\begin_layout Scrap
 }
-\newline
+\end_layout
+
+\begin_layout Scrap
 if ((!$pre_only) && (!$post_only)) {
-\newline
+\end_layout
+
+\begin_layout Scrap
   <<Run reLyX on intermediate file>>
-\newline
+\end_layout
+
+\begin_layout Scrap
 }
-\newline
+\end_layout
+
+\begin_layout Scrap
 if (!$pre_only) {
-\newline
+\end_layout
+
+\begin_layout Scrap
   <<Fix up LyX file>>
-\newline
+\end_layout
+
+\begin_layout Scrap
 }
-\newline
+\end_layout
+
+\begin_layout Scrap
 <<Clean up>>
-\newline
+\end_layout
+
+\begin_layout Scrap
 @
 \end_layout
 
 \begin_layout Section
-
 Making a file that reLyX 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.
@@ -453,14 +541,25 @@ In this section, we present the code that performs the task of creating
 
 \begin_layout Scrap
 
+\end_layout
+
+\begin_layout Scrap
 <<Transform noweb for reLyX>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 <<Setup INPUT and OUTPUT>>
-\newline
+\end_layout
+
+\begin_layout Scrap
 inputline: while(<INPUT>)
-\newline
+\end_layout
+
+\begin_layout Scrap
 {
-\newline
+\end_layout
+
+\begin_layout Scrap
   if (/^
 \backslash
 s*
@@ -472,15 +571,23 @@ s*
 >
 \backslash
 >=/) { # Beginning of a noweb scrap
-\newline
+\end_layout
+
+\begin_layout Scrap
     <<Read in and output the noweb code chunk>>
-\newline
+\end_layout
+
+\begin_layout Scrap
   } elsif (/^@
 \backslash
 s+(.*)/) { # Beginning of a documentation chunk
-\newline
+\end_layout
+
+\begin_layout Scrap
     print OUTPUT $1; # We do not need the ``@'' part
-\newline
+\end_layout
+
+\begin_layout Scrap
   } elsif (/
 \backslash
 [
@@ -490,33 +597,47 @@ s+(.*)/) { # Beginning of a documentation chunk
 ]
 \backslash
 ]/) { # noweb quoted code
-\newline
+\end_layout
+
+\begin_layout Scrap
     <<Perform special input quoting of [[var]]>>
-\newline
+\end_layout
+
+\begin_layout Scrap
   } else {
-\newline
+\end_layout
+
+\begin_layout Scrap
     print OUTPUT; # Just let the line pass through
-\newline
+\end_layout
+
+\begin_layout Scrap
   }
-\newline
+\end_layout
+
+\begin_layout Scrap
 }
-\newline
+\end_layout
+
+\begin_layout Scrap
 <<Close INPUT and OUTPUT>>
-\newline
+\end_layout
+
+\begin_layout Scrap
 @
 \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.
 \end_layout
 
 \begin_layout Scrap
-
 <<Perform special input quoting of [[var]]>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 s/
 \backslash
 [
@@ -524,14 +645,17 @@ s/
 [.+?
 \backslash
 ]{2,}/{$&}/g;
-\newline
+\begin_inset Newline newline
+\end_inset
+
 print OUTPUT;
-\newline
+\begin_inset Newline newline
+\end_inset
+
 @
 \end_layout
 
 \begin_layout Standard
-
 While reading in the 
 \family roman
 \series medium
@@ -545,7 +669,8 @@ While reading in the
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[INPUT]]
 \end_layout
 
@@ -559,8 +684,9 @@ 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
@@ -568,25 +694,30 @@ noweb
 \end_layout
 
 \begin_layout Scrap
-
 <<Read in and output the noweb code chunk>>= 
-\newline
+\end_layout
+
+\begin_layout Scrap
 <<Save the beginning of the scrap to savedScrap>>
-\newline
+\end_layout
+
+\begin_layout Scrap
 <<Concatenate the rest of the scrap>>
-\newline
+\end_layout
+
+\begin_layout Scrap
 <<print out the scrap in a reLyXskip block>>
-\newline
+\end_layout
+
+\begin_layout Scrap
 @
 \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 +735,8 @@ noweb2lyx
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[INPUT]]
 \end_layout
 
@@ -618,8 +750,11 @@ status collapsed
 \emph default
 \bar default
 \noun default
 \color inherit
- and 
+and
+\color none
 \family roman
 \series medium
 \shape up
@@ -627,12 +762,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,8 +781,9 @@ 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.
  If we are being called only to pre-process the input file, then there is
@@ -655,26 +791,38 @@ status collapsed
 \end_layout
 
 \begin_layout Scrap
-
 <<Setup INPUT and OUTPUT>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 if ($pre_only) {
-\newline
-  &setup_files($input_file, $output_file);
-\newline
-} else {
-\newline
-  $relyx_file = "temp$$";
-\newline
-  &setup_files($input_file, $relyx_file);
-\newline
-}
-\newline
-@
 \end_layout
 
-\begin_layout Standard
+\begin_layout Scrap
+  &setup_files($input_file, $output_file);
+\end_layout
+
+\begin_layout Scrap
+} else {
+\end_layout
 
+\begin_layout Scrap
+  $relyx_file = "temp$$";
+\end_layout
+
+\begin_layout Scrap
+  &setup_files($input_file, $relyx_file);
+\end_layout
+
+\begin_layout Scrap
+}
+\end_layout
+
+\begin_layout Scrap
+@
+\end_layout
+
+\begin_layout Standard
 This code uses a small perl subroutine, 
 \family roman
 \series medium
@@ -688,7 +836,8 @@ This code uses a small perl subroutine,
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[setup_files]]
 \end_layout
 
@@ -707,28 +856,38 @@ status collapsed
 \end_layout
 
 \begin_layout Scrap
-
 <<Subroutines>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 sub setup_files {
-\newline
+\end_layout
+
+\begin_layout Scrap
   my($in, $out) = @_;
-\newline
-  open(INPUT, "<$in") || die "Can not read $in: $!
+\end_layout
+
+\begin_layout Scrap
+  open(INPUT, "<$in") || die "Cannot read $in: $!
 \backslash
 n";
-\newline
-  open(OUTPUT, ">$out") || die "Can not write $out: $!
+\end_layout
+
+\begin_layout Scrap
+  open(OUTPUT, ">$out") || die "Cannot write $out: $!
 \backslash
 n";
-\newline
+\end_layout
+
+\begin_layout Scrap
 }
-\newline
+\end_layout
+
+\begin_layout Scrap
 @ %def setup_files   
 \end_layout
 
 \begin_layout Subsection
-
 Reading in the 
 \noun on
 noweb
@@ -737,46 +896,65 @@ noweb
 \end_layout
 
 \begin_layout Standard
-
 After we see the beginning of the scrap, we need to read in and save the
  rest of the scrap for output.
 \end_layout
 
 \begin_layout Scrap
-
 <<Save the beginning of the scrap to savedScrap>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 $savedScrap = $_;
-\newline
+\end_layout
+
+\begin_layout Scrap
 $endLine = "";
-\newline
-@
 \end_layout
 
 \begin_layout Scrap
+@
+\end_layout
 
+\begin_layout Scrap
 <<Concatenate the rest of the scrap>>=
-\newline
+\begin_inset Newline newline
+\end_inset
+
 scrapline: while (<INPUT>) {
-\newline
+\begin_inset Newline newline
+\end_inset
+
   last scrapline if /^@
 \backslash
 s+/;
-\newline
+\begin_inset Newline newline
+\end_inset
+
   $savedScrap .= $_;
-\newline
+\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
+\begin_inset Newline newline
+\end_inset
+
   if (/^@
 \backslash
 s+%def.*$/) {$savedScrap .= $_; last switch; }
-\newline
+\begin_inset Newline newline
+\end_inset
+
   if (/^@
 \backslash
 s+(.*)$/) {$savedScrap .= "@
@@ -784,26 +962,29 @@ s+(.*)$/) {$savedScrap .= "@
 n"; $endLine = "$1
 \backslash
 n"; }
-\newline
+\begin_inset Newline newline
+\end_inset
+
 }
-\newline
+\begin_inset Newline newline
+\end_inset
+
 @
 \end_layout
 
 \begin_layout Subsection
-
 Printing out the scrap
 \end_layout
 
 \begin_layout Standard
-
 The final piece of the first pass of the conversion is done by this code.
 \end_layout
 
 \begin_layout Scrap
-
 <<print out the scrap in a reLyXskip block>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 print OUTPUT "
 \backslash
 
@@ -811,9 +992,13 @@ print OUTPUT "
 begin{reLyXskip}
 \backslash
 n";
-\newline
+\end_layout
+
+\begin_layout Scrap
 print OUTPUT $savedScrap;
-\newline
+\end_layout
+
+\begin_layout Scrap
 print OUTPUT "
 \backslash
 
@@ -823,14 +1008,17 @@ end{reLyXskip}
 n
 \backslash
 n";
-\newline
+\end_layout
+
+\begin_layout Scrap
 print OUTPUT "$endLine";
-\newline
+\end_layout
+
+\begin_layout Scrap
 @
 \end_layout
 
 \begin_layout Standard
-
 Finally, we need to close the 
 \family roman
 \series medium
@@ -844,7 +1032,8 @@ Finally, we need to close the
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[INPUT]]
 \end_layout
 
@@ -858,8 +1047,11 @@ status collapsed
 \emph default
 \bar default
 \noun default
 \color inherit
- and 
+and
+\color none
 \family roman
 \series medium
 \shape up
@@ -867,12 +1059,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,28 +1078,32 @@ status collapsed
 \emph default
 \bar default
 \noun default
 \color inherit
- files.
+files.
 \end_layout
 
 \begin_layout Scrap
-
 <<Close INPUT and OUTPUT>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 close(INPUT);
-\newline
+\end_layout
+
+\begin_layout Scrap
 close(OUTPUT);
-\newline
+\end_layout
+
+\begin_layout Scrap
 @
 \end_layout
 
 \begin_layout Section
-
 Running reLyX
 \end_layout
 
 \begin_layout Standard
-
 In this section, we describe and implement the code that runs reLyX on the
  intermediate file 
 \family roman
@@ -922,7 +1118,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 +1139,32 @@ 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
  (to choose the corresponding literate document layout).
  For this, we need to parse the intermediate file.
 \end_layout
 
 \begin_layout Scrap
-
 <<Run reLyX on intermediate file>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 <<Parse for document class>>
-\newline
+\end_layout
+
+\begin_layout Scrap
 <<Run reLyX with document class>>
-\newline
+\end_layout
+
+\begin_layout Scrap
 @
 \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 
@@ -980,8 +1179,7 @@ noweb2lyx.nw
 \begin_inset Foot
 status collapsed
 
-\begin_layout Standard
-
+\begin_layout Plain Layout
 reLyX searches for 
 \backslash
 
@@ -999,7 +1197,8 @@ doc
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 {}
 \end_layout
 
@@ -1027,7 +1226,8 @@ ument
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 {}
 \end_layout
 
@@ -1056,66 +1256,91 @@ noweb2lyx
 \end_layout
 
 \begin_layout Scrap
-
 <<Parse for document class>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 open(INPUT, "<$relyx_file") ||
-\newline
-  die "Can not read $relyx_file: $!
+\end_layout
+
+\begin_layout Scrap
+  die "Cannot read $relyx_file: $!
 \backslash
 n";
-\newline
+\end_layout
+
+\begin_layout Scrap
 $class = "article"; # default if none found
-\newline
+\end_layout
+
+\begin_layout Scrap
 parse: while(<INPUT>) {
-\newline
+\end_layout
+
+\begin_layout Scrap
   if (/
 \backslash
 
 \backslash
 docu[m]entclass{(.*)}/) {
-\newline
+\end_layout
+
+\begin_layout Scrap
     $class = $1;
-\newline
+\end_layout
+
+\begin_layout Scrap
     last parse;
-\newline
+\end_layout
+
+\begin_layout Scrap
   }
-\newline
+\end_layout
+
+\begin_layout Scrap
 }
-\newline
+\end_layout
+
+\begin_layout Scrap
 close(INPUT);
-\newline
+\end_layout
+
+\begin_layout Scrap
 @
 \end_layout
 
 \begin_layout Subsection
-
 Running reLyX 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
-
 <<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
 n"
-\newline
+\begin_inset Newline newline
+\end_inset
+
   if (system("reLyX -c $doc_class $relyx_file"));
-\newline
+\begin_inset Newline newline
+\end_inset
+
 @
 \end_layout
 
 \begin_layout Standard
-
 reLyX performs the main bulk of the translation work.
  Note that if the ``literate-
 \emph on
@@ -1130,42 +1355,56 @@ noweb
 \end_layout
 
 \begin_layout Section
-
 Fixing the reLyX output
 \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:
 \end_layout
 
 \begin_layout Scrap
-
 <<Fix up LyX file>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 <<Setup INPUT and OUTPUT for the final output>>
-\newline
+\end_layout
+
+\begin_layout Scrap
 line: while(<INPUT>)
-\newline
+\end_layout
+
+\begin_layout Scrap
 {
-\newline
+\end_layout
+
+\begin_layout Scrap
   <<Fix code chunks in latex layout>>
-\newline
+\end_layout
+
+\begin_layout Scrap
   <<Fix [[var]] noweb construct>>
-\newline
+\end_layout
+
+\begin_layout Scrap
   print OUTPUT; # default
-\newline
+\end_layout
+
+\begin_layout Scrap
 } 
-\newline
+\end_layout
+
+\begin_layout Scrap
 <<Close INPUT and OUTPUT>>
-\newline
+\end_layout
+
+\begin_layout Scrap
 @
 \end_layout
 
 \begin_layout Standard
-
 Note that in the perl code that is contained in the 
 \family roman
 \series medium
@@ -1179,7 +1418,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 +1433,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 +1445,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 +1464,18 @@ 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.
 \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 +1489,8 @@ Setting up the
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 [[INPUT]]
 \end_layout
 
@@ -1261,8 +1504,11 @@ status collapsed
 \emph default
 \bar default
 \noun default
 \color inherit
- and 
+and
+\color none
 \family roman
 \series medium
 \shape up
@@ -1270,12 +1516,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,81 +1535,114 @@ 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
-
 <<Setup INPUT and OUTPUT for the final output>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 if ($post_only) {
-\newline
+\end_layout
+
+\begin_layout Scrap
   &setup_files("$input_file", "$output_file");
-\newline
+\end_layout
+
+\begin_layout Scrap
 } else {
-\newline
+\end_layout
+
+\begin_layout Scrap
   &setup_files("$relyx_file.lyx", "$output_file");
-\newline
+\end_layout
+
+\begin_layout Scrap
 }
-\newline
+\end_layout
+
+\begin_layout Scrap
 @
 \end_layout
 
 \begin_layout Subsection
-
 Making sure the code chunks are in the Scrap 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.
 \end_layout
 
 \begin_layout Scrap
-
 <<Fix code chunks in latex layout>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 if (/
 \backslash
 
 \backslash
 latex latex/) { # Beginning of some latex code
-\newline
+\end_layout
+
+\begin_layout Scrap
   if (($line = <INPUT>) =~ /^
 \backslash
 s*<</) { # code scrap
-\newline
+\end_layout
+
+\begin_layout Scrap
     <<Transform this chunk into layout scrap>>
-\newline
+\end_layout
+
+\begin_layout Scrap
   } else {
-\newline
+\end_layout
+
+\begin_layout Scrap
     # print the 
 \backslash
 latex latex line + next line
-\newline
+\end_layout
+
+\begin_layout Scrap
     print OUTPUT "$_$line";
-\newline
+\end_layout
+
+\begin_layout Scrap
   }
-\newline
+\end_layout
+
+\begin_layout Scrap
   next line;
-\newline
+\end_layout
+
+\begin_layout Scrap
 }
-\newline
+\end_layout
+
+\begin_layout Scrap
 @
 \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:
 \end_layout
 
 \begin_layout Scrap
-
 <<Transform this chunk into layout scrap>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
+
+\end_layout
+
+\begin_layout Scrap
 $savedScrap = "
 \backslash
 
@@ -1373,61 +1652,86 @@ layout Scrap
 n
 \backslash
 n$line";
-\newline
+\begin_inset Newline newline
+\end_inset
+
 codeline: while (<INPUT>) {
-\newline
+\begin_inset Newline newline
+\end_inset
+
   $savedScrap .= $_;
-\newline
+\begin_inset Newline newline
+\end_inset
+
   last codeline if /^@
 \backslash
 s+/;
-\newline
+\begin_inset Newline newline
+\end_inset
+
 };
-\newline
+\begin_inset Newline newline
+\end_inset
+
 print OUTPUT $savedScrap;
-\newline
+\begin_inset Newline newline
+\end_inset
+
 <<Slurp up to the end of the latex layout>>
-\newline
+\begin_inset Newline newline
+\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
-
 <<Slurp up to the end of the latex layout>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 slurp: while (<INPUT>) {
-\newline
+\end_layout
+
+\begin_layout Scrap
   last slurp if /
 \backslash
 
 \backslash
 latex /;
-\newline
+\end_layout
+
+\begin_layout Scrap
   next slurp if /
 \backslash
 
 \backslash
 newline/;
-\newline
+\end_layout
+
+\begin_layout Scrap
   next slurp if /^
 \backslash
 s*$/;
-\newline
+\end_layout
+
+\begin_layout Scrap
   warn "confused by line: $_";
-\newline
+\end_layout
+
+\begin_layout Scrap
 }
-\newline
+\end_layout
+
+\begin_layout Scrap
 @
 \end_layout
 
 \begin_layout Subsection
-
 Taking care of the 
 \noun on
 noweb
@@ -1441,7 +1745,6 @@ noweb
 
 \begin_layout Standard
 
-
 \noun on
 noweb
 \noun default
@@ -1462,9 +1765,10 @@ noweb
 \end_layout
 
 \begin_layout Scrap
-
 <<Fix [[var]] noweb construct>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 if (/
 \backslash
 [
@@ -1474,7 +1778,9 @@ if (/
 ]
 \backslash
 ]/) { # special code for [[var]]
-\newline
+\end_layout
+
+\begin_layout Scrap
   s/
 \backslash
 [
 latex default
 \backslash
 n/g;
-\newline
+\end_layout
+
+\begin_layout Scrap
   print OUTPUT;
-\newline
+\end_layout
+
+\begin_layout Scrap
   next line;
-\newline
+\end_layout
+
+\begin_layout Scrap
 }
-\newline
+\end_layout
+
+\begin_layout Scrap
 @
 \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
-
 <<Clean up>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 system("rm -f $relyx_file*") unless ($post_only || $pre_only);
-\newline
+\end_layout
+
+\begin_layout Scrap
 @
 \end_layout
 
 \begin_layout Section
-
 User supplied arguments
 \end_layout
 
 \begin_layout Standard
-
 The 
 \noun on
 noweb2lyx
@@ -1544,65 +1857,105 @@ noweb2lyx
 \end_layout
 
 \begin_layout Scrap
-
 <<Setup variables from user supplied args>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 &usage() if ($#ARGV < 1); # zero or one argument 
-\newline
+\end_layout
+
+\begin_layout Scrap
 if ($ARGV[0] eq "-pre") {
-\newline
+\end_layout
+
+\begin_layout Scrap
   &usage unless ($#ARGV == 2);
-\newline
+\end_layout
+
+\begin_layout Scrap
   $input_file = $ARGV[1]; $output_file = $ARGV[2]; $pre_only = 1;
-\newline
+\end_layout
+
+\begin_layout Scrap
 } elsif ($ARGV[0] eq "-post") {
-\newline
+\end_layout
+
+\begin_layout Scrap
   &usage unless ($#ARGV == 2);
-\newline
+\end_layout
+
+\begin_layout Scrap
   $input_file = $ARGV[1]; $output_file = $ARGV[2]; $post_only = 1;
-\newline
+\end_layout
+
+\begin_layout Scrap
 } else {
-\newline
+\end_layout
+
+\begin_layout Scrap
   &usage unless ($#ARGV == 1);
-\newline
+\end_layout
+
+\begin_layout Scrap
   $input_file = $ARGV[0]; $output_file = $ARGV[1];
-\newline
+\end_layout
+
+\begin_layout Scrap
   $pre_only = 0; $post_only = 0;
-\newline
+\end_layout
+
+\begin_layout Scrap
 }
-\newline
-@ %def input_file output_file pre_only post_only
 \end_layout
 
 \begin_layout Scrap
+@ %def input_file output_file pre_only post_only
+\end_layout
 
+\begin_layout Scrap
 <<Subroutines>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 sub usage() {
-\newline
+\end_layout
+
+\begin_layout Scrap
   print "Usage: noweb2lyx [-pre | -post] input-file output-file
-\newline
+\end_layout
+
+\begin_layout Scrap
+\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
 @sylvan.com>.
 \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
 \end_layout
 
 \begin_layout Section
-
 Generating the 
 \noun on
 noweb2lyx
@@ -1611,7 +1964,6 @@ noweb2lyx
 \end_layout
 
 \begin_layout Standard
-
 The noweb2lyx script can be tangled from LyX if you set 
 \family typewriter
 
@@ -1627,43 +1979,50 @@ build-script
 \end_layout
 
 \begin_layout LyX-Code
-
 #!/bin/sh
-\newline
+\begin_inset Newline newline
+\end_inset
+
 notangle -Rbuild-script $1 | sh
 \end_layout
 
 \begin_layout Scrap
-
 <<build-script>>=
-\newline
+\end_layout
+
+\begin_layout Scrap
 PREFIX=/usr
-\newline
+\end_layout
+
+\begin_layout Scrap
 notangle -Rnoweb2lyx.in noweb2lyx.nw > noweb2lyx.in
-\newline
+\end_layout
+
+\begin_layout Scrap
 sed -e "s=@PERL@=$PREFIX/bin/perl=" noweb2lyx.in > noweb2lyx
-\newline
+\end_layout
+
+\begin_layout Scrap
 chmod +x noweb2lyx
-\newline
-@
 \end_layout
 
+\begin_layout Scrap
+@
+\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 +2031,11 @@ Macros
 \bar no
 \noun off
 \color none
-
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 
 \backslash
 nowebchunks
@@ -1688,13 +2047,11 @@ nowebchunks
 \end_layout
 
 \begin_layout Section*
-
 Identifiers
 \end_layout
 
 \begin_layout Standard
 
-
 \family roman
 \series medium
 \shape up
@@ -1703,11 +2060,11 @@ Identifiers
 \bar no
 \noun off
 \color none
-
 \begin_inset ERT
 status collapsed
 
-\begin_layout Standard
+\begin_layout Plain Layout
+
 
 \backslash
 nowebindex