Add getting-started guide - only for texmacs so far
[newfangle.git] / docs / getting-started.tm
blobdbd63c76cbce3e7c8c452615277d8b0f68cb10c6
1 <TeXmacs|1.0.7.10>
3 <style|<tuple|article|tmdoc-keyboard|header-article|fangle>>
5 <\body>
6   <hide-preamble|<assign|LyX|<macro|L<space|-0.1667em><move|Y|0fn|-0.25em><space|-0.125em>X>><assign|par-first|0fn><assign|par-par-sep|0.5fn>>
8   <doc-data|<doc-title|Getting Started with
9   Fangle>|<doc-author-data|<author-name|Sam Liddicott>|<\author-address>
10     sam@liddicott.com
11   </author-address>>>
13   <assign|sub-page|<\macro|x>
14     <\wide-std-framed>
15       \;
17       <\padded-centered|0cm|2cm>
18         <indent-both|1cm|1cm|<arg|x>>
19       </padded-centered>
20     </wide-std-framed>
21   </macro>>
23   <assign|fake-caret|<macro|<with|color|black|<math|\<vdots\>>>>>
25   <\abstract>
26     This document explains how to use fangle and is a companion to
27     <strong|Fangle> which explains how fangle works.
29     Of course one does not need to know how Fangle works in order to use it,
30     and one may find it easier to understand how it works when one knows how
31     it is used.
33     Because of this it is probably better to read <strong|Getting Started
34     with Fangle> before reading <strong|Fangle>.
36     This document is not intended to cover what <em|literate programming> is,
37     or what its advantages are. It is assumed that the reader will have some
38     knowledge of this. This document covers how to use fangle for literate
39     programming, assuming that the user has at least some theoretical
40     knowledge of what this entails.
42     This document includes getting and installing fangle, starting a new
43     simple fangle project (with <TeXmacs>, <LyX>, <LaTeX>, and plain text)
44     and then making use of <strong|Makefile.inc> (from the <strong|Fangle>
45     book) for larger projects and for specific sub-modules of existing Make
46     based projects.
48     This document should have enough detail to help someone who is
49     un-familiar with <TeXmacs> or <LyX> to become acquainted with their use
50     for literate programming, but is not intended to guide the reader in
51     making particularly effective use of these editors.
53     It is assumed that the reader will already have a functioning
54     installation of <TeXmacs>, <LyX>, <LaTeX> or whatever document
55     preparation system they intend to employ.
56   </abstract>
58   <\table-of-contents|toc>
59   </table-of-contents>
61   <part|Getting and Installing Fangle>
63   <section|Getting Fangle>
65   The latest release of Fangle can be downloaded as a gzip'd tar file from
66   the git repository at <hlink|http://git.savannah.gnu.org/cgit/fangle.git/snapshot/latest.tar.gz|>
68   You can checkout the entire git repository read-only by cloning either
69   <hlink|git://git.sv.gnu.org/fangle.git|> or
70   <hlink|http://git.savannah.gnu.org/r/fangle.git|>
72   Users with a Savannah.gnu.org login can also clone
73   <hlink|ssh://git.sv.gnu.org/srv/git/fangle.git|> which will also give
74   commit access to project members.
76   <section|Installing Fangle>
78   There is no <verbatim|make install><\footnote>
79     there should be, but I'm writing this document partly to find out what
80     the obstacles to adoption are
81   </footnote> so you will need to copy files to the correct places, as
82   described here.
84   <todo|Make install>
86   <subsection|For personal use>
88   <subsubsection|The fangle untangler>
90   <verbatim|fangle> itself needs copying to where personal programs are kept.
91   This could just be the git checkout directory or the place where you
92   un-tar'd latest.tar.gz
94   I keep my personal programs in a private <verbatim|.local/bin> directory
95   which I keep in my path.
97   <\verbatim>
98     mkdir -p $HOME/.local/bin
100     cp fangle $HOME/.local/bin
101   </verbatim>
103   If you don't have this folder in your path (and you use bash) you could add
104   it like this:
106   <verbatim|echo 'export PATH=$PATH:$HOME/.local/bin' \<gtr\>\<gtr\>
107   $HOME/.bashrc>
109   and if you don't want to have to login again, also set the path for the
110   current session:
112   <verbatim|<verbatim|export PATH=$PATH:$HOME/.local/bin>>
114   <subsubsection|The <TeXmacs> stylesheet>
116   If you are using <TeXmacs>, then <verbatim|fangle.ts> needs copying to your
117   private <TeXmacs> packages folder:
119   <verbatim|cp fangle.ts $HOME/.TeXmacs/packages/>
121   <subsubsection|The <LyX> stylesheet>
123   If you are using <LyX>, then <verbatim|fangle.module> needs copying to your
124   private <LyX> modules folder:
126   <verbatim|cp fangle.module $HOME/.lyx/modules/>
128   You will also need to have Norman Ramsey's <name|noweb> stylesheet
129   installed.
131   <subsubsection|The <TeX> stylesheet>
133   <todo|Still needs ripping off out of the .module maybe>
135   You will also need to have Norman Ramsey's noweb stylesheet installed.
137   <subsection|For system-wide use>
139   <subsubsection|The fangle untangler>
141   <paragraph|/usr/local/bin>
143   <verbatim|fangle> can be copied to <verbatim|/usr/local/bin>
145   <verbatim|sudo cp fangle /usr/local/bin>
147   <paragraph|/opt>
149   you could extract the entire package to <verbatim|/opt/fangle> but might
150   want to add <verbatim|/opt/fangle> to the system-wide path. You could do
151   that like this
153   <\verbatim>
154     echo 'PATH=$PATH:/opt/fangle' \<gtr\>\<gtr\> /etc/profile.d/fangle.sh
156     echo export PATH \<gtr\>\<gtr\> /etc/profile.d/fangle.sh
157   </verbatim>
159   <subsubsection|The <TeXmacs> stylesheet>
161   If you are using <TeXmacs> then you will need to install
162   <verbatim|fangle.ts> into the <TeXmacs> system-wide package folder. This
163   might be <verbatim|/usr/share/texmacs/TeXmacs/packages/> but may vary
164   across installations.
166   <verbatim|cp fangle.ts /usr/share/texmacs/TeXmacs/packages/>
168   <subsubsection|The <LyX> stylesheet>
170   If you are using <LyX>, then you will need to install
171   <verbatim|fangle.module> into the <LyX> system-wide modules folder. This
172   might be <verbatim|/usr/share/lyx/> but may vary across installations
174   <verbatim|cp fangle.module /usr/share/lyx/modules/>
176   You will also need to have Norman Ramsey's <name|noweb> stylesheet
177   installed.
179   <subsubsection|The <TeX> stylesheet>
181   <todo|Still needs ripping off out of the .module maybe>
183   You will also need to have Norman Ramsey's noweb stylesheet installed.
185   <part|Authoring with Fangle>
187   Fangle has editor style-sheets for <TeXmacs> and <LyX> to aid document
188   editing.
190   Fangle can untangle<\footnote>
191     <em|untangling> is the historical term referring to the extraction or
192     generation of source code from the documentation
193   </footnote> sources from text files produced by <TeXmacs>'s verbatim
194   export, from <TeX> files generated by <LyX>, from plain hand-edited <LaTeX>
195   or <TeX> files, and from plain text files that adhere to certain
196   conventions (either hand-written or generated from other document editors).
198   This part will show how to start a simple project for <TeXmacs>, <LyX>,
199   <LaTeX>/<TeX> and plain text.
201   The instructions cover more than mere use of the fangle style-sheet.
202   Literate programming is more than just pretty-looks or a bound booklet
203   <emdash> it is a mind-set. Good titles, author information, abstracts, good
204   structure and good narrative are essential to stop the whole thing being a
205   good-looking waste of time.
207   <section|<TeXmacs>>
209   This section does not assume a large degree of familiarity with <TeXmacs>,
210   but you should have spent at least a few minutes figuring out how to use
211   it.
213   <subsection|Load fangle style-sheet>
215   <\enumerate>
216     <item>Start <TeXmacs> with a new document.
218     <item>Work around a dumb bug in Fangle<\footnote>
219       And if you can work out what the fix is to get fangle.ts to execute
220       this command, please let me know!
221     </footnote>.
223     From the menu: <menu|Tools|Execute|Evaluate scheme expression...> and
224     type: <verbatim|(define-group enumerate-tag nf-chunk)>
226     Sadly you will need to do this each time you start <TeXmacs> but lucky
227     for you it will remember the last command you ran.
229     <item>Choose an appropriate document style:
231     From the menu: <menu|Document|Style|article>
233     For small informal projects I usually choose <em|article>, and for longer
234     more formal projects I usually choose a <em|book>.
236     <item>Add the fangle package:
238     From the menu: <menu|Document|Add package|fangle>
240     If the <em|fangle> package isn't listed, then update your styles
241     selection with:
243     <menu|Tools|Update|Styles> and then try again
245     <item>Optionally, (if you prefer this style):
247     <menu|Document|View|Create preamble> (or <menu|Document|View|Show
248     preamble>) and insert this:
250     <verbatim|\<less\>assign\|par-first\|0fn\<gtr\>\<less\>assign\|par-par-sep\|0.5fn\<gtr\>>
252     and then: <menu|Document|View|Show all parts>
253   </enumerate>
255   <subsection|Save the document>
257   Save the document, and call it <verbatim|hello-world.tm>
259   From the menu: <menu|File|Save>
261   <subsection|Sandard document parts>
263   <subsubsection|Insert your title>
265   <menu|Insert|Title|Insert title>
267   <\enumerate>
268     <item>Type the name of your document:
269     <keys|L|i|t|e|r|a|t|e|space|E|x|a|m|p|l|e>
271     <item>Press <key|enter> and then type your name.
273     <item>Press <key|enter> and then type your email address.
275     <item>Press <key|right> to leave the title block
276   </enumerate>
278   <subsubsection|Insert your abstract>
280   <menu|Insert|Title|Abstract>
282   The abstract should explain what the document is about and help the reader
283   discover if the document is relevant to them. It should not contain
284   explanations that the document contains but it should explain what it is
285   that the document contains.
287   See the abstract to this document for a fair example.
289   After you have entered the abstract, press <key|right> to leave the
290   abstract block
292   <subsubsection|Insert a table of contents>
294   <menu|Insert|Automatic|Table of contents>
296   <subsubsection|Start a new section (or chapter)>
298   <menu|Insert|Section|Section> (or <menu|Insert|Section|Chapter>) and type
299   the name of the chapter:
301   <keys|H|e|l|l|o|space|W|o|r|l|d|enter>
303   The first chapter will generally illustrate the problem to be solved and
304   explain how the book is to be used to understand and provide the solution.
306   <subsection|Talk about your code>
308   Before you insert a chunk of code, you introduce it.
310   Usually you will have introduced some aspect of the main problem that the
311   program as a whole will solve, and will then outline the solution that this
312   chunk will provide.
314   We will introduce our hello-world chunk by typing:
316   <key|T h e> <key|space> <key|t y p i c a l> <key|space> <key|h e l l o>
317   <key|space> <key|w o r l d> <key|space> <key|p r o g r a m> <key|space>
318   <key|l o o k s> <key|space> <key|l i k e> <key|space> <key|t h i s :>
319   <key|enter>
321   <subsection|Insert your first code chunk>
323   Fangle currently has no menus; all commands are entered with a back-slash.
324   This may annoy you, but it is much faster to keep your hands off the mouse.
326   <todo|Add some menus bindings>
328   Fangle chunks are (currently) called: <verbatim|nf-chunk> and are entered
329   like this:
331   <\enumerate>
332     <item>type: <keys|\\|n|f|-|c|h|u|n|k> <emdash> it will appear like this:
333     <inactive|<hybrid|nf-chunk>>
335     <item>press <key|enter><math|>
337     Depending on your <TeXmacs> environment, you may get either this
338     <inactive|<nf-chunk|<fake-caret>|||>> which is the inactive view, or the
339     active view shown below:
341     <\sub-page>
342       <\nf-fake-chunk|<fake-caret>>
343         \;
344       </nf-fake-chunk|||1|1a|||||>
345     </sub-page>
347     The text insertion point is represented by the three vertical dots
348     <fake-caret>
350     <item>Type the name of your chunk: <keys|h|e|l|l|o|-|w|o|r|l|d>
352     This will give you either <inactive|<nf-chunk|hello-world<fake-caret>|||>>
353     for the inactive view, or the active view shown as below:
355     <\sub-page>
356       <\nf-fake-chunk|hello-world<fake-caret>>
357         <item>
358       </nf-fake-chunk|||1|1a|||||>
359     </sub-page>
360   </enumerate>
362   <subsection|Optional chunk parameters>
364   Press <key|right> to move the text insertion point to the second argument
365   of the chunk.
367   This is to specify parameters to the code that will be contained in the
368   chunk. Chunks can take optional parameters, and behave somewhat like C
369   macros.
371   Usually chunks will not have parameters, although parameters can be useful
372   when a chunk is used to express an algorithm (like a sort) or a class of
373   behaviours (like binary tree management). In such cases, a set of
374   parameterized chunks can work like generics or C++ templates.
376   If chunk has parameters, they must be enclosed in a tuple. When I
377   understand DRD's a bit better this will be done for you, but for now if you
378   want chunk parameters then you must type <keys|\\|t|u|p|l|e|enter>,
379   otherwise skip to the next step.
381   Type the first chunk argument, and then for additional arguments,
382   <key|M-right> (windows key and right arrow).
384   You can type multiple parameters: <inactive|<nf-chunk|hello-world|<tuple|message|language<fake-caret>>||>>
385   or
387   <\sub-page>
388     <\nf-fake-chunk|hello-world>
389       <item>
390     </nf-fake-chunk||<tuple|message|language<fake-caret>>|1|1a|||||>
391   </sub-page>
393   <subsection|Typing code>
395   Press <key|right> to move the text insertion point to the main code area.
397   If your chunk shows as inactive then this will be visible as the third
398   argument, but you may prefer to activate your chunk at this point. You
399   should be able to do this by pressing <key|enter> or clicking the
400   <image|<tuple|<#89504E470D0A1A0A0000000D49484452000000110000001108060000003B6D47FA000000017352474200AECE1CE900000006624B474400FF00FF00FFA0BDA793000000097048597300000B1300000B1301009A9C180000000774494D4507DB06120F0303780569BC0000001974455874436F6D6D656E74004372656174656420776974682047494D5057810E17000000924944415438CBBD94D10D80200C440FE3127E38846C0303EA3665083F1CA37E95102D52A2B17F90DCCB91BBE22811E3E50CF860C6F2E0176F1652221D020031C42660DDD6BA935EB119721532339C733688888FFDC877D33CD99C68620130731D52A67215B700B927129706E82A1B2552DFDC72A136B60459002A2486584DA16B77046471F11831805BA94C9072A97EFF0A4E5C193CCC5933FA210000000049454E44AE426082>|png>||||>
401   icon on the toolbar. Sometimes the <image|<tuple|<#89504E470D0A1A0A0000000D49484452000000110000001108060000003B6D47FA000000017352474200AECE1CE900000006624B474400FF00FF00FFA0BDA793000000097048597300000B1300000B1301009A9C180000000774494D4507DB06120F0303780569BC0000001974455874436F6D6D656E74004372656174656420776974682047494D5057810E17000000924944415438CBBD94D10D80200C440FE3127E38846C0303EA3665083F1CA37E95102D52A2B17F90DCCB91BBE22811E3E50CF860C6F2E0176F1652221D020031C42660DDD6BA935EB119721532339C733688888FFDC877D33CD99C68620130731D52A67215B700B927129706E82A1B2552DFDC72A136B60459002A2486584DA16B77046471F11831805BA94C9072A97EFF0A4E5C193CCC5933FA210000000049454E44AE426082>|png>||||>
402   icon is absent and pressent enter does nothing <emdash> in which case I
403   don't know what you must do.
405   <\sub-page>
406     <\nf-fake-chunk|hello-world>
407       <item><fake-caret>
408     </nf-fake-chunk||<tuple|message|language>|1|1a|||||>
409   </sub-page>
411   \;
413   At this point, start typing code.
415   When you press <key|enter>, a new line number will be inserted at the left
416   of the listing. If you press <key|S-enter> then you can break the line for
417   layout purposes, but it will not be considered a new-line when the code is
418   extracted and leading white-space will be stripped.
420   <\sub-page>
421     <\nf-fake-chunk|hello-world>
422       <item>#include stdio.c
424       <item>
426       <item>main() {
428       <item> \ printf("<fake-caret>
429     </nf-fake-chunk||<tuple|message|language>|1|1a|||||>
430   </sub-page>
432   The listing above is incomplete. Instead of typing the the traditional
433   <verbatim|hello world!>, we can make use of our chunk arguments. Let's
434   place the value of the argument <with|color|blue|message> at this point.
436   The command for a chunk argument is <keys|\\|n|f|-|a|r|g>, but when you
437   press the <key|\\> it will enter a literal <verbatim|\\> because the cursor
438   is in a code block. To enter a command-backslash in code block, use the
439   meta key (probably the windows button): <keys|M-\\|n|f|-|a|r|g> and this
440   will produce: <inactive*|<nf-arg|>>
442   To enter the name of the argument <with|color|blue|message>, type
443   <keys|m|e|s|s|a|g|e|enter> which will produce <nf-arg|message>
445   Finish typing the code as shown below:
447   <\sub-page>
448     <\nf-fake-chunk|hello-world>
449       <item>#include stdio.c
451       <item>
453       <item>main() {
455       <item> \ printf("<nf-arg|hey>\\n");
457       <item>}<fake-caret>
458     </nf-fake-chunk||<tuple|message|language>|1|1a|||||>
459   </sub-page>
461   We've now defined a chunk of code which can potentially produce the famous
462   <verbatim|hello world!> in any language.
464   If the chunk were more complicated, we could break off part-way through and
465   provide more explanation, and then insert another chunk <em|with the same
466   name> to continue the code. In this way a single chunk can be broken across
467   sections and spread across the whole document and still be assembled in
468   order.
470   Let's define some file-chunks that use this chunk.
472   <subsection|File chunks>
474   By convention, file chunk is just a regular chunk whose name begins with
475   <verbatim|./> which signifies to build-tools that it should be extracted
476   into a file.
478   <subsubsection|French hello-world>
480   Insert a new sub-section for french:
482   <menu|Insert|Section|Subsection> (or <menu|Insert|Section|Section>) and
483   type the name of the subsection:
485   <key|I n> <key|space> <key|F r e n c h> <key|enter>
487   Then introduce the next code chunk, type:
488   <keys|W|e|space|w|i|l|l|space|d|e|r|i|v|e|space|t|h|e|space|f|r|e|n|c|h|space|h|e|l|l|o|-|w|o|r|l|d|space|p|r|o|g|r|a|m|space|l|i|k|e|space|t|h|i|s|:|enter>
490   Then, create a chunk called hello-world.en.c, by typing:
491   <keys|\\|n|f|-|c|h|u|n|k|enter> and then the chunk name
492   <keys|.|/|h|e|l|l|o|-|w|o|r|l|d|.|f|r|.|c|right|right>
494   <\sub-page>
495     <strong|<small|1.1 In French>><htab|0mm>
497     We will derive the french hello-world program like this:<htab|0mm>
499     <\nf-fake-chunk|hello-world.fr.c>
500       <item><fake-caret>
501     </nf-fake-chunk||<tuple>|1|1b|||||>
502   </sub-page>
504   To include our previous chunk with the <verbatim|nf-ref> command, type
505   <keys|M-\\|n|f|-|r|e|f|enter> and then type the name of our previous chunk,
506   <keys|h|e|l|l|o|-|w|o|r|l|d|right>
508   Then type the argument <em|Bonjour tout le monde> in a tuple:
510   <keys|M-\\|t|u|p|l|e|enter|B|o|n|j|o|u|r|space|t|o|u|t|space|l|e|space|m|o|n|d|e|enter>
512   <\sub-page>
513     <strong|<small|1.1 In French>><htab|0mm>
515     We will derive the french hello-world program like this:<htab|0mm>
517     <\nf-fake-chunk|hello-world.fr.c>
518       <item><nf-fake-ref|hello-world|<tuple|Bonjour tout le
519       monde>|1a><fake-caret>
520     </nf-fake-chunk||<tuple>|1|1b|||||>
521   </sub-page>
523   <subsubsection|German hello-world>
525   And let's create a similar chunk for german. Insert a new sub-section:
527   <menu|Insert|Section|Subsection> (or <menu|Insert|Section|Section>) and
528   type the name of the subsection:
530   <key|I n> <key|space> <key|G e r m a n> <key|enter>
532   Then introduce the next code chunk, type:
533   <keys|W|e|space|w|i|l|l|space|d|e|r|i|v|e|space|t|h|e|space|g|e|r|m|a|n|space|h|e|l|l|o|-|w|o|r|l|d|space|p|r|o|g|r|a|m|space|l|i|k|e|space|t|h|i|s|:|enter>
535   <\sub-page>
536     <strong|<small|1.1 In German>><htab|0mm>
538     We will derive the german hello-world program like this:<htab|0mm>
540     <\nf-fake-chunk|hello-world.de.c>
541       <item><nf-fake-ref|hello-world|<tuple|Hallo welt>|1a><fake-caret>
542     </nf-fake-chunk||<tuple>|1|1c|||||>
543   </sub-page>
545   <subsection|Additional parameters>
547   Astute readers will have noticed that the <verbatim|hello-world> chunk has
548   two parameters but that our french and german invocations only have one
549   argument. This is not really a problem as the <verbatim|hello-world> chunk
550   only uses one; but let's change that:
552   <\sub-page>
553     <\nf-fake-chunk|hello-world>
554       <item>/* The traditional hello-world program in <nf-arg|language>\ 
556       <item> * generated using fangle literate programming macros
558       <item> */
560       <item>#include stdio.c
562       <item>
564       <item>main() {
566       <item> \ printf("<nf-arg|message>\\n");
568       <item>}<fake-caret>
569     </nf-fake-chunk||<tuple|message|language>|1|1a|||||>
570   </sub-page>
572   We will now modify our french and german .c files by clicking inside
573   <with|color|blue|Bonjour tout le monde> and pressing <key|M-right> and then
574   typing: <key|f r e n c h>
576   <\sub-page>
577     <\nf-fake-chunk|hello-world.fr.c>
578       <item><nf-fake-ref|hello-world|<tuple|Bonjour tout le
579       monde|french>|1a><fake-caret>
580     </nf-fake-chunk||<tuple>|1|1b|||||>
581   </sub-page>
583   And doing similarly for the german:
585   <\sub-page>
586     <\nf-fake-chunk|hello-world.de.c>
587       <item><nf-fake-ref|hello-world|<tuple|Hallo
588       welt|german>|1a><fake-caret>
589     </nf-fake-chunk||<tuple>|1|1c|||||>
590   </sub-page>
592   <subsection|Extracting individual files>
594   Later on, automatic extraction using <verbatim|Makefile.inc> is shown, but
595   this is how to extract chunks manually from a <TeXmacs> document.
597   <\enumerate>
598     <item>Save the <verbatim|hello-world.tm> document\ 
600     <item>Generate a text file hello-world.txt, either with
601     <menu|File|Export\|Verbatim> or with this command line:
603     <verbatim|texmacs -s -c hello-world.tm hello-world.txt -q>
605     <item>Extract the french and german files:
607     <\verbatim>
608       fangle -R./hello-world.fr.c hello-world.txt \<gtr\> hello-world.fr.c
610       fangle -R./hello-world.de.c hello-world.txt \<gtr\> hello-world.de.c
611     </verbatim>
612   </enumerate>
614   The resultant french file should look like this:
616   <\small>
617     <\cpp>
618       <\with|par-par-sep|0fn>
619         #include stdio.c
621         /* The traditional hell-world program in french\ 
623         \ * generated using literate programming macros
625         \ */
627         main() {
629         \ \ printf("Bonjour tout le monde\\n");
631         }
632       </with>
633     </cpp>
634   </small>
636   <subsection|Extracting all files>
638   A list of all the chunks can be obtained with:
640   <verbatim|fangle -r hello-world.txt>
642   So we can extract all files like this:
644   <\verbatim>
645     texmacs -s -c hello-world.tm hello-world.txt -q &&
647     fangle -r hello-world.txt \| while read file
649     do fangle -R"$file" \<gtr\> "$file"
650   </verbatim>
652   If you have <em|noweb> installed then you can use <verbatim|cpif> to avoid
653   updating files that haven't changed:
655   <\verbatim>
656     texmacs -s -c hello-world.tm hello-world.txt -q &&
658     fangle -r hello-world.txt \| while read file
660     do fangle -R"$file" \| cpif "$file"
661   </verbatim>
663   <subsection|The completed document>
665   The document you typed might look something like this:<no-page-break>
667   <\sub-page>
668     <htab|0mm><strong|Literate Example><htab|0mm>
670     <\with|par-par-sep|0fn>
671       <\small>
672         Joe Soap<htab|0mm>joe@example.com
673       </small>
674     </with>
676     <htab|0mm><small|<strong|Abstract>><htab|0mm>
678     <\small>
679       This is a simple example of how to use literate programming templates,
680       using hello-world.
682       Hello-world is a famous <em|first program> with a visible side effect.
684       This example produces hello-world in multiple languages.
685     </small>
687     <strong|Table of Contents>
689     <\with|par-par-sep|0fn>
690       <with|font-series|bold|math-font-series|bold|1<space|2spc>Hello World>
691       <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
692       <no-break>1
694       <with|par-left|1.5fn|1.1<space|2spc>In French
695       <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
696       <no-break>1><vspace|0.0fn>
698       <with|par-left|1.5fn|1.2<space|2spc>In German
699       <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
700       <no-break>1><vspace|0.5fn>
701     </with>
703     \;
705     <with|font-series|bold|math-font-series|bold|1 Hello World>
707     The typical hello-world program looks something like this:
709     <\nf-fake-chunk|hello-world>
710       <item>/* The traditional hello-world program in <nf-arg|language>\ 
712       <item> * generated using literate programming macros
714       <item> */
716       <item>#include stdio.c
718       <item>
720       <item>main() {
722       <item> \ printf("<nf-arg|message>\\n");
724       <item>}
725     </nf-fake-chunk||<tuple|message|language>|1|1a|||||>
727     <strong|<small|1.1 In French>>
729     We will derive the french hello-world program like this:<htab|0mm>
731     <\nf-fake-chunk|hello-world.fr.c>
732       <item><nf-fake-ref|hello-world|<tuple|Bonjour tout le monde|french>|1a>
733     </nf-fake-chunk||<tuple>|1|1b|||||>
735     <small|<strong|1.2 In German>>
737     We will derive the german hello-world program like this:<htab|0mm>
739     <\nf-fake-chunk|hello-world.de.c>
740       <item><nf-fake-ref|hello-world|<tuple|Hallo welt|german>|1a>
741     </nf-fake-chunk||<tuple>|1|1c|||||>
743     \;
744   </sub-page>
746   <section|<LyX>>
747 </body>
749 <\initial>
750   <\collection>
751     <associate|page-medium|papyrus>
752     <associate|page-screen-height|746496tmpt>
753     <associate|page-screen-margin|false>
754     <associate|page-screen-width|1268736tmpt>
755     <associate|preamble|false>
756   </collection>
757 </initial>
759 <\references>
760 </references>
762 <\auxiliary>
763 </auxiliary>