1 #LyX 2.2 created this file. For more info see http://www.lyx.org/
5 \origin /systemlyxdir/examples/
9 % This relaxes the noweb constraint that chunks are
10 % never broken across pages.
12 % This is from the noweb FAQ
14 \def\nwendcode{\endtrivlist \endgroup}
15 \let\nwdocspar=\smallbreak
17 \use_default_options false
21 \maintain_unincluded_children false
23 \language_package default
24 \inputencoding default
26 \font_roman "default" "default"
27 \font_sans "default" "default"
28 \font_typewriter "default" "default"
29 \font_math "auto" "auto"
30 \font_default_family default
31 \use_non_tex_fonts false
34 \font_sf_scale 100 100
35 \font_tt_scale 100 100
37 \default_output_format default
39 \bibtex_command default
40 \index_command default
41 \paperfontsize default
46 \use_package amsmath 0
47 \use_package amssymb 0
50 \use_package mathdots 1
51 \use_package mathtools 0
53 \use_package stackrel 0
54 \use_package stmaryrd 0
55 \use_package undertilde 0
57 \cite_engine_type default
61 \paperorientation portrait
71 \paragraph_separation indent
72 \paragraph_indentation default
73 \quotes_language english
76 \paperpagestyle default
77 \tracking_changes false
94 Sylvan <kayvan@sylvan.com>
101 \begin_layout Abstract
102 This document describes and implements a perl script for importing noweb
103 files into \SpecialCharNoPassThru LyX
106 \begin_layout Standard
107 \begin_inset CommandInset toc
108 LatexCommand tableofcontents
115 \begin_layout Standard
116 \begin_inset Newpage newpage
122 \begin_layout Section
126 \begin_layout Standard
127 Since version 1.0.1, \SpecialCharNoPassThru LyX
128 now supports Literate Programming using
133 This addition to \SpecialCharNoPassThru LyX
134 made it very pleasant to write programs in the literate
135 style (like this one).
136 In addition to being able to write new literate programs, it would be quite
141 code could be imported into \SpecialCharNoPassThru LyX
143 That's where this program comes in.
146 \begin_layout Standard
155 file to \SpecialCharNoPassThru LyX
159 \begin_layout Standard
160 \begin_inset Flex Chunk
163 \begin_layout Plain Layout
165 \begin_inset Argument 1
168 \begin_layout Plain Layout
177 \begin_layout Plain Layout
182 \begin_layout Plain Layout
184 # Copyright (C) 1999 Kayvan A.
185 Sylvan <kayvan@sylvan.com>
188 \begin_layout Plain Layout
190 # You are free to use and modify this code under the terms of
193 \begin_layout Plain Layout
195 # the GNU General Public Licence version 2 or later.
198 \begin_layout Plain Layout
203 \begin_layout Plain Layout
205 # Written with assistance from:
208 \begin_layout Plain Layout
210 # Edmar Wienskoski Jr.
211 <edmar-w-jr@technologist.com>
214 \begin_layout Plain Layout
216 # Amir Karger <karger@post.harvard.edu>
219 \begin_layout Plain Layout
224 \begin_layout Plain Layout
226 # $Id: noweb2lyx.lyx,v 1.5 2005/07/18 09:42:27 jamatos Exp $
229 \begin_layout Plain Layout
234 \begin_layout Plain Layout
236 # NOTE: This file was automatically generated from noweb2lyx.lyx using noweb.
239 \begin_layout Plain Layout
244 \begin_layout Plain Layout
246 <<Setup variables from user supplied args>>
249 \begin_layout Plain Layout
254 \begin_layout Plain Layout
256 <<Convert noweb to \SpecialCharNoPassThru LyX
265 \begin_layout Section
266 The Noweb file defined
269 \begin_layout Standard
274 file is a collection of documentation and code chunks.
275 Documentation chunks simply start with an ``@'' and have no name:
278 \begin_layout LyX-Code
279 @ Here is some documentation.
282 \begin_layout Standard
286 \begin_layout Plain Layout
288 We can do arbitrary \SpecialCharNoPassThru LaTeX
292 \begin_layout Plain Layout
303 \begin_layout Standard
304 Code chunks look like this:
307 \begin_layout LyX-Code
312 \begin_layout Plain Layout
323 \begin_layout Plain Layout
331 \begin_inset Newline newline
335 code for the chunk goes here ...}
336 \begin_inset Newline newline
342 \begin_layout Standard
343 The ``@'' is a necessary delimiter to end the code chunk.
344 The other form that the ``@'' line takes is as follows:
347 \begin_layout LyX-Code
352 \begin_layout Plain Layout
363 \begin_layout Plain Layout
371 \begin_inset Newline newline
375 code for the chunk ...}
376 \begin_inset Newline newline
379 @ %def identifier1 identifier2
382 \begin_layout Standard
383 In the latter form, we are declaring to
387 that this code chunk defines identifier1, identifier2, etc.
390 \begin_layout Standard
391 When first tackling this problem, I spoke with members of the \SpecialCharNoPassThru LyX
393 knew about the literate programming extensions and re\SpecialCharNoPassThru LyX
394 (the \SpecialCharNoPassThru LaTeX
399 \begin_layout Standard
400 One of the first ideas was to extend the re\SpecialCharNoPassThru LyX
401 code to understand the
406 This proved to be too hard and presents other problems
410 \begin_layout Plain Layout
411 Not the least of these problems is the fact that << is a quote in French.
417 On the other hand, it turns out that re\SpecialCharNoPassThru LyX
418 contains a very useful literal
420 If the input file contains the construct
423 \begin_layout LyX-Code
426 begin{re\SpecialCharNoPassThru LyX
428 \begin_inset Newline newline
432 \SpecialCharNoPassThru LaTeX
434 \begin_inset Newline newline
439 end{re\SpecialCharNoPassThru LyX
443 \begin_layout Standard
444 then re\SpecialCharNoPassThru LyX
445 will copy the surrounded code to the output file verbatim.
446 Given this, the first part of the translation is easy; we simply have to
447 copy the code chunks into an intermediate file that surrounds them with
452 begin{re\SpecialCharNoPassThru LyX
459 end{re\SpecialCharNoPassThru LyX
465 \begin_layout Standard
466 Once re\SpecialCharNoPassThru LyX
467 is done with the input file, the problem is reduced to changing
468 the code chunks from \SpecialCharNoPassThru LyX
469 's \SpecialCharNoPassThru LaTeX
470 layout to the Chunk layout.
473 \begin_layout Standard
474 There is one final constraint on
479 We want to be able to run it as a simple pre-processor and post-processor
480 from within re\SpecialCharNoPassThru LyX
482 We can accomplish this by setting the flags
495 \begin_layout Plain Layout
526 \begin_layout Plain Layout
543 before we reach the main conversion code.
546 \begin_layout Standard
547 With all that preamble out of the way, we now have the basic high-level
548 outline for our code:
551 \begin_layout Standard
552 \begin_inset Flex Chunk
555 \begin_layout Plain Layout
557 \begin_inset Argument 1
560 \begin_layout Plain Layout
561 Convert noweb to \SpecialCharNoPassThru LyX
569 \begin_layout Plain Layout
571 <<Transform noweb for re\SpecialCharNoPassThru LyX
575 \begin_layout Plain Layout
580 \begin_layout Plain Layout
582 if ((!$pre_only) && (!$post_only)) {
585 \begin_layout Plain Layout
587 <<Run re\SpecialCharNoPassThru LyX
588 on intermediate file>>
591 \begin_layout Plain Layout
596 \begin_layout Plain Layout
601 \begin_layout Plain Layout
603 <<Fix up \SpecialCharNoPassThru LyX
607 \begin_layout Plain Layout
612 \begin_layout Plain Layout
622 \begin_layout Section
623 Making a file that re\SpecialCharNoPassThru LyX
627 \begin_layout Standard
628 In this section, we present the code that performs the task of creating
629 the intermediate file that re\SpecialCharNoPassThru LyX
630 can process, using the algorithm that
632 This algorithm is outlined in the code that follows:
635 \begin_layout Standard
636 \begin_inset Flex Chunk
639 \begin_layout Plain Layout
643 \begin_layout Plain Layout
645 <<Transform noweb for re\SpecialCharNoPassThru LyX
649 \begin_layout Plain Layout
651 <<Setup INPUT and OUTPUT>>
654 \begin_layout Plain Layout
656 inputline: while(<INPUT>)
659 \begin_layout Plain Layout
664 \begin_layout Plain Layout
676 >=/) { # Beginning of a noweb chunk
679 \begin_layout Plain Layout
681 <<Read in and output the noweb code chunk>>
684 \begin_layout Plain Layout
688 s+(.*)/) { # Beginning of a documentation chunk
691 \begin_layout Plain Layout
693 print OUTPUT $1; # We do not need the ``@'' part
696 \begin_layout Plain Layout
706 ]/) { # noweb quoted code
709 \begin_layout Plain Layout
711 <<Perform special input quoting of [[var]]>>
714 \begin_layout Plain Layout
719 \begin_layout Plain Layout
721 print OUTPUT; # Just let the line pass through
724 \begin_layout Plain Layout
729 \begin_layout Plain Layout
734 \begin_layout Plain Layout
736 <<Close INPUT and OUTPUT>>
744 \begin_layout Standard
745 In the code above, we do some pre-processing of the noweb ``[[...]]'' construct.
746 This avoids some problems with re\SpecialCharNoPassThru LyX
747 confusing lists composed of ``[[...]]''
751 \begin_layout Standard
755 \begin_layout Plain Layout
757 <<Perform special input quoting of [[var]]>>=
760 \begin_layout Plain Layout
771 \begin_layout Plain Layout
776 \begin_layout Plain Layout
786 \begin_layout Standard
800 \begin_layout Plain Layout
817 file, once we have identified a
821 code chunk, we transform it into a form that is usable by re\SpecialCharNoPassThru LyX
825 \begin_layout Standard
826 \begin_inset Flex Chunk
829 \begin_layout Plain Layout
831 \begin_inset Argument 1
834 \begin_layout Plain Layout
835 Read in and output the noweb code chunk
840 <<Save the beginning of the chunk to savedchunk>>
843 \begin_layout Plain Layout
845 <<Concatenate the rest of the chunk>>
848 \begin_layout Plain Layout
850 <<print out the chunk in a re\SpecialCharNoPassThru LyX
859 \begin_layout Subsection
860 File input and output for the pre-processing step
863 \begin_layout Standard
881 \begin_layout Plain Layout
912 \begin_layout Plain Layout
929 to read and write files.
930 In the code fragment above, we need to read from the input file and write
931 to a file that will be later transformed by re\SpecialCharNoPassThru LyX
933 If we are being called only to pre-process the input file, then there is
934 no need to create a temporary file.
937 \begin_layout Standard
938 \begin_inset Flex Chunk
941 \begin_layout Plain Layout
943 \begin_inset Argument 1
946 \begin_layout Plain Layout
947 Setup INPUT and OUTPUT
955 \begin_layout Plain Layout
957 &setup_files($input_file, $output_file);
960 \begin_layout Plain Layout
965 \begin_layout Plain Layout
967 $relyx_file = "temp$$";
970 \begin_layout Plain Layout
972 &setup_files($input_file, $relyx_file);
975 \begin_layout Plain Layout
985 \begin_layout Standard
986 This code uses a small perl subroutine,
999 \begin_layout Plain Layout
1015 , which we define below:
1018 \begin_layout Standard
1022 \begin_layout Plain Layout
1027 \begin_layout Plain Layout
1032 \begin_layout Plain Layout
1037 \begin_layout Plain Layout
1039 open(INPUT, "<$in") || die "Cannot read $in: $!
1044 \begin_layout Plain Layout
1046 open(OUTPUT, ">$out") || die "Cannot write $out: $!
1051 \begin_layout Plain Layout
1056 \begin_layout Plain Layout
1066 \begin_layout Subsection
1074 \begin_layout Standard
1075 After we see the beginning of the chunk, we need to read in and save the
1076 rest of the chunk for output.
1079 \begin_layout Standard
1080 \begin_inset Flex Chunk
1083 \begin_layout Plain Layout
1085 \begin_inset Argument 1
1088 \begin_layout Plain Layout
1089 Save the beginning of the chunk to savedchunk
1097 \begin_layout Plain Layout
1107 \begin_layout Standard
1111 \begin_layout Plain Layout
1113 <<Concatenate the rest of the chunk>>=
1116 \begin_layout Plain Layout
1118 chunkline: while (<INPUT>) {
1121 \begin_layout Plain Layout
1123 last chunkline if /^@
1128 \begin_layout Plain Layout
1133 \begin_layout Plain Layout
1138 \begin_layout Plain Layout
1143 \begin_layout Plain Layout
1147 s+$/) {$savedchunk .= $_; last switch; }
1150 \begin_layout Plain Layout
1154 s+%def.*$/) {$savedchunk .= $_; last switch; }
1157 \begin_layout Plain Layout
1161 s+(.*)$/) {$savedchunk .= "@
1168 \begin_layout Plain Layout
1173 \begin_layout Plain Layout
1183 \begin_layout Subsection
1184 Printing out the chunk
1187 \begin_layout Standard
1188 The final piece of the first pass of the conversion is done by this code.
1191 \begin_layout Standard
1192 \begin_inset Flex Chunk
1195 \begin_layout Plain Layout
1197 \begin_inset Argument 1
1200 \begin_layout Plain Layout
1201 print out the chunk in a re\SpecialCharNoPassThru LyX
1211 begin{re\SpecialCharNoPassThru LyX
1217 \begin_layout Plain Layout
1219 print OUTPUT $savedchunk;
1222 \begin_layout Plain Layout
1228 end{re\SpecialCharNoPassThru LyX
1236 \begin_layout Plain Layout
1238 print OUTPUT "$endLine";
1246 \begin_layout Standard
1247 Finally, we need to close the
1260 \begin_layout Plain Layout
1291 \begin_layout Plain Layout
1311 \begin_layout Standard
1312 \begin_inset Flex Chunk
1315 \begin_layout Plain Layout
1317 \begin_inset Argument 1
1320 \begin_layout Plain Layout
1321 Close INPUT and OUTPUT
1329 \begin_layout Plain Layout
1339 \begin_layout Section
1340 Running re\SpecialCharNoPassThru LyX
1343 \begin_layout Standard
1344 In this section, we describe and implement the code that runs re\SpecialCharNoPassThru LyX
1359 \begin_layout Plain Layout
1379 \begin_layout Subsection
1380 Selecting the document class
1383 \begin_layout Standard
1384 In order to run re\SpecialCharNoPassThru LyX
1385 , we need to know the article class of the input document
1386 (to choose the corresponding literate document layout).
1387 For this, we need to parse the intermediate file.
1390 \begin_layout Standard
1391 \begin_inset Flex Chunk
1394 \begin_layout Plain Layout
1396 \begin_inset Argument 1
1399 \begin_layout Plain Layout
1400 Run re\SpecialCharNoPassThru LyX
1401 on intermediate file
1406 <<Parse for document class>>
1409 \begin_layout Plain Layout
1411 <<Run re\SpecialCharNoPassThru LyX
1412 with document class>>
1420 \begin_layout Standard
1421 In the code below, you'll see a strange regular expression to search for
1423 The reason for this kludge is that without it, we can't run
1431 file that is generated by \SpecialCharNoPassThru LyX
1435 \begin_layout Plain Layout
1436 re\SpecialCharNoPassThru LyX
1454 \begin_layout Plain Layout
1483 \begin_layout Plain Layout
1499 class and gets confused, so we have to obfuscate it slightly.
1505 With the regular expression as it is, we can actually run
1509 on itself and a produce a quite reasonable \SpecialCharNoPassThru LyX
1513 \begin_layout Standard
1514 \begin_inset Flex Chunk
1517 \begin_layout Plain Layout
1519 \begin_inset Argument 1
1522 \begin_layout Plain Layout
1523 Parse for document class
1528 open(INPUT, "<$relyx_file") ||
1531 \begin_layout Plain Layout
1533 die "Cannot read $relyx_file: $!
1538 \begin_layout Plain Layout
1540 $class = "article"; # default if none found
1543 \begin_layout Plain Layout
1545 parse: while(<INPUT>) {
1548 \begin_layout Plain Layout
1554 docu[m]entclass{(.*)}/) {
1557 \begin_layout Plain Layout
1562 \begin_layout Plain Layout
1567 \begin_layout Plain Layout
1572 \begin_layout Plain Layout
1577 \begin_layout Plain Layout
1587 \begin_layout Subsection
1588 Running re\SpecialCharNoPassThru LyX
1589 with the corresponding literate document layout
1592 \begin_layout Standard
1593 Now that we know what the document class ought to be, we do:
1596 \begin_layout Standard
1600 \begin_layout Plain Layout
1602 <<Run re\SpecialCharNoPassThru LyX
1603 with document class>>=
1606 \begin_layout Plain Layout
1608 $doc_class = "literate-" .
1612 \begin_layout Plain Layout
1614 die "re\SpecialCharNoPassThru LyX
1615 returned non-zero: $!
1620 \begin_layout Plain Layout
1622 if (system("re\SpecialCharNoPassThru LyX
1623 -c $doc_class $relyx_file"));
1626 \begin_layout Plain Layout
1636 \begin_layout Standard
1637 re\SpecialCharNoPassThru LyX
1638 performs the main bulk of the translation work.
1639 Note that if the ``literate-
1643 '' document layout is not found, then re\SpecialCharNoPassThru LyX
1644 will fail with an error.
1645 In that case, you may need to modify your
1649 input file to a supported document type.
1652 \begin_layout Section
1653 Fixing the re\SpecialCharNoPassThru LyX
1657 \begin_layout Standard
1658 We need to perform some post-processing of what re\SpecialCharNoPassThru LyX
1660 to have the best output for our literate document.
1661 The outline of the post-processing steps are:
1664 \begin_layout Standard
1665 \begin_inset Flex Chunk
1668 \begin_layout Plain Layout
1670 \begin_inset Argument 1
1673 \begin_layout Plain Layout
1674 Fix up \SpecialCharNoPassThru LyX
1680 <<Setup INPUT and OUTPUT for the final output>>
1683 \begin_layout Plain Layout
1685 line: while(<INPUT>)
1688 \begin_layout Plain Layout
1693 \begin_layout Plain Layout
1695 <<Fix code chunks in latex layout>>
1698 \begin_layout Plain Layout
1700 <<Fix [[var]] noweb construct>>
1703 \begin_layout Plain Layout
1705 print OUTPUT; # default
1708 \begin_layout Plain Layout
1713 \begin_layout Plain Layout
1715 <<Close INPUT and OUTPUT>>
1723 \begin_layout Standard
1724 Note that in the perl code that is contained in the
1737 \begin_layout Plain Layout
1754 loop above, the perl construct
1768 \begin_layout Plain Layout
1785 is sufficient to restart the loop.
1786 We can use this construct to do some relatively complex parsing of the
1787 re\SpecialCharNoPassThru LyX
1791 \begin_layout Subsection
1792 File input and output for the post-processing
1795 \begin_layout Standard
1809 \begin_layout Plain Layout
1840 \begin_layout Plain Layout
1857 is taken care of by this code:
1860 \begin_layout Standard
1861 \begin_inset Flex Chunk
1864 \begin_layout Plain Layout
1866 \begin_inset Argument 1
1869 \begin_layout Plain Layout
1870 Setup INPUT and OUTPUT for the final output
1878 \begin_layout Plain Layout
1880 &setup_files("$input_file", "$output_file");
1883 \begin_layout Plain Layout
1888 \begin_layout Plain Layout
1890 &setup_files("$relyx_file.lyx", "$output_file");
1893 \begin_layout Plain Layout
1903 \begin_layout Subsection
1904 Making sure the code chunks are in the Chunk layout
1907 \begin_layout Standard
1908 Now, as we outlined before, the final step is transforming the code-chunks
1909 which have been put into a \SpecialCharNoPassThru LaTeX
1910 layout by \SpecialCharNoPassThru LyX
1911 into the Chunk layout.
1914 \begin_layout Standard
1915 \begin_inset Flex Chunk
1918 \begin_layout Plain Layout
1920 \begin_inset Argument 1
1923 \begin_layout Plain Layout
1924 Fix code chunks in latex layout
1933 latex latex/) { # Beginning of some latex code
1936 \begin_layout Plain Layout
1938 if (($line = <INPUT>) =~ /^
1940 s*<</) { # code chunk
1943 \begin_layout Plain Layout
1945 <<Transform this chunk into layout chunk>>
1948 \begin_layout Plain Layout
1953 \begin_layout Plain Layout
1957 latex latex line + next line
1960 \begin_layout Plain Layout
1962 print OUTPUT "$_$line";
1965 \begin_layout Plain Layout
1970 \begin_layout Plain Layout
1975 \begin_layout Plain Layout
1985 \begin_layout Standard
1986 When we are sure that we are in a code chunk, we must read in the rest of
1987 the code chunk and output a chunk layout for it:
1990 \begin_layout Standard
1994 \begin_layout Plain Layout
1996 <<Transform this chunk into layout chunk>>=
1999 \begin_layout Plain Layout
2003 \begin_layout Plain Layout
2016 \begin_layout Plain Layout
2018 codeline: while (<INPUT>) {
2021 \begin_layout Plain Layout
2026 \begin_layout Plain Layout
2028 last codeline if /^@
2033 \begin_layout Plain Layout
2038 \begin_layout Plain Layout
2040 print OUTPUT $savedchunk;
2043 \begin_layout Plain Layout
2045 <<Slurp up to the end of the latex layout>>
2048 \begin_layout Plain Layout
2058 \begin_layout Standard
2059 Okay, now we just need to eat the rest of the latex layout.
2060 There should only be a few different types of lines for us to match:
2063 \begin_layout Standard
2064 \begin_inset Flex Chunk
2067 \begin_layout Plain Layout
2069 \begin_inset Argument 1
2072 \begin_layout Plain Layout
2073 Slurp up to the end of the latex layout
2078 slurp: while (<INPUT>) {
2081 \begin_layout Plain Layout
2090 \begin_layout Plain Layout
2099 \begin_layout Plain Layout
2106 \begin_layout Plain Layout
2108 warn "confused by line: $_";
2111 \begin_layout Plain Layout
2121 \begin_layout Subsection
2133 \begin_layout Standard
2138 allows the user to use a special code quoting mechanism in documentation
2140 Fixing this ``[[quoted-code]]''
2144 syntax means putting the ``[[quoted-code]]'' in a \SpecialCharNoPassThru LaTeX
2145 layout in the \SpecialCharNoPassThru LyX
2147 Otherwise, \SpecialCharNoPassThru LyX
2148 will backslash-quote the brackets, creating ugly output.
2149 The quoted-code is transformed by
2153 when it generates the final \SpecialCharNoPassThru LaTeX
2157 \begin_layout Standard
2158 \begin_inset Flex Chunk
2161 \begin_layout Plain Layout
2163 \begin_inset Argument 1
2166 \begin_layout Plain Layout
2167 Fix [[var]] noweb construct
2180 ]/) { # special code for [[var]]
2183 \begin_layout Plain Layout
2210 \begin_layout Plain Layout
2215 \begin_layout Plain Layout
2220 \begin_layout Plain Layout
2230 \begin_layout Section
2231 Cleaning up intermediate files
2234 \begin_layout Standard
2235 The cleanup code is very simple:
2238 \begin_layout Standard
2239 \begin_inset Flex Chunk
2242 \begin_layout Plain Layout
2244 \begin_inset Argument 1
2247 \begin_layout Plain Layout
2253 system("rm -f $relyx_file*") unless ($post_only || $pre_only);
2261 \begin_layout Section
2262 User supplied arguments
2265 \begin_layout Standard
2270 script understands two arguments, input-file and output-file.
2271 It is also set up to be used internally by re\SpecialCharNoPassThru LyX
2272 to pre-process or postprocess
2273 files in the import pipeline.
2276 \begin_layout Standard
2280 \begin_layout Plain Layout
2282 <<Setup variables from user supplied args>>=
2285 \begin_layout Plain Layout
2287 &usage() if ($#ARGV < 1); # zero or one argument
2290 \begin_layout Plain Layout
2292 if ($ARGV[0] eq "-pre") {
2295 \begin_layout Plain Layout
2297 &usage unless ($#ARGV == 2);
2300 \begin_layout Plain Layout
2302 $input_file = $ARGV[1]; $output_file = $ARGV[2]; $pre_only = 1;
2305 \begin_layout Plain Layout
2307 } elsif ($ARGV[0] eq "-post") {
2310 \begin_layout Plain Layout
2312 &usage unless ($#ARGV == 2);
2315 \begin_layout Plain Layout
2317 $input_file = $ARGV[1]; $output_file = $ARGV[2]; $post_only = 1;
2320 \begin_layout Plain Layout
2325 \begin_layout Plain Layout
2327 &usage unless ($#ARGV == 1);
2330 \begin_layout Plain Layout
2332 $input_file = $ARGV[0]; $output_file = $ARGV[1];
2335 \begin_layout Plain Layout
2337 $pre_only = 0; $post_only = 0;
2340 \begin_layout Plain Layout
2345 \begin_layout Plain Layout
2347 @ %def input_file output_file pre_only post_only
2350 \begin_layout Plain Layout
2355 \begin_layout Plain Layout
2360 \begin_layout Plain Layout
2362 print "Usage: noweb2lyx [-pre | -post] input-file output-file
2365 \begin_layout Plain Layout
2369 \begin_layout Plain Layout
2371 If -pre is specified, only pre-processes the input-file for re\SpecialCharNoPassThru LyX
2375 \begin_layout Plain Layout
2377 Similarly, in the case of -post, post-processes re\SpecialCharNoPassThru LyX
2381 \begin_layout Plain Layout
2383 In case of bugs, Email Kayvan Sylvan <kayvan
2390 \begin_layout Plain Layout
2395 \begin_layout Plain Layout
2400 \begin_layout Plain Layout
2410 \begin_layout Section
2418 \begin_layout Standard
2419 The noweb2lyx script can be tangled from \SpecialCharNoPassThru LyX
2426 to call a generic script that always extracts a chunk named
2431 Here is an example of such a script:
2434 \begin_layout LyX-Code
2436 \begin_inset Newline newline
2439 notangle -Rbuild-script $1 | env NOWEB_SOURCE=$1 NOWEB_OUTPUT_DIR=$2 sh
2442 \begin_layout Standard
2443 \begin_inset Flex Chunk
2446 \begin_layout Plain Layout
2448 \begin_inset Argument 1
2451 \begin_layout Plain Layout
2460 \begin_layout Plain Layout
2462 notangle -Rnoweb2lyx.in noweb2lyx.nw > noweb2lyx.in
2465 \begin_layout Plain Layout
2467 sed -e "s=@PERL@=$PREFIX/bin/perl=" noweb2lyx.in > noweb2lyx
2470 \begin_layout Plain Layout
2480 \begin_layout Standard
2481 \begin_inset Newpage newpage
2487 \begin_layout Section*
2491 \begin_layout Standard
2504 \begin_layout Plain Layout
2516 \begin_layout Section*
2520 \begin_layout Standard
2533 \begin_layout Plain Layout