WIP
[newfangle.git] / fangle.ts
blob2a3fe0ada8cab52628844629d6f70334a533bef7
1 <TeXmacs|1.0.7.15>
3 <style|source>
5 <\body>
6   <\active*>
7     <\src-title>
8       <src-style-file|fangle|0.5>
10       <\src-purpose>
11         Style to be used in literate programs.
12       </src-purpose>
14       <\src-copyright|2009-2012>
15         Sam Liddicott
16       </src-copyright>
18       <\src-license>
19         This <TeXmacs> style file falls under the <hlink|GNU general public
20         license|$TEXMACS_PATH/LICENSE> and comes WITHOUT ANY WARRANTY
21         WHATSOEVER. If you do not have a copy of the license, then write to
22         the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23         Boston, MA 02111-1307, USA.
24       </src-license>
25     </src-title>
26   </active*>
28   <\active*>
29     <\src-comment>
30       The previous release of newfangle did not embed the \<less\>item\<gtr\>
31       tags within the listing to denote a new line. Instead it used tricks to
32       break the environment contents into lines and enumerated over those and
33       emitting an \<less\>item\<gtr\> tag before each one.
35       Such a technique prevented lines from wrapping when typesetting and
36       also prevented users from inserting soft line-breaks (as they can with
37       normal enumerate environments).
39       For these reasons, a change is made to explicitly use the
40       \<less\>item\<gtr\> tag at the beginning of each line in a listing.
41       When the program is extracted from the document:
43       1. lines that do not begin with \<less\>item\<gtr\> will be joined to
44       the previous line by a single space character.
46       2. if the first line does not begin with \<less\>item\<gtr\> then
48       \ \ \ a. if it is not the first instance of a chunk name, it will be
49       joined to the end of the last line of the previous chunk instance
51       Note: if a line is included in another chunk without starting a new
52       line in the including chunk then the included chunk will not start a
53       new line, regardless of whether or not it is prefixed with
54       \<less\>item\<gtr\>
56       \;
58       This sed will convert <TeXmacs> documents from the old to the new
59       format. Within nf-chunk tags it detects the start of a new entry by the
60       preceding blank line and inserts an \<less\>item\<gtr\> tag. It also
61       inserts an \<less\>item\<gtr\> tag right after the start of the
62       nf-chunk tag as this does not have a blank line.
64       <\verbatim>
65         sed -e '
67         /^[[:space:]]*\<less\>\\/nf-chunk/h
69         /^$/{n;/[^ ]/{x;/^[[:space:]]*\<less\>\\\\nf-chunk/{x;s/[[:space:]]*/
70         \<less\>item\<gtr\>/;x};x}}
72         /^[[:space:]]*\<less\>\\\\nf-chunk/{h;n;s/[[:space:]]*/
73         \<less\>item\<gtr\>/}
75         ' slow.tm
76       </verbatim>
77     </src-comment>
78   </active*>
80   <\active*>
81     <\src-comment>
82       These are our package dependancies
83     </src-comment>
84   </active*>
86   <use-package|std|env|tmdoc-markup>
88   <\active*>
89     <\src-comment>
90       This is a failed attempt to add nf-chunk to the list tag definitions.
91       It does not work and must currently be executed from Tools, Execute,
92       Evaluate Scheme Expression
93     </src-comment>
94   </active*>
96   <extern|(lambda() (define-group enumerate-tag nf-chunk))>
98   <assign|list-of-chunks|<\macro|aux|body>
99     <render-index|List of Code Chunks|<arg|body>>
100   </macro>>
102   <assign|list-of-chunks*|<\macro|aux|name|body>
103     <render-index|<localize|<arg|name>>|<arg|body>>
104   </macro>>
106   <\active*>
107     <\src-comment>
108       The filename macro is intended to format filenames with appropriate
109       visual markup and avoiding confusing insertions of hyphens when the
110       name is split over a line
111     </src-comment>
112   </active*>
114   <assign|filename|<macro|name|<verbatim|<arg|name>>>>
116   <\active*>
117     <\src-comment>
118       The build-in code and verbaitim formats have an unpleasant line spacing
119     </src-comment>
120   </active*>
122   <assign|old-code|<value|code>>
124   <assign|code|<macro|x|<with|par-par-sep|0fn|<compound|old-code|<arg|x>>>>>
126   <assign|old-verbatim|<value|verbatim>>
128   <assign|verbatim|<macro|x|<with|<merge|ov-|<get-label|<arg|x>>>|<macro|x|<old-verbatim|<arg|x>>>|ov-document|<macro|x|<with|par-par-sep|0fn|<small|<old-verbatim|<arg|x>>>>>|<compound|<merge|ov-|<get-label|<arg|x>>>|<arg|x>>>>>
130   <\active*>
131     <\src-comment>
132       This style renders causes hyperlinks to show the URL in a footnote -
133       very useful for printed text and while <TeXmacs> PDF output does not
134       support hyperlink clicking
135     </src-comment>
136   </active*>
138   <assign|old-hlink|<value|hlink>>
140   <assign|hlink|<macro|t|l|<old-hlink|<arg|t>|<arg|l>><if|<greater|<length|<arg|l>>|0>|<\footnote>
141     <old-hlink|<arg|l>|<arg|l>>
142   </footnote>>>>
144   <assign|old-render-footnote|<value|render-footnote>>
146   <assign|render-footnote|<macro|nr|x|<specific|html|\<less\>table
147   width="30%" align="right"\<gtr\>\<less\>tr\<gtr\>\<less\>td\<gtr\>><assign|zz|<arg|nr>><with|footnote-sep|<macro|<specific|html|<value|zz>>.
148   >|<old-render-footnote|<arg|nr>|<arg|x>>><specific|html|\<less\>/td\<gtr\>\<less\>/tr\<gtr\>\<less\>/table\<gtr\>>>>
150   <\active*>
151     <\src-comment>
152       This style makes it easy to render a sequence of keystrokes.
154       TODO: boundry from single-to multiple or back must have an extra space
155     </src-comment>
156   </active*>
158   <assign|keys|<xmacro|args|<with|c|0|m|<length|<map-args|identity|tuple|args>>|<while|<less|<value|c>|<value|m>>|<if|<greater|<value|c>|0>|<if|<greater|<length|<arg|args|<value|c>>>|1>|
159   >><key|<arg|args|<value|c>>><if|<less|<plus|<value|c>|1>|<value|m>>|<if|<and|<greater|<length|<arg|args|<value|c>>>|1>|<not|<greater|<length|<arg|args|<plus|<value|c>|1>>>|1>>>|
160   >><assign|c|<plus|<value|c>|1>>>>>>
162   <\active*>
163     <\src-comment>
164       This style makes it easy to render a fake text insertion point/caret
166       TODO: make it full height. Maybe make it also italic when needed
167     </src-comment>
168   </active*>
170   <assign|xlook-up-or|<macro|x|i|o|<if|<and|<equal|<get-label|<arg|x>>|tuple>|<greater|<length|<arg|x>>|<arg|i>>>|<look-up|<arg|x>|<arg|i>>|<arg|o>>>>
172   <assign|fxake-caret|<macro|<space|0.5spc><with|gr-mode|<tuple|edit|line>|gr-frame|<tuple|scale|1fs|<tuple|0.5gw|0.5gh>>|gr-geometry|<tuple|geometry|3ln|1.5ex|bottom>|gr-color|red|gr-auto-crop|false|<graphics||<with|color|red|<line|<point|0gw|1ln>|<point|1gw|1ln>>>|<with|color|red|<line|<point|0.5gw|1ln>|<point|0.5gw|1gh>>>|<with|color|red|<line|<point|0gw|1gh>|<point|1gw|1gh>>>>><space|0.5spc>>>
174   <assign|xsub-page|<macro|x|<with|ornament-color|#eeeeee|ornament-sunny-color|#000000|ornament-shadow-color|#000000|ornament-borderx|2l|ornament-hpadding|2ex|ornament-vpadding|2ex|<ornament|<surround||<htab|0spc>|<indent-both|1cm|1cm|<arg|x>>>>>>>
176   <assign|xfake-page-base-name|>
178   <assign|xfake-page-make-new-label|<macro|x|<merge|<value|fake-page-base-name>|-|<arg|x>>>>
180   <assign|xfake-page-label|<macro|x|<with|the-label|<tuple|<value|the-label>|<value|page-no>>|<quasi|<old-label|<unquote|<fake-page-make-new-label|<arg|x>>>>>>>>
182   <assign|xfake-page-reference|<macro|x|<quasi|<with|b|<get-binding|<unquote|<fake-page-make-new-label|<arg|x>>>|0>|<compound|look-up-or|<value|b>|0|<uninit>>>>>>
184   <assign|xfake-page-environment|<macro|x|<with|old-label|<value|label>|label|<value|fake-page-label>|pagerefpage|<value|fake-page-pagerefpage>|old-reference|<value|reference>|reference|<value|fake-page-reference>|this-page-no|<macro|<value|page-no>>|<arg|x>>>>
186   <assign|xinit-or|<macro|x|i|<if|<not|<equal|<uninit>|<arg|x>>>|<arg|x>|<arg|i>>>>
188   <assign|xdefault-to|<macro|x|i|<if|<not|<equal|<uninit>|<arg|x>>>|<arg|x>|<arg|i>>>>
190   <assign|xfake-page|<macro|content|doc|page-no|instance|<with|doc|<compound|init-or|<arg|doc>|>|page-no|<compound|init-or|<arg|page-no>|0>|instance|<init-or|<arg|instance>|0>|fake-page-base-name|<merge|fake-page-|<arg|doc>|-|<arg|page-no>|-|<arg|instance>>|<sub-page|<surround|<new-counter|<nf-id|nf-chunk>>||<fake-page-environment|<arg|content>>>>>>>
192   <assign|xthis-page-no|<macro|<auto-label><get-binding|<the-auto>|1>>>
194   \;
196   \;
198   \;
200   \;
202   <assign|fake-page-pagerefpage|<macro|x|<quasi|<look-up-default|<get-binding|<unquote|<fake-page-make-new-label|<arg|x>>>|0>|1|<uninit>>>>>
204   <\active*>
205     <\src-comment>
206       Now, some extensions to standard <TeXmacs> functionality.
208       \ - the get-binding trick to extract a page number is kindly given by
209       Joris who gave us so much already.
211       I would rather ispageref? just made the first test comparing to uninit
212       (the red question mark) so that real but un-placed page refs would
213       still be recognized as a pageref - however I have found documents with
214       stale labels - that no longer exist in the document but which are still
215       stored in the document references section with a target page of ?
217       --- additional note: I have found that stale labels are now not even
218       reverting to ? but retain the last known value. The only fix is to
219       insert \<less\>assign\|save-aux\|false\<gtr\> in the pre-amble and hope
220       that it works (it often doesn't) so that page references are not saved
221       at all but created from scratch each time - avoiding the problem of
222       stale labels as they won't get created!
223     </src-comment>
224   </active*>
226   <assign|ispageref?|<macro|x|<and|<not|<equal|<uninit>|<pagerefpage|<arg|x>>>>|<not|<equal|?|<pagerefpage|<arg|x>>>>>>>
228   <\active*>
229     <\src-comment>
230       Joris tells me:
232       <\verbatim>
233         Page references are links, defined by the following macro:
235         \ \ \ (macro "x"
237         \ \ \ \ \ (locus (id (hard-id (arg "x")))
239         \ \ \ \ \ \ \ \ \ \ \ \ (hyperlink (id (hard-id (arg "x")))
241         \ \ \ \ \ (url (merge "#" (arg "x"))))
243         (get-binding (arg "x") "1")))
244       </verbatim>
246       which leads to this definition if pagerefpage whose job it is to give
247       the page number for a label (as it was last calculated to be).\ 
249       This is useful when constructing our own labels that consist of the
250       page number and a sub-page counter of the target.
251     </src-comment>
252   </active*>
254   <assign|pagerefpage|<macro|x|<get-binding|<arg|x>|1>>>
256   <\active*>
257     <\src-comment>
258       These next macros control how a code chunk is rendered on the screen,
259       and could legitimately be re-defined in the document.
260     </src-comment>
261   </active*>
263   <\active*>
264     <\src-comment>
265       nf-framed-table defines the format of the single cell that used to hold
266       the listing. The listing is no longer defined in a cell, but we still
267       draw top and bottom borders.
269       Currenly we can't draw left and right borders.
270     </src-comment>
271   </active*>
273   <assign|nf-cell-border|0.5ln>
275   <assign|nf-cell-no-border|0.0ln>
277   <assign|nf-cell-top-border|<value|nf-cell-border>>
279   <assign|nf-cell-left-border|<value|nf-cell-border>>
281   <assign|nf-cell-bottom-border|<value|nf-cell-no-border>>
283   <assign|nf-cell-right-border|<value|nf-cell-border>>
285   <\active*>
286     <\src-comment>
287       DEPRACATED: nf-framed-fragment defines the listing to be rendered in a
288       table with a single cell.
289     </src-comment>
290   </active*>
292   <assign|nf-framed-table|<macro|x|<with|color|dark
293   grey|<tformat|<twith|table-width|1par>|<cwith|1|-1|1|-1|cell-hyphen|t>|<cwith|1|-1|1|-1|cell-bsep|1spc>|<cwith|1|-1|1|-1|cell-tsep|1spc>|<cwith|1|-1|1|-1|cell-background|white>|<cwith|1|-1|1|-1|cell-lborder|<value|nf-cell-left-border>>|<cwith|1|-1|1|-1|cell-rborder|<value|nf-cell-right-border>>|<cwith|1|-1|1|-1|cell-bborder|<value|nf-cell-bottom-border>>|<cwith|1|-1|1|-1|cell-tborder|<value|nf-cell-top-border>>|<arg|x>>>>>
295   <\active*>
296     <\src-comment>
297       DEPREACTED: nf-framed-fragment defines the listing to be rendered in a
298       table with a single cell.\ 
300       As we currently use \<less\>wide-underlined\<gtr\> or
301       \<less\>wide-bothlined\<gtr\> to draw the lines this is done on lines
302       before and after the listing by underlining the header and a following
303       blank line, so nf-framed-fragment is currently null.
304     </src-comment>
305   </active*>
307   <assign|nf-framed-fragment-old|<macro|x|<nf-framed-table|<tformat|<table|<row|<\cell>
308     <with|color|black|<arg|x>>
309   </cell>>>>>>>
311   <assign|nf-framed-fragment|<macro|x|<arg|x>>>
313   <\active*>
314     <\src-comment>
315       This is how top and bottom borders are drawn using solid or jagged
316       lines - it needs reworking, its a horrid hack with repeated code. \ 
317     </src-comment>
318   </active*>
320   <assign|nf-jag-top|<macro|<with|gr-geometry|<tuple|geometry|0.25fn|1fn>|gr-mode|<tuple|edit|line>|gr-frame|<tuple|scale|1cm|<tuple|0gw|1gh>>|gr-line-width|0.5ln|<graphics||<line|<point|0gw|-0.4gh>|<point|0.5gw|-0.25gh>|<point|1gw|-0.4gh>>>>>>
322   <assign|nf-jag-bottom|<macro|<with|gr-geometry|<tuple|geometry|0.25fn|1bls>|gr-mode|<tuple|edit|line>|gr-frame|<tuple|scale|1cm|<tuple|0gw|1gh>>|gr-line-width|1ln|<graphics||<line|<point|0gw|0.5gh>|<point|0.5gw|0.35gh>|<point|1gw|0.5gh>>>>>>
324   <assign|nf-jags-top|<macro|x|<repeat|<arg|x>|<nf-jag-top>>>>
326   <assign|nf-jags-bottom|<macro|x|<repeat|<arg|x>|<nf-jag-bottom>>>>
328   <assign|nf-jagit-top|<macro|body|<datoms|<macro|x|<nf-jags-top|<arg|x>>>|<surround||<htab|5mm*|last><vspace*|1sep>|<arg|body>>>>>
330   <assign|nf-jagit-bottom|<macro|body|<datoms|<macro|x|<nf-jags-bottom|<arg|x>>>|<surround||<htab|5mm*|last><vspace*|1sep>|<arg|body>>>>>
332   <assign|nf-top-border-line|<macro|body|<wide-underlined|<value|nf-cell-border>|1ln|<arg|body>>>>
334   <assign|nf-top-border-jags|<macro|body|<nf-jagit-top|<arg|body>>>>
336   <assign|nf-top-border-true|<macro|body|<nf-top-border-line|<arg|body>>>>
338   <assign|nf-top-border-false|<macro|body|<nf-top-border-jags|<arg|body>>>>
340   <assign|nf-top-border|<macro|first|body|<compound|<merge|nf-top-border-|<arg|first>>|<arg|body>>>>
342   <assign|nf-bottom-border-line|<macro|body|<wide-bothlined|<value|nf-cell-border>|0ln|1ln|0ln|<arg|body>>>>
344   <assign|nf-bottom-border-jags|<macro|body|<nf-jagit-bottom|<arg|body>>>>
346   <assign|nf-bottom-border-true|<macro|body|<nf-bottom-border-line|<arg|body>>>>
348   <assign|nf-bottom-border-false|<macro|body|<nf-bottom-border-jags|<arg|body>>>>
350   <assign|nf-bottom-border|<macro|first|body|<compound|<merge|nf-bottom-border-|<arg|first>>|<arg|body>>>>
352   <\active*>
353     <\src-comment>
354       prog-f renders a body in prog mode with specified language and without
355       a ghastly par-par-sep
356     </src-comment>
357   </active*>
359   <assign|prog-f|<macro|lang|body|<with|mode|prog|prog-language|<arg|lang>|<with|par-par-sep|0fn|<arg|body>>>>>
361   <\active*>
362     <\src-comment>
363       nf-border-if takes a boolean and then returns a correct width to show
364       (or not show) a border -- either as a table sell or a wide-underlined
365     </src-comment>
366   </active*>
368   <assign|nf-border-if|<macro|x|<if|<arg|x>|<value|nf-cell-border>|<value|nf-cell-no-border>>>>
370   <\active*>
371     <\src-comment>
372       ???prog-fragment is the top level macro used for rendering a listing
373       (without line numbers). It renders prog-f within a framed fragment.
374     </src-comment>
375   </active*>
377   <assign|prog-fragment|<\macro|name|lang|x>
378     <with|nf-cell-top-border|<nf-border-if|<compound|nf-first-chunklet?|<arg|name>>>|nf-cell-bottom-border|<nf-border-if|<nf-last-chunklet?|<arg|name>>>|<nf-framed-fragment|<compound|prog-f|<arg|lang>|<arg|x>>>>
379   </macro>>
381   <assign|nf-pf|<macro|name|lang|x|<nf-framed-fragment|<prog-f|<arg|lang>|<arg|x>>>>>
383   <\active*>
384     <\src-comment>
385       ???Numbering the listing
386     </src-comment>
387   </active*>
389   <assign|nflp|<macro|x|<arg|x>>>
391   <\active*>
392     <\src-comment>
393       nf-chunk counts the chunks on a page and is reset each time we detect a
394       new page
395     </src-comment>
396   </active*>
398   <new-counter|nf-chunk>
400   <new-counter|<nf-id|nf-chunk>>
402   <\active*>
403     <\src-comment>
404       The noweb format that we follow names listings after the page number
405       followed by an alpha-counter that is reset on each page; e.g. 12a then
406       12b, 12c and then on page 13 back to 13a
408       As there is no trigger called on a new page that can help us, we
409       instead store the page number as we process each chunk so that we can
410       tell when a chunk is on a different page to the previous chunk --- in
411       order to reset the alpha-counter.
412     </src-comment>
413   </active*>
415   <assign|nf-page|0>
417   <\active*>
418     <\src-comment>
419       Chunks have a name which is provided by the user, but more than one
420       chunk can have the same name. These are called chunklets of the same
421       chunk.
423       Although chunklets have the same name, they have a different id, which
424       is the name with a specified prefix, and a suffix which is the chunklet
425       sequence number.
427       nf-chunk-id computes a chunk id from a fixed "code-" namespace, a
428       supplied "tag" namespace name, the name and the chunklet number
429     </src-comment>
430   </active*>
432   <assign|joinz|<macro|n|j|x|<if|<less|<arg|n>|<length|<arg|x>>>|<if|<greater|<arg|n>|0>|<arg|j>><look-up|<arg|x>|<arg|n>><joinz|<plus|<arg|n>|1>|<arg|j>|<arg|x>>>>>
434   <assign|join-args|<xmacro|x|<joinz|0|<arg|x|0>|<map-args|identity|tuple|x|1>>>>
436   <assign|ns-id|<xmacro|x|<quasi|<join-args|:|<unquote*|<quote-arg|x>>>>>>
438   <assign|nf-id-|<macro|x|<merge|<if|<and|<provides|fake-page-base-name>|<greater|<length|<value|fake-page-base-name>>|0>>|<quasi|<ns-id|<value|fake-page-base-name>|<unquote*|<quote-arg|x>>>>|<quasi|<ns-id|<unquote*|<quote-arg|x>>>>>>>>
440   <assign|nf-id|<xmacro|x|<quasi|<nf-id-|<unquote|<map-args|identity|tuple|x>>>>>>
442   <assign|nf-chunk-id|<macro|name|tag|n|<nf-id|code|<merge|<arg|tag>|-|<arg|name>|-|<arg|n>>>>>
444   \;
446   <assign|zip-|<macro|t|<quasi|<tuple|<unquote*|<quote-arg|t>>>>>>
448   <assign|zip|<xmacro|x|<quasi|<zip-|<unquote|<map-args|identity|tuple|x>>>>>>
450   <assign|zip|<xmacro|x|<zip-|<map-args|identity|tuple|x>>>>
452   <\active*>
453     <\src-comment>
454       nf-this-chunk-id is a convenience that uses the counter for the current
455       chunklet. (Each chunk has it's own counter to count it's chunklets)
457       ???Possibly unquote should be used by the called and not here
458     </src-comment>
459   </active*>
461   <assign|nf-this-chunk-id|<macro|name|tag|<nf-chunk-id|<arg|name>|<arg|tag>|<compound|<merge|the-|<unquote|<nf-id|code|chunk|<arg|name>>>>>>>>
463   <\active*>
464     <\src-comment>
465       Simple way to discover if we are processing the first chunklet of a
466       named chunk - by checking it's chunklet counter.
467     </src-comment>
468   </active*>
470   <assign|nf-first-chunklet?|<macro|name|<equal|<compound|<merge|the-|<unquote|<nf-id|code|chunk|<arg|name>>>>>|1>>>
472   <\active*>
473     <\src-comment>
474       Simple way to discover if we are processing the last chunklet of a
475       named chunk - by checking if there is a chunklet with an increased
476       counter
477     </src-comment>
478   </active*>
480   <assign|nf-last-chunklet?|<macro|name|<not|<nf-chunklet-exists?|<nf-next-chunk-id|<arg|name>>>>>>
482   <\active*>
483     <\src-comment>
484       Simple way to discover if a chunklet (probably) exists - which is
485       needed to know if we should show a forward reference to the next
486       chunklet. As each chunklet defines a label, we just need to check if
487       there is a pageref to that label.
488     </src-comment>
489   </active*>
491   <assign|nf-chunklet-exists?|<macro|id|<ispageref?|<arg|id>>>>
493   <\active*>
494     <\src-comment>
495       nf-nav renders the links to the previous and next chunklets of this
496       chunk (if they exist).
498       Looks like this: <math|\<vartriangleleft\>>7b
499       7d<math|\<vartriangleright\>>
500     </src-comment>
501   </active*>
503   <assign|nf-prev-chunk-id|<macro|name|<nf-chunk-id|<arg|name>|ref|<minus|<compound|<merge|the-|<unquote|<nf-id|code|chunk|<arg|name>>>>>|1>>>>
505   <assign|nf-next-chunk-id|<macro|name|<nf-chunk-id|<arg|name>|ref|<plus|<compound|<merge|the-|<unquote|<nf-id|code|chunk|<arg|name>>>>>|1>>>>
507   <assign|fangle-nav-left|<math|\<vartriangleleft\>>>
509   <assign|fangle-nav-up|<math|\<vartriangle\>>>
511   <assign|fangle-nav-down|<math|\<triangledown\>>>
513   <assign|fangle-nav-right|<math|\<vartriangleright\>>>
515   <assign|render-fangle-nav|<style-with|src-compact|none|<macro|<style-with|src-compact|all|<if|<not|<equal|<length|<value|prev_label>>|0>>|<value|prev><value|prev_label>><style-with|src-compact|all|<if|<not|<equal|<length|<value|next_label>>|0>>|
516   <value|next_label><value|next>>>>>>>
518   <assign|fangle-nav|<style-with|src-compact|none|<\macro|name>
519     <with|prev|<if|<equal|<pagerefpage|<nf-prev-chunk-id|<arg|name>>>|<pagerefpage|<nf-this-chunk-id|<arg|name>|label>>>|<fangle-nav-up>|<fangle-nav-left>>|prev_label|<if|<not|<nf-first-chunklet?|<arg|name>>>|<reference|<nf-prev-chunk-id|<arg|name>>>>|next|<if|<not|<nf-last-chunklet?|<arg|name>>>|<if|<equal|<pagerefpage|<nf-next-chunk-id|<arg|name>>>|<pagerefpage|<nf-this-chunk-id|<arg|name>|label>>>|<fangle-nav-down>|<fangle-nav-right>>>|next_label|<if|<not|<nf-last-chunklet?|<arg|name>>>|
520     <reference|<nf-next-chunk-id|<arg|name>>>>|<render-fangle-nav>>
522     <style-with|src-compact|all|>
523   </macro>>>
525   <assign|xnf-nav|<style-with|src-compact|none|<macro|name|<style-with|src-compact|all|<if|<not|<nf-first-chunklet?|<arg|name>>>|<if|<equal|<pagerefpage|<nf-prev-chunk-id|<arg|name>>>|<pagerefpage|<nf-this-chunk-id|<arg|name>|label>>>|<fangle-nav-up>|<fangle-nav-left>><reference|<nf-prev-chunk-id|<arg|name>>>>><if|<nf-chunklet-exists?|<nf-next-chunk-id|<arg|name>>>|
526   <reference|<nf-next-chunk-id|<arg|name>>><if|<equal|<pagerefpage|<nf-next-chunk-id|<arg|name>>>|<pagerefpage|<nf-this-chunk-id|<arg|name>|label>>>|<fangle-nav-down>|<fangle-nav-right>>>>>>
528   <\active*>
529     <\src-comment>
530       nf-header renders the single line header before the listing. It lists
531       the reference of this chunk which is the-label (already estiablished by
532       nf-chunk-init) along with the chunk name and language, the chunklet
533       number and a reference to the first chunklet with the same name, and
534       also the chunklet navigation.
536       Like this:\ 
537     </src-comment>
538   </active*>
540   <assign|render-fangle-header|<macro|name|lang|args|<shift|<resize|<specific-verbatim|\<#000A\>><value|chunk_label>
541   |||0fn|>|-2.0fn|><nv-langle><with|color|blue|<arg|name>>[<value|chunk_no><style-with|src-compact|none|]><if|<not|<equal|<value|chunk_no>|1>>|<if|<not|<equal|<length|<arg|args>>|0>>|(<with|nf-render-commas|<macro|x|<arg|x>>|<nf-commas|<arg|args>>>)>
542   <math|\<Uparrow\>><value|first_chunk_label>|(<nf-commas|<arg|args>>)>,
543   lang=<with|color|blue|<arg|lang>><nv-rangle>
544   <math|<if|<not|<equal|<value|chunk_no>|1>>|+>\<equiv\>>>>
546   <drd-props|render-fangle-header|accessible|all>
548   <assign|if-provides|<macro|x|<if|<provides|<arg|x>>|<arg|x>>>>
550   <assign|fangle-header|<macro|name|lang|args|<render-fangle-header|<arg|name>|<arg|lang>|<arg|args>|<if-provides|<compound|<merge|the-code-chunk-|<unquote|<arg|name>>>>>|<value|the-label>>>>
552   <assign|draw-fangle-header|<macro|name|lang|args|chunk_no|chunk_label|first_chunk_label|prev|prev_label|next|next_label|<with|name|<arg|name>|lang|<arg|lang>|args|<arg|args>|chunk_no|<arg|chunk_no>|chunk_label|<arg|chunk_label>|first_chunk_label|<arg|first_chunk_label>|prev|<arg|prev>|prev_label|<arg|prev_label>|next_label|<arg|next_label>|next|<arg|next>|<render-fangle-header><htab|0pt><render-fangle-nav>>>>
554   <assign|nf-pad|<macro|w|<if|<not|<less|<arg|w>|1>>|
555   <nf-pad|<minus|<arg|w>|1>>>>>
557   <assign|nf-header|<macro|name|lang|args|<shift|<resize|<specific-verbatim|\<#000A\>><value|the-label>
558   |||0fn|>|-2.0fn|><nv-langle><with|color|blue|<arg|name>>[<compound|<merge|the-code-chunk-|<unquote|<arg|name>>>><style-with|src-compact|none|]><if|<not|<nf-first-chunklet?|<arg|name>>>|<if|<not|<equal|<value|<merge|code-args-|<unquote|<arg|name>>>>|<uninit>>>|(<with|nf-render-commas|<macro|x|<arg|x>>|<nf-commas|<value|<merge|code-args-|<unquote|<arg|name>>>>>>)>
559   <math|\<Uparrow\>><reference|<nf-chunk-id|<arg|name>|ref|1>>|(<nf-commas|<arg|args>>)>,
560   lang=<with|color|blue|<arg|lang>><nv-rangle>
561   <math|<if|<not|<nf-first-chunklet?|<arg|name>>>|+>\<equiv\>><htab|0pt><fangle-nav|<arg|name>>>>
563   <assign|nf-header|<macro|name|lang|args|<quasi|<with|chunk_label|<value|the-label>|chunk_no|<compound|<merge|the-|<nf-id|code|chunk|<unquote|<arg|name>>>>>|first_chunk_label|<reference|<nf-chunk-id|<arg|name>|ref|1>>|<fangle-header|<arg|name>|<arg|lang>|<if|<not|<equal|<value|<nf-id|code|args|<arg|name>>>|<uninit>>>|<nf-commas|<value|<nf-id|code|args|<arg|name>>>>|<arg|args>>><htab|0pt><xnf-nav|<arg|name>>>>>>
565   <assign|nf-render-commas|<macro|x|<with|color|blue|<arg|x>>>>
567   <assign|nf-commas|<macro|items|<if|<equal|<get-label|<arg|items>>|tuple>|<if|<less|<length|<arg|items>>|1>|<arg|items><specific-verbatim|\<#000B\>>|<nf-render-commas|<look-up|<arg|items>|0>><if|<greater|<length|<arg|items>>|1>|<specific-verbatim|\<#000B\>>,
568   <nf-commas|<range|<arg|items>|1|<length|<arg|items>>>>|<specific-verbatim|\<#000B\>>>>|<arg|items><if|<not|<equal|<length|<arg|items>>|0>>|<specific-verbatim|\<#000B\>>>>>>
570   <drd-props|nf-commas|accessible|all>
572   <assign|nf-commaxy|<macro|x|, (<arg|x>)>>
574   <assign|nf-commax|<xmacro|args|[<arg|args|0><map-args|nf-commaxy|concat|args|1>]>>
576   <assign|bla|<xmacro|args|<arg|args|0>:<arg|args|1>(<arg|args>)>>
578   <\active*>
579     <\src-comment>
580       nf-gather is an attempt to remember each named chunk so that it can
581       optionally be expanded in-place in other chunks. It's a poor attempt
582       and only works for forward uses. Such expansion should be compined with
583       over-brace or side-brace decoration of the included chunk, and also
584       requires that the inline continuation after the expanded chunk continue
585       from the baseline of the expanded chunk instead of the baseline before
586       the expanded chunk was included.
587     </src-comment>
588   </active*>
590   <assign|nf-gather|<macro|name|x|lang|<if|<provides|<arg|name>>|<assign|<unquote|<arg|name>>|<value|<arg|name>><unquote|<arg|x>>>|<assign|<unquote|<arg|name>>|<quote|<arg|x>>>>>>
592   <\active*>
593     <\src-comment>
594       nf-chunk-new is called by nf-chunk-init for the first chunklet of a
595       given chunk name - it defines a chunklet counter and a line number
596       counter
597     </src-comment>
598   </active*>
600   <assign|nf-chunk-new|<macro|name|args|<quasi|<new-counter|<unquote|<nf-id|code|chunk|<arg|name>>>><new-counter|<unquote|<nf-id|code|line|<arg|name>>>><assign|<unquote|<nf-id|code|item|<arg|name>>>|<macro|<compound|<unquote|<merge|next-|<nf-id|code|line|<arg|name>>>>><render-item|<compound|<unquote|<merge|the-|<nf-id|code|line|<arg|name>>>>>>>><compound|<merge|inc-|<nf-id|code|chunk|<arg|name>>>><assign|<unquote|<nf-id|code|args|<arg|name>>>|<arg|args>>><write|<nf-id|nf-chunk>|<tuple|<tuple|<arg|name>>|<reference|<nf-this-chunk-id|<arg|name>|ref>>>>>>
602   <\active*>
603     <\src-comment>
604       nf-chunk-next is called by nf-chunk-init for the additional chunklets
605       of a given chunk name. \ It increments the chunklet counter
606     </src-comment>
607   </active*>
609   <assign|nf-chunk-next|<macro|name|<compound|<merge|inc-|<nf-id|code|chunk|<arg|name>>>><write|<nf-id|nf-chunk>|<tuple|<tuple|<arg|name>>|<reference|<nf-this-chunk-id|<arg|name>|ref>>>>>>
611   <\active*>
612     <\src-comment>
613       nf-check-page uses the label defined in nf-chunk-label to get the
614       number of the page containing this chunk to compare to nf-page (the
615       number of the page containing the previous chunk) to see if this chunk
616       is the first chunk on a page. If so, then the nf-chunk alpha counter is
617       reset, otherwise it is increased.
618     </src-comment>
619   </active*>
621   <assign|nf-check-page|<macro|name|<if|<not|<equal|<nf-id|nf-page>|<pagerefpage|<nf-this-chunk-id|<arg|name>|label>>>>|<compound|<merge|reset-|<nf-id|nf-chunk>>><compound|<merge|inc-|<nf-id|nf-chunk>>><assign|<nf-id|nf-page>|<pagerefpage|<nf-this-chunk-id|<arg|name>|label>>>|<compound|<merge|inc-|<nf-id|nf-chunk>>>>>>
623   <\active*>
624     <\src-comment>
625       ???????? Review from here onwards
626     </src-comment>
627   </active*>
629   <\active*>
630     <\src-comment>
631       nf-chunk-ref defines labels and label text so that we can generate
632       references to chunklets in the form
633       \<less\>PAGENO\<gtr\>\<less\>the-nf-chunk\<gtr\> \ e.g. 17a then 17b
634       etc.
636       The label text is stored in the-chunk-label which is used by XXX. It
637       then creates a label (with the tag ref) of the form code-ref-NAME-NO
638       which is a bit long winded to use with \<less\>reference\|...\<gtr\>
639       and so \<less\>chunk-reference\|...\<gtr\> is provided to help.
641       The ref tagged label is to be used in preference to the label-tagged
642       label created in nf-chunk-label whose only purpose is to find out what
643       page a chunk starts on so that the chunk ref label can be created
644     </src-comment>
645   </active*>
647   <assign|nf-chunk-ref|<macro|name|<nf-check-page|<arg|name>><assign|the-chunk-label|<pagerefpage|<nf-this-chunk-id|<arg|name>|label>><number|<compound|<merge|the-|<nf-id|nf-chunk>>>|alpha>><assign|the-label|<value|the-chunk-label>><label|<nf-this-chunk-id|<arg|name>|ref>>>>
649   <\active*>
650     <\src-comment>
651       There seems to be no \<less\>specific\|...\<gtr\> tag for verbatim
652       exports, so we use specific-verbatim. The body is not visible except in
653       text exports.
654     </src-comment>
655   </active*>
657   <assign|specific-verbatim|<macro|x|<clipped|<arg|x>|0|0|0|0>>>
659   <\active*>
660     <\src-comment>
661       except-specific-verbatim is intended to output in all forms except
662       verbatim. This is used because some entities do not have a text
663       representation --- like \<less\>langle\<gtr\> and the fall-back
664       representation is ugly. This macro does not work in page headers, the
665       \<less\>if*\|false\|body\<gtr\> fails to leave the correct space
666     </src-comment>
667   </active*>
669   <assign|except-specific-verbatim|<macro|body|<specific|screen|<arg|body>><specific|printer|<arg|body>><if*|false|<arg|body>>>>
671   <\active*>
672     <\src-comment>
673       nv-langle-subst and lv-rangle-subst define characters that should be
674       output in verbatim mode instead of langle and rangle which would
675       otherwise be output as the literal text rangle and langle
676     </src-comment>
677   </active*>
679   <assign|nv-langle-subst|\<less\>>
681   <assign|nv-rangle-subst|\<gtr\>>
683   <\active*>
684     <\src-comment>
685       nv-langle and nv-rangle are macros that can be used to generate a
686       langle and rangle exceot in text mode were they use the subst
687       characters \<less\> and \<gtr\>
688     </src-comment>
689   </active*>
691   <assign|nv-langle|<macro|<except-specific-verbatim|<with|mode|math|<left|langle>>><specific-verbatim|<value|nv-langle-subst>>>>
693   <assign|nv-rangle|<macro|<except-specific-verbatim|<with|mode|math|<right|rangle>>><specific-verbatim|<value|nv-rangle-subst>>>>
695   <\active*>
696     <\src-comment>
697       nv-render-line-no renders the line numbers for listings in a way that
698       is suitable for typeset and also verbatim export.
699     </src-comment>
700   </active*>
702   <assign|nf-render-line-no|<macro|x|<with|mode|text|par-mode|right|<with|font-family|tt|<with|font-base-size|6|<specific-verbatim|<nf-pad|<minus|3|<length|<value|item-nr>>>>><aligned-space-item|<arg|x>><specific-verbatim|\|
703   >>>><nf-bar>>>
705   <\active*>
706     <\src-comment>
707       A chunklabel is of the form [chunkaname chunkno] e.g. [main.c 1] but
708       it's main purpose is not decorative or visual but as a means to
709       discover the page number containing this chunk so that it can be used
710       by nf-chunk-ref.
711     </src-comment>
712   </active*>
714   <assign|nf-chunk-label|<macro|name|<assign|nf-last-chunk|<arg|name>><assign|the-label|[<arg|name>
715   <compound|<merge|the-code-chunk-|<unquote|<arg|name>>>>]><label|<nf-this-chunk-id|<arg|name>|label>>>>
717   <\active*>
718     <\src-comment>
719       nf-chunk-init is called at the start of nf-chunk to create all
720       neccessary counters and labels. The
721       \<less\>provides\|\<less\>merge\|code-chunk-\|\<less\>unquote\|name\<gtr\>\|-nr\<gtr\>\<gtr\>
722       test could be replaced by some more canonical way to discover if a
723       chunk or chunk counter is defined. It's old code and I don't want to
724       change it now.
725     </src-comment>
726   </active*>
728   <assign|nf-chunk-init|<macro|name|args|<quasi|<with|<unquote|<nf-id|nf-same-chunk>>|<equal|<value|<unquote|<nf-id|nf-last-chunk>>>|<arg|name>>|<if|<not|<provides|<unquote|<merge|<nf-id|code|chunk|<arg|name>>|-nr>>>>|<nf-chunk-new|<arg|name>|<arg|args>>|<nf-chunk-next|<arg|name>>><nf-chunk-label|<arg|name>><nf-chunk-ref|<arg|name>><assign|<unquote|<nf-id|nf-continues>>|<and|<value|<unquote|<nf-id|nf-same-chunk>>>|<not|<equal|<number|<unquote|<compound|<merge|the-|<nf-id|nf-chunk>>>>|alpha>|a>>>>>>>>
730   <\active*>
731     <\src-comment>
732       nf-chunk-outit is called at the end of nf-chunk mainly to create a
733       label so that we can see if the chunk ended on the same page it began.\ 
734     </src-comment>
735   </active*>
737   <assign|nf-chunk-outit|<macro|name|<label|<nf-this-chunk-id|<arg|name>|end>>>>
739   <\active*>
740     <\src-comment>
741       These macros output either a solid line ________ or a torn-paper-line
742       /\\/\\/\\ at the top and bottom of listins in verbatim mode, to signify
743       if the chunk continues or ends with this chunklet
744     </src-comment>
745   </active*>
747   <assign|nf-jags|<macro|<datoms|<macro|x|<repeat|<arg|x>|<with|gr-geometry|<tuple|geometry|2mm|5mm|center>|gr-mode|<tuple|edit|line>|gr-frame|<tuple|scale|1cm|<tuple|0.589991gw|0.5gh>>|<graphics||<line|<point|0mm|0mm>|<point|1mm|1mm>|<point|2mm|0mm|>>>>>>|<htab|5mm*|last>>>>
749   <assign|nf-bar|<macro|>>
751   <assign|nf-barx|<macro|<merge|<times|<value|font-base-size>|<value|font-size>>|pt><with|gr-geometry|<tuple|geometry|2mm|<merge|<times|<value|font-base-size>|<value|font-size>|1>|pt>|center>|gr-mode|<tuple|edit|line>|line-width|8ln|<graphics||<line|<point|0mm|0mm>|<point|0mm|30pt>>>>>>
753   <assign|nf-verbatim-top|<macro|new|<if|<arg|new>|<specific-verbatim|
754   \ \ \ \ \ ________________________________________________________________________>|<specific-verbatim|
755   \ \ \ \ ./\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\>>>>
757   <assign|nf-verbatim-bottom|<macro|new|<if|<arg|new>|<specific-verbatim|
758   \ \ \ \ \|________________________________________________________________________>|<specific-verbatim|
759   \ \ \ \ \|/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\>>>>
761   <\active*>
762     <\src-comment>
763       nf-chunk is the first public macro. It shows a named listing with all
764       the trimmings.\ 
766       We used to disable the full header if previous chunk on this page had
767       same name and this is not the first chunk on a page
768     </src-comment>
769   </active*>
771   <assign|nf-use-page-header|<macro|h|<set-this-page-header|<value|page-even-header>>>>
773   <assign|nf-use-page-header|<macro|h|<set-this-page-header|<arg|h>>>>
775   <assign|nf-chunk|<macro|name|x|lang|args|<with|the-label||<small|<surround|<aligned-space-item|><nf-chunk-init|<arg|name>|<arg|args>><wide-underlined|<nf-border-if|<nf-first-chunklet?|<arg|name>>>|1ln|<no-page-break*><label|<arg|name>><small|<nf-header|<arg|name>|<arg|lang>|<arg|args>>><no-page-break>>|<if|<nf-last-chunklet?|<arg|name>>|<wide-bothlined|<nf-border-if|<nf-last-chunklet?|<arg|name>>>|0ln|1ln|0ln|<if|<nf-first-chunklet?|<arg|name>>|<nf-show-used-by|<arg|name>>><htab|5mm*|last>>|<if|<nf-first-chunklet?|<arg|name>>|<nf-show-used-by|<arg|name>>>>|<\with|item|<value|<unquote|<nf-id|code|item|<arg|name>>>>|item-vsep|0fn|current-item|<value|nf-render-line-no>|transform-item|<value|identity>>
776     <\surround||<nf-chunk-outit|<arg|name>><if|<and|<not|<equal|<value|<nf-id|nf-page>>|<pagerefpage|<nf-this-chunk-id|<arg|name>|end>>>>|<ispageref?|<nf-this-chunk-id|<arg|name>|end>>>|<nf-use-page-header|<with|nv-langle|<macro|<with|mode|math|<left|langle>>>|nv-rangle|<macro|<with|mode|math|<right|rangle>>>|<small|<nf-header|<arg|name>|<arg|lang>|<arg|args>>>>>>>
777       <no-page-break><nf-verbatim-top|<nf-first-chunklet?|<arg|name>>>
779       <with|nv-langle-subst|\S|nv-rangle-subst|\T|nf-current-chunk|<arg|name>|<nf-pf|<arg|name>|<arg|lang>|<arg|x>>>
781       <no-page-break*><if|<nf-last-chunklet?|<arg|name>>|<assign|<merge|<nf-id|code|line|<arg|name>>|-nr>|0>><nf-verbatim-bottom|<nf-last-chunklet?|<arg|name>>>
782     </surround>
783   </with>>>>>>
785   <assign|nf-fake-chunk|<macro|name|x|lang|args|chunk_no|chunk_label|chunk_first_label|prev|prev_label|next|next_label|line-no|<with|the-label||xnv-langle-subst||xnv-rangle-subst||nf-name|<unquote|<arg|name>>|chunk_no|<arg|chunk_no>|chunk_label|<arg|chunk_label>|first_chunk_label|<arg|chunk_first_label>|prev|<arg|prev>|prev_label|<arg|prev_label>|next|<arg|next>|next_label|<arg|next_label>|<small|<surround|<aligned-space-item|><wide-underlined|<nf-border-if|<equal|<value|chunk_no>|1>>|1ln|<no-page-break*><small|<render-fangle-header|<arg|name>|<arg|lang>|<arg|args>><htab|0pt><render-fangle-nav>><no-page-break>>|<if|<equal|<length|<value|next>>|0>|<wide-bothlined|<nf-border-if|<equal|<length|<value|next>>|0>>|0ln|1ln|0ln|<htab|5mm*|last>>|<nf-jags>>|<\with|xitem|<arg|line-no>|item-nr|0|item-vsep|0fn|current-item|<value|nf-render-line-no>|transform-item|<value|identity>>
786     <no-page-break><nf-verbatim-top|<nf-first-chunklet?|<value|nf-name>>>
788     <with|nv-langle-subst|\S|nv-rangle-subst|\T|<nf-pf|<value|nf-name>|<arg|lang>|<arg|x>>>
790     <no-page-break*><if|<nf-last-chunklet?|<value|nf-name>>|<assign|<merge|code-line-|<value|nf-name>|-nr>|0>><nf-verbatim-bottom|<nf-last-chunklet?|<value|nf-name>>>
791   </with>>>>>>
793   <new-list|nfl|<value|aligned-dot-item>|<value|identity>>
795   <drd-props|nf-chunk|accessible|all>
797   <drd-props|nf-fake-chunk|accessible|all>
799   <assign|nf-comment|<macro|x|<with|mode|text|<specific-verbatim|/*
800   ><arg|x><specific-verbatim| */>>>>
802   <\active*>
803     <\src-comment>
804       nf-ref is the second public macro. It may be inserted into a chunk
805       listing to signify that another listing should be included at that
806       point. As \\ doesn't work in listings you'll have to type meta-\\ \ 
808       This will become an xmacro or something so that it can take optional
809       arguments (like C macros) which will be expanded when the programs are
810       extracted.
811     </src-comment>
812   </active*>
814   <assign|nf-ref|<style-with|src-compact|none|<macro|name|args|<if|<and|<provides|nf-current-chunk>|<not|<equal|<uninit>|<value|nf-current-chunk>>>|<not|<equal|?|<value|nf-current-chunk>>>>|<nf-used-by-chunk|<arg|name>|<nf-chunk-id|<value|nf-current-chunk>|ref|1>><write|nf-chunk|<tuple|<tuple|<arg|name>|Used
815   by>|<reference|<nf-chunk-id|<value|nf-current-chunk>|ref|1>>>>|<auto-label><write|nf-chunk|<tuple|<tuple|<arg|name>|Mentioned>|<nf-render-used-by|<the-auto>>>>><nv-langle><arg|name><if|<and|<or|<equal|<get-label|<arg|args>>|tuple>|<equal|<get-label|<arg|args>>|string>>|<greater|<length|<arg|args>>|0>>|<specific-verbatim|\<#000B\>>(<if|<equal|<get-label|<arg|args>>|tuple>|<nf-commas|<arg|args>>|<with|color|blue|<arg|args>>>)|<phantom|(><arg|args>>
816   <reference|<nf-chunk-id|<arg|name>|ref|1>><nv-rangle><flag|<arg|name>|red><if|<equal|0|1>|<compound|<quote-arg|name>>>>>>
818   <assign|nf-fake-ref|<style-with|src-compact|none|<macro|name|args|ref|<nv-langle><arg|name><if|<equal|<get-label|<arg|args>>|tuple>|<specific-verbatim|\<#000B\>>(<nf-commas|<arg|args>>)>
819   <arg|ref><nv-rangle><flag|<arg|name>|red><if|<equal|0|1>|<compound|<quote-arg|name>>>>>>
821   <drd-props|nf-ref|accessible|all>
823   <drd-props|nf-fake-ref|accessible|all>
825   <assign|nf-render-used-by|<macro|x|<reference|<arg|x>> (<localize|page>
826   <pageref|<arg|x>>)>>
828   <assign|nf-used-by-chunk|<macro|name|<write|nf-chunk|<tuple|<tuple|<arg|name>|Used
829   by>|<reference|<nf-chunk-id|<value|nf-current-chunk>|ref|1>>>>>>
831   <assign|nf-put|<macro|name|value|<with|the-label|<arg|value>|<label|<arg|name>>>>>
833   <assign|nf-get|<macro|name|<get-binding|<arg|name>|0>>>
835   <assign|nf-ping-old|<macro|name|<if|<not|<provides|<merge|old-|<arg|name>>>>|<assign|<merge|old-|<arg|name>>|<get-binding|<arg|name>|0>>>>>
837   <assign|nf-used-by-chunk|<macro|name|used|<nf-ping-old|<merge|nf-code-use-|<arg|name>>><with|uses|<value|<merge|nf-code-use-|<arg|name>>>|<if|<not|<equal|<get-label|<value|uses>>|tuple>>|<assign|<merge|nf-code-use-|<arg|name>>|<tuple|<arg|used>>>|<if|<not|<equal|<look-up|<value|<merge|nf-code-use-|<arg|name>>>|<minus|<length|<value|<merge|nf-code-use-|<arg|name>>>>|1>>|<arg|used>>>|<assign|<merge|nf-code-use-|<arg|name>>|<merge|<value|<merge|nf-code-use-|<arg|name>>>|<tuple|<arg|used>>>>>><nf-put|<merge|nf-code-use-|<arg|name>>|<value|<merge|nf-code-use-|<arg|name>>>>>>>
839   <assign|nf-show-used-by|<macro|name|<nf-ping-old|<merge|nf-code-use-|<arg|name>>><with|uses|<value|<merge|old-nf-code-use-|<arg|name>>>|<if|<equal|<get-label|<value|uses>>|tuple>|Used
840   by <nf-render-used-by|<value|uses>>|<smaller|not used>>>>>
842   <assign|render-join|<xmacro|args|<with|join|<arg|args|0>|render|<arg|args|1>|render-join|<macro|x|<value|join><compound|<value|render>|<arg|x>>>|<compound|<value|render>|<arg|args|2>><map-args|render-join|concat|args|3>>>>
844   <assign|nf-render-used-by|<macro|t|with|render|<quasi|<render-join|,
845   |reference|<unquote*|<arg|t>>>>>>
847   <\active*>
848     <\src-comment>
849       nf-quote causes literal text to be included in a new language mode -
850       it's main task is to do some of the horrid nested quoting that some
851       languages require.
853       For instance to match a backslash in a gsub regex in awk requires 4
854       back slashes - first quote the single backslash for the regex which
855       makes two backslashes, and then quote each of those for the string
856       argument to gsub
857     </src-comment>
858   </active*>
860   <assign|output-mode?|<macro|<assign|output-mode|unknown><specific|screen|<assign|output-mode|typeset>><specific|html|<assign|output-mode|export>>>>
862   <assign|nf-text-render-typeset|<macro|x|mode|submode|<math|<wide|<text|<verbatim|<arg|x>>>|\<wide-overbrace\>><rsup|<arg|mode>:<arg|submode>>>>>
864   <assign|nf-text-render-export|<macro|x|mode|submode|<nv-langle><arg|mode>:<arg|submode>:<arg|x><nv-rangle>>>
866   <assign|nf-text|<macro|x|mode|submode|<output-mode?><compound|<merge|nf-text-render-|<value|output-mode>>|<arg|x>|<arg|mode>|<arg|submode>>>>
868   <drd-props|nf-text|accessible|all>
870   <\active*>
871     <\src-comment>
872       nf-arg is a public macro. It will be replaced by the value of the chunk
873       argument when the code is extracted.
875       I really want to use \<less\>with\|nv-langle\|${\<gtr\> etc, but
876       evaluation of this is deferred until afterwards or something
877     </src-comment>
878   </active*>
880   <assign|nf-arg|<macro|name|<with|nv-langle-subst||nv-rangle-subst||<nv-langle><specific-verbatim|${><with|color|dark
881   green|<with|prog-font-shape|italic|<arg|name>>><specific-verbatim|}><nv-rangle>>>>
883   <\active*>
884     <\src-comment>
885       chunk-reference takes the chunks name and chunklet number and returns a
886       regular reference - like \<less\>reference\|\<gtr\> but calculates the
887       id for you.
888     </src-comment>
889   </active*>
891   <assign|chunk-reference|<macro|name|n|<reference|<nf-chunk-id|<arg|name>|ref|<arg|n>>>>>
893   <assign|chunk-page-reference|<macro|name|n|<pageref|<nf-chunk-id|<arg|name>|ref|<arg|n>>>>>
895   <assign|chunk-page-reference-page|<macro|name|n|<pagerefpage|<nf-chunk-id|<arg|name>|ref|<arg|n>>>>>
897   <\active*>
898     <\src-comment>
899       One day nf-tab will manage proper tab stops and emit a literal TAB
900       character in text mode.
902       Until then, it equals 8 spaces and the sequence 0xE2 0x86 0xA6 must be
903       converted to a tab during untangling
905       nf-untab will output 0xE2 0x86 0xA4 and is a hack; during untanging
906       [[:space:]]*0xE2 0x86 0xA4 will be deleted. This is useful for
907       removeing the indent of here documents in bash scripts
908     </src-comment>
909   </active*>
911   <assign|nf-tab-stop|8>
913   <assign|xafter|<specific-verbatim|\<#000A\> \ \ \ \<#221F\>>>
915   <assign|xnf-tab|<macro|<resize|\<#0009\><with|mode|math|\<mapsto\>>|||<merge|c+|<minus|<value|nf-tab-stop>|<mod|<value|nf-len>|<value|nf-tab-stop>>>|spc>|>>>
917   <assign|nf-tab|<macro|<resize|<with|mode|math|\<mapsto\>>|||8spc|>>>
919   <assign|nf-untab|<macro|<with|mode|math|\<mapsfrom\>>>>
921   <assign|nf-ht|<macro|<extern|(lambda () `(concat "[" ,(string #\\ht)
922   "]"))>>>
924   <\active*>
925     <\src-comment>
926       THIS is the NEW fangle
927     </src-comment>
928   </active*>
930   <assign|fangle-chunk-new|<macro|name|args|<quasi|<new-counter|<merge|code-chunk-|<unquote|<arg|name>>>><new-counter|<merge|code-line-|<unquote|<arg|name>>>><assign|<unquote|<merge|code-item-|<arg|name>>>|<macro|<compound|<unquote|<merge|next-code-line-|<arg|name>>>><render-item|<compound|<unquote|<merge|the-code-line-|<arg|name>>>>>>><compound|<merge|inc-code-chunk-|<unquote|<arg|name>>>><assign|<merge|code-args-|<unquote|<arg|name>>>|<arg|args>>>>>
932   <assign|fangle-chunk-init|<macro|name|args|<with|nf-same-chunk|<equal|<value|nf-last-chunk>|<arg|name>>|<if|<not|<provides|<merge|code-chunk-|<unquote|<arg|name>>|-nr>>>|<fangle-chunk-new|<arg|name>|<arg|args>>|<nf-chunk-next|<arg|name>>><nf-chunk-label|<arg|name>><nf-chunk-ref|<arg|name>><assign|nf-continues|<and|<value|nf-same-chunk>|<not|<equal|<number|<the-nf-chunk>|alpha>|a>>>>>>>
934   <assign|fangle-render-list|<\macro|body>
935     <\padded-normal|<item-vsep>|<item-vsep>>
936       <\indent-left|<item-hsep>>
937         <surround|<no-page-break*>|<no-indent*>|<arg|body>>
938       </indent-left>
939     </padded-normal>
940   </macro>>
942   <assign|fangle-list|<\macro|item-render|item-transform|body>
943     <\with|current-item|<arg|item-render>|transform-item|<arg|item-transform>|_item-nr|0>
944       <fangle-render-list|<arg|body>>
945     </with>
946   </macro>>
948   <assign|new-fangle|<\macro|name|lang|args>
949     <fangle-chunk-init|<arg|name>|<arg|args>><quasi|<style-with|src-compact|none|<assign|<arg|name>|<\macro|body>
950       <small|<with|item-vsep|0fn|item-nr|<value|<unquote|<merge|code-line-|<arg|name>|-nr>>>|<fangle-list|<value|nf-render-line-no>|<value|identity>|<prog-f|<unquote|<arg|lang>>|<arg|body>>>>>
951     </macro>>><drd-props|<unquote|<arg|name>>|arity|1|accessible|all>>
952   </macro>>
954   <assign|nf-chunkz|<macro|name|x|lang|args|<with|the-label||xnv-langle-subst||xnv-rangle-subst||nf-name|<unquote|<arg|name>>|y|<value|pob>|<small|<surround|<nf-chunk-init|<arg|name>|<arg|args>><wide-underlined|<nf-border-if|<nf-first-chunklet?|<value|nf-name>>>|1ln|<no-page-break*><label|<arg|name>><small|<nf-header|<arg|name>|<arg|lang>|<arg|args>>><no-page-break>>|<if|<nf-last-chunklet?|<value|nf-name>>|<wide-bothlined|<nf-border-if|<nf-last-chunklet?|<value|nf-name>>>|0ln|1ln|0ln|<htab|5mm*|last>>|<nf-jags>>|<\with|item|<value|<merge|code-item-|<unquote|<arg|name>>>>|item-vsep|0fn|current-item|<value|nf-render-line-no>|transform-item|<value|identity>>
955     <\surround||<nf-chunk-outit|<arg|name>><if|<and|<not|<equal|<value|nf-page>|<pagerefpage|<nf-this-chunk-id|<arg|name>|end>>>>|<ispageref?|<nf-this-chunk-id|<arg|name>|end>>>|<nf-use-page-header|<with|nv-langle|<macro|<with|mode|math|<left|langle>>>|nv-rangle|<macro|<with|mode|math|<right|rangle>>>|<small|<nf-header|<arg|name>|<arg|lang>|<arg|args>>>>>>>
956       <no-page-break><nf-verbatim-top|<nf-first-chunklet?|<value|nf-name>>>
958       <with|nv-langle-subst|\S|nv-rangle-subst|\T|<nf-pf|<value|nf-name>|<arg|lang>|<arg|x>>>
960       <no-page-break*><if|<nf-last-chunklet?|<value|nf-name>>|<assign|<merge|code-line-|<value|nf-name>|-nr>|0>><nf-verbatim-bottom|<nf-last-chunklet?|<value|nf-name>>>
961     </surround>
962   </with>>>>>>
964   \;
966   <assign|-xmake-tuple|<xmacro|x|<map-args|identity|tuple|x>>>
968   <assign|-make-tuple|<macro|x|<quasi|<xmake-tuple|<unquote*|<arg|x>>>>>>
970   <assign|-joiner|:>
972   <assign|-join|<macro|i|n|<if|<equal|<arg|n>|1>|<arg|i>|<merge|<value|joiner>|<arg|i>>>>>
974   <assign|-join-args|<xmacro|x|<assign|joiner|<arg|x|0>><map-args|join|merge|x|1>>>
976   <assign|-joinz|<macro|n|j|x|<if|<less|<arg|n>|<length|<arg|x>>>|<merge|<if|<greater|<arg|n>|1>|<arg|j>>|<arg|x|<arg|n>>|<joinz|<plus|<arg|n>|1>|<arg|j>|<arg|x>>>>>>
978   <assign|-joinz|<macro|n|j|x|<if|<less|<arg|n>|<length|<arg|x>>>|<if|<greater|<arg|n>|1>|<merge|<arg|j>|<arg|x|<arg|n>>|<joinz|<plus|<arg|n>|1>|<arg|j>|<arg|x>>>|<merge|<arg|x|<arg|n>>|<joinz|<plus|<arg|n>|1>|<arg|j>|<arg|x>>>>>>>
980   <assign|-make-tuple|<macro|x|<arg|x>>>
982   <assign|-joinz|<macro|n|j|x|<if|<less|<arg|n>|<length|<arg|x>>>|<make-tuple|<if|<greater|<arg|n>|0>|<arg|j>><look-up|<arg|x>|<arg|n>><joinz|<plus|<arg|n>|1>|<arg|j>|<arg|x>>>>>>
984   <assign|-join-args|<xmacro|x|<with|join|<macro|i|n|<if|<equal|<arg|n>|1>|<arg|i>|<merge|<value|joiner>|<arg|i>>>>|joiner|<arg|x|0>|<map-args|join|merge|x|1>>>>
986   <\active*>
987     <\src-comment>
988       Above doesn't work cos \<less\>with\|\<gtr\> breaks things so use this
989       version below
990     </src-comment>
991   </active*>
993   \;
994 </body>
996 <\initial>
997   <\collection>
998     <associate|page-medium|automatic>
999     <associate|page-screen-height|747264tmpt>
1000     <associate|page-screen-width|1267200tmpt>
1001     <associate|preamble|true>
1002   </collection>
1003 </initial>