1 #LyX 2.2 created this file. For more info see http://www.lyx.org/
5 \save_transient_properties true
6 \origin /systemlyxdir/examples/
10 % This relaxes the noweb constraint that chunks are
11 % never broken across pages.
13 % This is from the noweb FAQ
15 \def\nwendcode{\endtrivlist \endgroup}
16 \let\nwdocspar=\smallbreak
18 \use_default_options false
22 \maintain_unincluded_children false
24 \language_package default
25 \inputencoding default
27 \font_roman "default" "default"
28 \font_sans "default" "default"
29 \font_typewriter "default" "default"
30 \font_math "auto" "auto"
31 \font_default_family default
32 \use_non_tex_fonts false
35 \font_sf_scale 100 100
36 \font_tt_scale 100 100
38 \default_output_format default
40 \bibtex_command default
41 \index_command default
42 \paperfontsize default
47 \use_package amsmath 0
48 \use_package amssymb 0
51 \use_package mathdots 1
52 \use_package mathtools 0
54 \use_package stackrel 0
55 \use_package stmaryrd 0
56 \use_package undertilde 0
58 \cite_engine_type default
62 \paperorientation portrait
72 \paragraph_separation indent
73 \paragraph_indentation default
74 \quotes_language english
77 \paperpagestyle default
78 \tracking_changes false
95 Sylvan <kayvan@sylvan.com>
102 \begin_layout Abstract
103 This document describes and implements a perl script for importing noweb
104 files into \SpecialCharNoPassThru LyX
107 \begin_layout Standard
108 \begin_inset CommandInset toc
109 LatexCommand tableofcontents
116 \begin_layout Standard
117 \begin_inset Newpage newpage
123 \begin_layout Section
127 \begin_layout Standard
128 Since version 1.0.1, \SpecialCharNoPassThru LyX
129 now supports Literate Programming using
134 This addition to \SpecialCharNoPassThru LyX
135 made it very pleasant to write programs in the literate
136 style (like this one).
137 In addition to being able to write new literate programs, it would be quite
142 code could be imported into \SpecialCharNoPassThru LyX
144 That's where this program comes in.
147 \begin_layout Standard
156 file to \SpecialCharNoPassThru LyX
160 \begin_layout Standard
161 \begin_inset Flex Chunk
164 \begin_layout Plain Layout
166 \begin_inset Argument 1
169 \begin_layout Plain Layout
178 \begin_layout Plain Layout
183 \begin_layout Plain Layout
185 # Copyright (C) 1999 Kayvan A.
186 Sylvan <kayvan@sylvan.com>
189 \begin_layout Plain Layout
191 # You are free to use and modify this code under the terms of
194 \begin_layout Plain Layout
196 # the GNU General Public Licence version 2 or later.
199 \begin_layout Plain Layout
204 \begin_layout Plain Layout
206 # Written with assistance from:
209 \begin_layout Plain Layout
211 # Edmar Wienskoski Jr.
212 <edmar-w-jr@technologist.com>
215 \begin_layout Plain Layout
217 # Amir Karger <karger@post.harvard.edu>
220 \begin_layout Plain Layout
225 \begin_layout Plain Layout
227 # $Id: noweb2lyx.lyx,v 1.5 2005/07/18 09:42:27 jamatos Exp $
230 \begin_layout Plain Layout
235 \begin_layout Plain Layout
237 # NOTE: This file was automatically generated from noweb2lyx.lyx using noweb.
240 \begin_layout Plain Layout
245 \begin_layout Plain Layout
247 <<Setup variables from user supplied args>>
250 \begin_layout Plain Layout
255 \begin_layout Plain Layout
257 <<Convert noweb to \SpecialCharNoPassThru LyX
266 \begin_layout Section
267 The Noweb file defined
270 \begin_layout Standard
275 file is a collection of documentation and code chunks.
276 Documentation chunks simply start with an ``@'' and have no name:
279 \begin_layout LyX-Code
280 @ Here is some documentation.
283 \begin_layout Standard
287 \begin_layout Plain Layout
289 We can do arbitrary \SpecialCharNoPassThru LaTeX
293 \begin_layout Plain Layout
304 \begin_layout Standard
305 Code chunks look like this:
308 \begin_layout LyX-Code
313 \begin_layout Plain Layout
324 \begin_layout Plain Layout
332 \begin_inset Newline newline
336 code for the chunk goes here ...}
337 \begin_inset Newline newline
343 \begin_layout Standard
344 The ``@'' is a necessary delimiter to end the code chunk.
345 The other form that the ``@'' line takes is as follows:
348 \begin_layout LyX-Code
353 \begin_layout Plain Layout
364 \begin_layout Plain Layout
372 \begin_inset Newline newline
376 code for the chunk ...}
377 \begin_inset Newline newline
380 @ %def identifier1 identifier2
383 \begin_layout Standard
384 In the latter form, we are declaring to
388 that this code chunk defines identifier1, identifier2, etc.
391 \begin_layout Standard
392 When first tackling this problem, I spoke with members of the \SpecialCharNoPassThru LyX
394 knew about the literate programming extensions and re\SpecialCharNoPassThru LyX
395 (the \SpecialCharNoPassThru LaTeX
400 \begin_layout Standard
401 One of the first ideas was to extend the re\SpecialCharNoPassThru LyX
402 code to understand the
407 This proved to be too hard and presents other problems
411 \begin_layout Plain Layout
412 Not the least of these problems is the fact that << is a quote in French.
418 On the other hand, it turns out that re\SpecialCharNoPassThru LyX
419 contains a very useful literal
421 If the input file contains the construct
424 \begin_layout LyX-Code
427 begin{re\SpecialCharNoPassThru LyX
429 \begin_inset Newline newline
433 \SpecialCharNoPassThru LaTeX
435 \begin_inset Newline newline
440 end{re\SpecialCharNoPassThru LyX
444 \begin_layout Standard
445 then re\SpecialCharNoPassThru LyX
446 will copy the surrounded code to the output file verbatim.
447 Given this, the first part of the translation is easy; we simply have to
448 copy the code chunks into an intermediate file that surrounds them with
453 begin{re\SpecialCharNoPassThru LyX
460 end{re\SpecialCharNoPassThru LyX
466 \begin_layout Standard
467 Once re\SpecialCharNoPassThru LyX
468 is done with the input file, the problem is reduced to changing
469 the code chunks from \SpecialCharNoPassThru LyX
470 's \SpecialCharNoPassThru LaTeX
471 layout to the Chunk layout.
474 \begin_layout Standard
475 There is one final constraint on
480 We want to be able to run it as a simple pre-processor and post-processor
481 from within re\SpecialCharNoPassThru LyX
483 We can accomplish this by setting the flags
496 \begin_layout Plain Layout
527 \begin_layout Plain Layout
544 before we reach the main conversion code.
547 \begin_layout Standard
548 With all that preamble out of the way, we now have the basic high-level
549 outline for our code:
552 \begin_layout Standard
553 \begin_inset Flex Chunk
556 \begin_layout Plain Layout
558 \begin_inset Argument 1
561 \begin_layout Plain Layout
562 Convert noweb to \SpecialCharNoPassThru LyX
570 \begin_layout Plain Layout
572 <<Transform noweb for re\SpecialCharNoPassThru LyX
576 \begin_layout Plain Layout
581 \begin_layout Plain Layout
583 if ((!$pre_only) && (!$post_only)) {
586 \begin_layout Plain Layout
588 <<Run re\SpecialCharNoPassThru LyX
589 on intermediate file>>
592 \begin_layout Plain Layout
597 \begin_layout Plain Layout
602 \begin_layout Plain Layout
604 <<Fix up \SpecialCharNoPassThru LyX
608 \begin_layout Plain Layout
613 \begin_layout Plain Layout
623 \begin_layout Section
624 Making a file that re\SpecialCharNoPassThru LyX
628 \begin_layout Standard
629 In this section, we present the code that performs the task of creating
630 the intermediate file that re\SpecialCharNoPassThru LyX
631 can process, using the algorithm that
633 This algorithm is outlined in the code that follows:
636 \begin_layout Standard
637 \begin_inset Flex Chunk
640 \begin_layout Plain Layout
644 \begin_layout Plain Layout
646 <<Transform noweb for re\SpecialCharNoPassThru LyX
650 \begin_layout Plain Layout
652 <<Setup INPUT and OUTPUT>>
655 \begin_layout Plain Layout
657 inputline: while(<INPUT>)
660 \begin_layout Plain Layout
665 \begin_layout Plain Layout
677 >=/) { # Beginning of a noweb chunk
680 \begin_layout Plain Layout
682 <<Read in and output the noweb code chunk>>
685 \begin_layout Plain Layout
689 s+(.*)/) { # Beginning of a documentation chunk
692 \begin_layout Plain Layout
694 print OUTPUT $1; # We do not need the ``@'' part
697 \begin_layout Plain Layout
707 ]/) { # noweb quoted code
710 \begin_layout Plain Layout
712 <<Perform special input quoting of [[var]]>>
715 \begin_layout Plain Layout
720 \begin_layout Plain Layout
722 print OUTPUT; # Just let the line pass through
725 \begin_layout Plain Layout
730 \begin_layout Plain Layout
735 \begin_layout Plain Layout
737 <<Close INPUT and OUTPUT>>
745 \begin_layout Standard
746 In the code above, we do some pre-processing of the noweb ``[[...]]'' construct.
747 This avoids some problems with re\SpecialCharNoPassThru LyX
748 confusing lists composed of ``[[...]]''
752 \begin_layout Standard
756 \begin_layout Plain Layout
758 <<Perform special input quoting of [[var]]>>=
761 \begin_layout Plain Layout
772 \begin_layout Plain Layout
777 \begin_layout Plain Layout
787 \begin_layout Standard
801 \begin_layout Plain Layout
818 file, once we have identified a
822 code chunk, we transform it into a form that is usable by re\SpecialCharNoPassThru LyX
826 \begin_layout Standard
827 \begin_inset Flex Chunk
830 \begin_layout Plain Layout
832 \begin_inset Argument 1
835 \begin_layout Plain Layout
836 Read in and output the noweb code chunk
841 <<Save the beginning of the chunk to savedchunk>>
844 \begin_layout Plain Layout
846 <<Concatenate the rest of the chunk>>
849 \begin_layout Plain Layout
851 <<print out the chunk in a re\SpecialCharNoPassThru LyX
860 \begin_layout Subsection
861 File input and output for the pre-processing step
864 \begin_layout Standard
882 \begin_layout Plain Layout
913 \begin_layout Plain Layout
930 to read and write files.
931 In the code fragment above, we need to read from the input file and write
932 to a file that will be later transformed by re\SpecialCharNoPassThru LyX
934 If we are being called only to pre-process the input file, then there is
935 no need to create a temporary file.
938 \begin_layout Standard
939 \begin_inset Flex Chunk
942 \begin_layout Plain Layout
944 \begin_inset Argument 1
947 \begin_layout Plain Layout
948 Setup INPUT and OUTPUT
956 \begin_layout Plain Layout
958 &setup_files($input_file, $output_file);
961 \begin_layout Plain Layout
966 \begin_layout Plain Layout
968 $relyx_file = "temp$$";
971 \begin_layout Plain Layout
973 &setup_files($input_file, $relyx_file);
976 \begin_layout Plain Layout
986 \begin_layout Standard
987 This code uses a small perl subroutine,
1000 \begin_layout Plain Layout
1016 , which we define below:
1019 \begin_layout Standard
1023 \begin_layout Plain Layout
1028 \begin_layout Plain Layout
1033 \begin_layout Plain Layout
1038 \begin_layout Plain Layout
1040 open(INPUT, "<$in") || die "Cannot read $in: $!
1045 \begin_layout Plain Layout
1047 open(OUTPUT, ">$out") || die "Cannot write $out: $!
1052 \begin_layout Plain Layout
1057 \begin_layout Plain Layout
1067 \begin_layout Subsection
1075 \begin_layout Standard
1076 After we see the beginning of the chunk, we need to read in and save the
1077 rest of the chunk for output.
1080 \begin_layout Standard
1081 \begin_inset Flex Chunk
1084 \begin_layout Plain Layout
1086 \begin_inset Argument 1
1089 \begin_layout Plain Layout
1090 Save the beginning of the chunk to savedchunk
1098 \begin_layout Plain Layout
1108 \begin_layout Standard
1112 \begin_layout Plain Layout
1114 <<Concatenate the rest of the chunk>>=
1117 \begin_layout Plain Layout
1119 chunkline: while (<INPUT>) {
1122 \begin_layout Plain Layout
1124 last chunkline if /^@
1129 \begin_layout Plain Layout
1134 \begin_layout Plain Layout
1139 \begin_layout Plain Layout
1144 \begin_layout Plain Layout
1148 s+$/) {$savedchunk .= $_; last switch; }
1151 \begin_layout Plain Layout
1155 s+%def.*$/) {$savedchunk .= $_; last switch; }
1158 \begin_layout Plain Layout
1162 s+(.*)$/) {$savedchunk .= "@
1169 \begin_layout Plain Layout
1174 \begin_layout Plain Layout
1184 \begin_layout Subsection
1185 Printing out the chunk
1188 \begin_layout Standard
1189 The final piece of the first pass of the conversion is done by this code.
1192 \begin_layout Standard
1193 \begin_inset Flex Chunk
1196 \begin_layout Plain Layout
1198 \begin_inset Argument 1
1201 \begin_layout Plain Layout
1202 print out the chunk in a re\SpecialCharNoPassThru LyX
1212 begin{re\SpecialCharNoPassThru LyX
1218 \begin_layout Plain Layout
1220 print OUTPUT $savedchunk;
1223 \begin_layout Plain Layout
1229 end{re\SpecialCharNoPassThru LyX
1237 \begin_layout Plain Layout
1239 print OUTPUT "$endLine";
1247 \begin_layout Standard
1248 Finally, we need to close the
1261 \begin_layout Plain Layout
1292 \begin_layout Plain Layout
1312 \begin_layout Standard
1313 \begin_inset Flex Chunk
1316 \begin_layout Plain Layout
1318 \begin_inset Argument 1
1321 \begin_layout Plain Layout
1322 Close INPUT and OUTPUT
1330 \begin_layout Plain Layout
1340 \begin_layout Section
1341 Running re\SpecialCharNoPassThru LyX
1344 \begin_layout Standard
1345 In this section, we describe and implement the code that runs re\SpecialCharNoPassThru LyX
1360 \begin_layout Plain Layout
1380 \begin_layout Subsection
1381 Selecting the document class
1384 \begin_layout Standard
1385 In order to run re\SpecialCharNoPassThru LyX
1386 , we need to know the article class of the input document
1387 (to choose the corresponding literate document layout).
1388 For this, we need to parse the intermediate file.
1391 \begin_layout Standard
1392 \begin_inset Flex Chunk
1395 \begin_layout Plain Layout
1397 \begin_inset Argument 1
1400 \begin_layout Plain Layout
1401 Run re\SpecialCharNoPassThru LyX
1402 on intermediate file
1407 <<Parse for document class>>
1410 \begin_layout Plain Layout
1412 <<Run re\SpecialCharNoPassThru LyX
1413 with document class>>
1421 \begin_layout Standard
1422 In the code below, you'll see a strange regular expression to search for
1424 The reason for this kludge is that without it, we can't run
1432 file that is generated by \SpecialCharNoPassThru LyX
1436 \begin_layout Plain Layout
1437 re\SpecialCharNoPassThru LyX
1455 \begin_layout Plain Layout
1484 \begin_layout Plain Layout
1500 class and gets confused, so we have to obfuscate it slightly.
1506 With the regular expression as it is, we can actually run
1510 on itself and a produce a quite reasonable \SpecialCharNoPassThru LyX
1514 \begin_layout Standard
1515 \begin_inset Flex Chunk
1518 \begin_layout Plain Layout
1520 \begin_inset Argument 1
1523 \begin_layout Plain Layout
1524 Parse for document class
1529 open(INPUT, "<$relyx_file") ||
1532 \begin_layout Plain Layout
1534 die "Cannot read $relyx_file: $!
1539 \begin_layout Plain Layout
1541 $class = "article"; # default if none found
1544 \begin_layout Plain Layout
1546 parse: while(<INPUT>) {
1549 \begin_layout Plain Layout
1555 docu[m]entclass{(.*)}/) {
1558 \begin_layout Plain Layout
1563 \begin_layout Plain Layout
1568 \begin_layout Plain Layout
1573 \begin_layout Plain Layout
1578 \begin_layout Plain Layout
1588 \begin_layout Subsection
1589 Running re\SpecialCharNoPassThru LyX
1590 with the corresponding literate document layout
1593 \begin_layout Standard
1594 Now that we know what the document class ought to be, we do:
1597 \begin_layout Standard
1601 \begin_layout Plain Layout
1603 <<Run re\SpecialCharNoPassThru LyX
1604 with document class>>=
1607 \begin_layout Plain Layout
1609 $doc_class = "literate-" .
1613 \begin_layout Plain Layout
1615 die "re\SpecialCharNoPassThru LyX
1616 returned non-zero: $!
1621 \begin_layout Plain Layout
1623 if (system("re\SpecialCharNoPassThru LyX
1624 -c $doc_class $relyx_file"));
1627 \begin_layout Plain Layout
1637 \begin_layout Standard
1638 re\SpecialCharNoPassThru LyX
1639 performs the main bulk of the translation work.
1640 Note that if the ``literate-
1644 '' document layout is not found, then re\SpecialCharNoPassThru LyX
1645 will fail with an error.
1646 In that case, you may need to modify your
1650 input file to a supported document type.
1653 \begin_layout Section
1654 Fixing the re\SpecialCharNoPassThru LyX
1658 \begin_layout Standard
1659 We need to perform some post-processing of what re\SpecialCharNoPassThru LyX
1661 to have the best output for our literate document.
1662 The outline of the post-processing steps are:
1665 \begin_layout Standard
1666 \begin_inset Flex Chunk
1669 \begin_layout Plain Layout
1671 \begin_inset Argument 1
1674 \begin_layout Plain Layout
1675 Fix up \SpecialCharNoPassThru LyX
1681 <<Setup INPUT and OUTPUT for the final output>>
1684 \begin_layout Plain Layout
1686 line: while(<INPUT>)
1689 \begin_layout Plain Layout
1694 \begin_layout Plain Layout
1696 <<Fix code chunks in latex layout>>
1699 \begin_layout Plain Layout
1701 <<Fix [[var]] noweb construct>>
1704 \begin_layout Plain Layout
1706 print OUTPUT; # default
1709 \begin_layout Plain Layout
1714 \begin_layout Plain Layout
1716 <<Close INPUT and OUTPUT>>
1724 \begin_layout Standard
1725 Note that in the perl code that is contained in the
1738 \begin_layout Plain Layout
1755 loop above, the perl construct
1769 \begin_layout Plain Layout
1786 is sufficient to restart the loop.
1787 We can use this construct to do some relatively complex parsing of the
1788 re\SpecialCharNoPassThru LyX
1792 \begin_layout Subsection
1793 File input and output for the post-processing
1796 \begin_layout Standard
1810 \begin_layout Plain Layout
1841 \begin_layout Plain Layout
1858 is taken care of by this code:
1861 \begin_layout Standard
1862 \begin_inset Flex Chunk
1865 \begin_layout Plain Layout
1867 \begin_inset Argument 1
1870 \begin_layout Plain Layout
1871 Setup INPUT and OUTPUT for the final output
1879 \begin_layout Plain Layout
1881 &setup_files("$input_file", "$output_file");
1884 \begin_layout Plain Layout
1889 \begin_layout Plain Layout
1891 &setup_files("$relyx_file.lyx", "$output_file");
1894 \begin_layout Plain Layout
1904 \begin_layout Subsection
1905 Making sure the code chunks are in the Chunk layout
1908 \begin_layout Standard
1909 Now, as we outlined before, the final step is transforming the code-chunks
1910 which have been put into a \SpecialCharNoPassThru LaTeX
1911 layout by \SpecialCharNoPassThru LyX
1912 into the Chunk layout.
1915 \begin_layout Standard
1916 \begin_inset Flex Chunk
1919 \begin_layout Plain Layout
1921 \begin_inset Argument 1
1924 \begin_layout Plain Layout
1925 Fix code chunks in latex layout
1934 latex latex/) { # Beginning of some latex code
1937 \begin_layout Plain Layout
1939 if (($line = <INPUT>) =~ /^
1941 s*<</) { # code chunk
1944 \begin_layout Plain Layout
1946 <<Transform this chunk into layout chunk>>
1949 \begin_layout Plain Layout
1954 \begin_layout Plain Layout
1958 latex latex line + next line
1961 \begin_layout Plain Layout
1963 print OUTPUT "$_$line";
1966 \begin_layout Plain Layout
1971 \begin_layout Plain Layout
1976 \begin_layout Plain Layout
1986 \begin_layout Standard
1987 When we are sure that we are in a code chunk, we must read in the rest of
1988 the code chunk and output a chunk layout for it:
1991 \begin_layout Standard
1995 \begin_layout Plain Layout
1997 <<Transform this chunk into layout chunk>>=
2000 \begin_layout Plain Layout
2004 \begin_layout Plain Layout
2017 \begin_layout Plain Layout
2019 codeline: while (<INPUT>) {
2022 \begin_layout Plain Layout
2027 \begin_layout Plain Layout
2029 last codeline if /^@
2034 \begin_layout Plain Layout
2039 \begin_layout Plain Layout
2041 print OUTPUT $savedchunk;
2044 \begin_layout Plain Layout
2046 <<Slurp up to the end of the latex layout>>
2049 \begin_layout Plain Layout
2059 \begin_layout Standard
2060 Okay, now we just need to eat the rest of the latex layout.
2061 There should only be a few different types of lines for us to match:
2064 \begin_layout Standard
2065 \begin_inset Flex Chunk
2068 \begin_layout Plain Layout
2070 \begin_inset Argument 1
2073 \begin_layout Plain Layout
2074 Slurp up to the end of the latex layout
2079 slurp: while (<INPUT>) {
2082 \begin_layout Plain Layout
2091 \begin_layout Plain Layout
2100 \begin_layout Plain Layout
2107 \begin_layout Plain Layout
2109 warn "confused by line: $_";
2112 \begin_layout Plain Layout
2122 \begin_layout Subsection
2134 \begin_layout Standard
2139 allows the user to use a special code quoting mechanism in documentation
2141 Fixing this ``[[quoted-code]]''
2145 syntax means putting the ``[[quoted-code]]'' in a \SpecialCharNoPassThru LaTeX
2146 layout in the \SpecialCharNoPassThru LyX
2148 Otherwise, \SpecialCharNoPassThru LyX
2149 will backslash-quote the brackets, creating ugly output.
2150 The quoted-code is transformed by
2154 when it generates the final \SpecialCharNoPassThru LaTeX
2158 \begin_layout Standard
2159 \begin_inset Flex Chunk
2162 \begin_layout Plain Layout
2164 \begin_inset Argument 1
2167 \begin_layout Plain Layout
2168 Fix [[var]] noweb construct
2181 ]/) { # special code for [[var]]
2184 \begin_layout Plain Layout
2211 \begin_layout Plain Layout
2216 \begin_layout Plain Layout
2221 \begin_layout Plain Layout
2231 \begin_layout Section
2232 Cleaning up intermediate files
2235 \begin_layout Standard
2236 The cleanup code is very simple:
2239 \begin_layout Standard
2240 \begin_inset Flex Chunk
2243 \begin_layout Plain Layout
2245 \begin_inset Argument 1
2248 \begin_layout Plain Layout
2254 system("rm -f $relyx_file*") unless ($post_only || $pre_only);
2262 \begin_layout Section
2263 User supplied arguments
2266 \begin_layout Standard
2271 script understands two arguments, input-file and output-file.
2272 It is also set up to be used internally by re\SpecialCharNoPassThru LyX
2273 to pre-process or postprocess
2274 files in the import pipeline.
2277 \begin_layout Standard
2281 \begin_layout Plain Layout
2283 <<Setup variables from user supplied args>>=
2286 \begin_layout Plain Layout
2288 &usage() if ($#ARGV < 1); # zero or one argument
2291 \begin_layout Plain Layout
2293 if ($ARGV[0] eq "-pre") {
2296 \begin_layout Plain Layout
2298 &usage unless ($#ARGV == 2);
2301 \begin_layout Plain Layout
2303 $input_file = $ARGV[1]; $output_file = $ARGV[2]; $pre_only = 1;
2306 \begin_layout Plain Layout
2308 } elsif ($ARGV[0] eq "-post") {
2311 \begin_layout Plain Layout
2313 &usage unless ($#ARGV == 2);
2316 \begin_layout Plain Layout
2318 $input_file = $ARGV[1]; $output_file = $ARGV[2]; $post_only = 1;
2321 \begin_layout Plain Layout
2326 \begin_layout Plain Layout
2328 &usage unless ($#ARGV == 1);
2331 \begin_layout Plain Layout
2333 $input_file = $ARGV[0]; $output_file = $ARGV[1];
2336 \begin_layout Plain Layout
2338 $pre_only = 0; $post_only = 0;
2341 \begin_layout Plain Layout
2346 \begin_layout Plain Layout
2348 @ %def input_file output_file pre_only post_only
2351 \begin_layout Plain Layout
2356 \begin_layout Plain Layout
2361 \begin_layout Plain Layout
2363 print "Usage: noweb2lyx [-pre | -post] input-file output-file
2366 \begin_layout Plain Layout
2370 \begin_layout Plain Layout
2372 If -pre is specified, only pre-processes the input-file for re\SpecialCharNoPassThru LyX
2376 \begin_layout Plain Layout
2378 Similarly, in the case of -post, post-processes re\SpecialCharNoPassThru LyX
2382 \begin_layout Plain Layout
2384 In case of bugs, Email Kayvan Sylvan <kayvan
2391 \begin_layout Plain Layout
2396 \begin_layout Plain Layout
2401 \begin_layout Plain Layout
2411 \begin_layout Section
2419 \begin_layout Standard
2420 The noweb2lyx script can be tangled from \SpecialCharNoPassThru LyX
2427 to call a generic script that always extracts a chunk named
2432 Here is an example of such a script:
2435 \begin_layout LyX-Code
2437 \begin_inset Newline newline
2440 notangle -Rbuild-script $1 | env NOWEB_SOURCE=$1 NOWEB_OUTPUT_DIR=$2 sh
2443 \begin_layout Standard
2444 \begin_inset Flex Chunk
2447 \begin_layout Plain Layout
2449 \begin_inset Argument 1
2452 \begin_layout Plain Layout
2461 \begin_layout Plain Layout
2463 notangle -Rnoweb2lyx.in noweb2lyx.nw > noweb2lyx.in
2466 \begin_layout Plain Layout
2468 sed -e "s=@PERL@=$PREFIX/bin/perl=" noweb2lyx.in > noweb2lyx
2471 \begin_layout Plain Layout
2481 \begin_layout Standard
2482 \begin_inset Newpage newpage
2488 \begin_layout Section*
2492 \begin_layout Standard
2505 \begin_layout Plain Layout
2517 \begin_layout Section*
2521 \begin_layout Standard
2534 \begin_layout Plain Layout