NOWEB(1)
π NOWEB(1) π
General Commands Manual β noweb
okay bestie, sit down, hydrate, because this is the manual page for the noweb family: notangle, noweave, and nountangle. it's a lot but we're gonna get through it together π«Ά
β¨ NAME β¨
notangle, noweave, nountangle β noweb, a literate-programming tool π
β¨ SYNOPSIS β¨
notangle [-Rrootname ...] [-filter command] [-L[format]] [file] ...
nountangle [-ml|-m3|-c|-c++|-awk|-tex|-f77|-f90|-lisp|-matlab]
[-Rrootname ...] [-filter command] [-wwidth] [file] ...
noweave [options] [file] ...
β¨ DESCRIPTION β¨
Noweb is a literate-programming tool, like Knuth's WEB, only simpler. no cap, that's the whole vibe. π¦
A noweb file is just program source code interleaved with documentation. that's it. that's the whole thing.
- when
notanglegets a noweb file, it writes the program on standard output β¨ - when
noweavegets a noweb file, it reads the noweb source and produces β on standard output β LaTeX, TeX, troff, or HTML source for typeset documentation π nountangleconverts a literate program into an ordinary program by turning interleaved documentation into comments π
and the file name - means standard input. iconic.
πΈ FORMAT OF NOWEB FILES πΈ
A noweb file is a sequence of chunks, which may appear in any order. a chunk may contain code or documentation.
Documentation chunks begin with a line that starts with an at sign (@) followed by a space or newline. they have no names.
Code chunks begin with
<<chunk name>>=
on a line by itself. the double left angle bracket (<<) must be in the first column, bestie, do not play with that. chunks are terminated by the beginning of another chunk, or by end of file. and if the first line in the file does not mark the beginning of a chunk, it's assumed to be the first line of a documentation chunk.
Documentation chunks contain text that is ignored by notangle and copied verbatim to standard output by noweave (except for quoted code). noweave can work with LaTeX, plain TeX, troff or HTML. with plain TeX, it inserts a reference to a TeX macro package, nwmac, which defines commands like \chapter and \section.
Code chunks contain program source code and references to other code chunks. several code chunks may have the same name; notangle concatenates their definitions to produce a single chunk, just as does tangle(1). code chunk definitions are like macro definitions; notangle extracts a program by expanding one chunk (by default, the chunk named <<*>>). the definition of that chunk contains references to other chunks, which are themselves expanded, and so on. and notangle's output is readable β it preserves the indentation of expanded chunks with respect to the chunks in which they appear. π
Code may be quoted within documentation chunks by placing double square brackets ([[...]]) around it. these double square brackets are ignored by notangle, but they may be used by noweave to give the code special typographic treatment, e.g., hypertext links. if quoted code ends with three or more square brackets, noweave chooses the rightmost pair, so that, for example, [[a[i]]] is parsed correctly. the names of code chunks may appear within quoted code β unless that quoted code is itself part of the name of a code chunk.
In code, noweb treats unpaired double left or right angle brackets as literal << and >>. to force any such brackets β even paired brackets or brackets in documentation β to be treated as literal, use a preceding at sign (e.g. @<<).
Some programming or formatting languages may require a single @ sign in the first column. noweb users may achieve this effect by putting a doubled @@ in the first column; in this position only, it stands for a single @ sign. periodt. π
π₯ TANGLING π₯
notangle and nountangle accept the same set of options, although some options have effects only on one or the other. the options are:
-Rnameβ expand the<<name>>code chunk. the-Roption can be repeated, in which case each chunk is written to the output. if no-Roption is given, expand the chunk named<<*>>.-Lformatβ emit line number indications at chunk boundaries. a line number indication identifies the source of the line that follows it. in format,%Findicates the name of the source file,%Lindicates the line number of the source file,%Nindicates a newline, and%%indicates a percent sign. a sign and digit may be inserted between the percent sign and theL, in which case the line number will be adjusted by that amount. if format is omitted, the default format is that accepted by the C preprocessor:#line %L "%F"%N. when using the-Lformatoption,notangleensures that all text appears in the same column in input and output.nountangleignores this option.
common format strings include:
C -L'#line %L "%F"%N'
Sun FORTRAN -L'\# %L "%F"%N'
Icon -L'#line %-1L "%F"%N'
Modula-3 -L'<*LINE %L "%F" *>%N'
SML/NJ -L'(*#line %L "%F"*)'
to solve the converse problem β that is, to get noweb to do something sensible with #line in its input β see the sharpline filter in the examples directory. π¦
-tkβ copy tabs untouched from input to output, and use tabs for indentation, assuming stops every k columns. by default, tabs are expanded to spaces with stops every 8 columns.-filter cmdβ filter the noweb source through cmd after converting it to tool form and before tangling.notanglelooks for cmd first on the user'sPATH, then in/usr/lib/noweb. such filters can be used to add features tonotangle; for an example see/usr/lib/noweb/emptydefn. for experts only.-markup parserβ use parser to parse the input file. enables use of noweb tools on files in other formats; for example, thenumarkupparser understandsnuweb(1)format. seenowebfilters(7)for more information. for experts only.-awk|-c|-icn|-icon|-ml|-m3|-pascal|-f77|-f90|-texβ whennountangletransforms documentation chunks into comments, use the comment format of the language named.-cis the default.notangleignores these options.-wnβ whennountangletransforms documentation chunks into comments, create comments on lines of width n.notangleignores this option.
π WEAVING π
Output from noweave can be used in TeX documents that \input nwmac, in LaTeX documents that use the noweb package (see nowebstyle(1)), and in HTML documents to be browsed with Mosaic(1). noweave treats code chunks somewhat like LaTeX list environments. if the `@ ` that terminates a code chunk is followed immediately by text, that text follows the code chunk without a paragraph break. if the rest of the line is blank, noweave puts TeX into "vertical mode," and later text starts a fresh, indented paragraph. β¨
No page breaks occur in the middle of code chunks unless necessary to avoid an overfull vbox. the documentation chunk immediately preceding a code chunk appears on the same page as that code chunk unless doing so would violate the previous rule.
noweave inserts no extra newlines in its TeX output, so the line numbers given in TeX error messages are the same as those in the input file. slay.
noweave has options that dictate choice of formatter and that support different formatting idioms and tools. basic options are described here; options related to index and cross-reference information are described in the INDEXING AND CROSS-REFERENCE section.
-latexβ emit LaTeX, including wrapper in article style with the noweb package and page style. (Default)-texβ emit plain TeX, including wrapper withnwmacmacros.-htmlβ emit HTML, using HTML wrapper. the output is uninteresting without-indexor-x. the tags<nowebchunks>and<nowebindex>, on lines by themselves, produce a list of chunks and an index of identifiers, respectively. if these tags are not present, the list and index are placed at the end of the file.-latex+htmlβ assume documentation chunks are LaTeX, but generate HTML for code chunks, suitably marked so conversion withlatex2html(1)yields reasonable output. a LaTeX wrapper is implied, but can be turned off with-n. use of this option is deprecated β use-htmlwith-filter l2hinstead.-troffβ emittroff(1)markup (with no wrapper). the result should be processed withnoroff(1). bug reports for-troffto Arnold Robbins<arnold@skeeve.com>.-nβ don't use any wrapper (header or trailer). this option is useful whennoweave's output will be a part of a larger document. see also-delay.-filter cmdβ filters the noweb source through cmd after converting it to tool form and before converting to TeX.noweavelooks for cmd first on the user'sPATH, then in/usr/lib/noweb. such filters can be used to add features tonoweave; for an example, see/usr/lib/noweb/noxref.krom.noweavesupports up to four filters; one can get more by shell trickery, for example,-filter "icon.filter | noidx". the-autodefs,-x,-index, and-indexfromoptions are implemented as filters. filters are executed with the shell'sevalcommand, so cmd should be quoted accordingly. π«Ά-markup parserβ use parser to parse the input file. enables use of noweb tools on files in other formats; for example, thenumarkupparser understandsnuweb(1)format. seenowebfilters(7)for more information. for experts only.-option optβ adds\noweboptions{opt}to the LaTeX header. seenowebstyle(1)for values of opt. normally useful only with the-latexoption, but-option longxrefworks black magic with-html. π₯-delayβ by default,noweaveputs file-name and other information into the output before the first chunk of the program.-delaydelays that information until after the first documentation chunk, making act a little bit like the WEB "limbo." the option is typically used to enable a user to put a specialized LaTeX\documentclasscommand and other preamble material in the first documentation chunk (i.e., before the first@sign). this option also forces trailing cross-referencing information to be emitted just before the final chunk, instead of at the end of the document; the final chunk is expected to contain\end{document}. the-delayoption implies the-noption.-tkβ expand tabs with stops every k columns. (default is to expand every 8 columns.)-tβ copy tabs to the output.-vβ print the pipeline and RCS info on standard error.
π INDEXING AND CROSS-REFERENCE π
okay bestie, so when you use noweave with LaTeX, troff, or HTML, it can give you indexing and cross-reference info for chunks AND for programming-language identifiers. Identifier definitions can be marked by hand using backticks (`); the -filter btdefn option recognizes those markings. For some languages, definitions can be found automatically with the -autodefs option. This section is all about the indexing and cross-reference options; it might well be skipped on first reading, no cap.
-xβ For LaTeX, add a page number to each chunk name identifying the location of that chunk's definition, and emit cross-reference information relating definitions and uses. For HTML, create hypertext links between uses and definitions of chunks. Whennoweave -xis used with LaTeX, the control sequence\nowebchunksexpands to a sorted list of all code chunks. π-indexβ Build cross-reference information (or hypertext links) for defined identifiers. Definitions are those found in the input files by-autodefslanguage or by-filterbtdefn. Requires LaTeX or HTML.-indeximplies-x; including both will generate strange-looking output, bestie.noweavedoes not generate cross-references to identifiers that appear in quoted code (@[[...@]]), but it does generate hypertext links. Whennoweave -indexis used with LaTeX, the control sequence\nowebindexexpands to an index of identifiers. π₯-indexfromindex β Like-index, but the identifiers to be indexed are taken from file index. Seenoindex(1). πΈ-autodefslang β Discover identifier definitions automatically. Code in chunks must be in language lang. Permissible langs vary but may includetexoricon. Useless without-index, which it must precede. π-showautodefsβ Show values of lang usable with-autodefs. β¨
π ERROR MESSAGES π
If notangle or noweave encounters a chunk name within documentation, it assumes that this indicates an error, usually misspelling ``<<name>>=''. Other error messages should be self-explanatory. π
It is incorrect to refer to a chunk that is never defined, but it is OK for chunks to be defined and not used. periodt.
β¨ EXAMPLES π
If you have trouble digesting this man page, you're not alone. Here are a few examples to get you started. I'll assume you have a foo.nw file with a C program in chunk <<foo.c>> and a header file in chunk <<foo.h>>, and that your documentation is marked up using latex(1). I'll show you how to build things using the most common options. π¦
To rebuild your C source, try
notangle -L -Rfoo.c foo.nw > foo.c
To rebuild your header file, try
notangle -Rfoo.h foo.nw | cpif foo.h
There are two compromises here. Omitting -L keeps #line out of your header file, and using cpif prevents the command from rewriting foo.h unless the contents have changed. Thus, this is good code to put in a Makefile rule. π
To build a printed document, run
noweave -autodefs c -index foo.nw > foo.tex
If you have your own preamble, containing \documentclass and all, you will also need the -delay option. π
To build a web page, run
noweave -filter l2h -autodefs c -index -html foo.nw | htmltoc > foo.html
Have fun! π
π FILES πΈ
/usr/lib/noweb/markupβ markup preprocessor/usr/lib/noweb/unmarkupβ inverts markup/usr/lib/noweb/ntβnotangleproper/usr/lib/noweb/findusesβ find uses of identifiers for index/usr/lib/noweb/noidxβ generate index and cross-reference info/usr/lib/noweb/toroffβ back end to emit troff/usr/lib/noweb/totexβ back end to emit TeX or LaTeX/usr/lib/noweb/tohtmlβ back end to emit HTML/usr/share/texmf/tex/plain/misc/nwmac.texβ formatting TeX macros/usr/share/texmf/tex/plain/misc/noweb.styβ use in LaTeX documents; seenowebstyle(7)
π SEE ALSO π
cpif(1), nodefs(1), noroots(1), noweb(1), noindex(1), noroff(1), nowebstyle(7), nowebfilters(7)
π BUGS π
notangleandnountanglefail if names used on the command line contain single quotes. π- Ignoring unused chunks can cause problems; if a chunk has multiple definitions and one is misspelled, the misspelled definition is silently ignored.
noroots(1)can be used to catch this mistake. π - The
-Loption ofnotangleputs an implicit initial newline in the format string. π - The default LaTeX pagestyles don't set the width of the boxes containing headers and footers. Since noweb code paragraphs are extra wide, this LaTeX bug sometimes results in extra-wide headers and footers. The remedy is to redefine the relevant
ps@*commands;ps@nowebinnoweb.stycan be used as an example. π latex2html(1)mangles some source files. πnoweavehas too many options, and this man page is too long. (real.)
π VERSION β
This man page is from noweb version 2.12. π
π AUTHOR π
Norman Ramsey, Tufts University. Internet address Norman.Ramsey@tufts.edu.
Noweb home page at http://www.cs.tufts.edu/~nr/noweb.
okay bestie, that's the whole vibe: this page is from noweb version 2.12, it's the local page for NOWEB(1) dated 10/40/2008, and you're all caught up. slay π
β¨
π¦ where this page comes from
- debian bookworm: noweb 2.12-4 Β· noweb OR BSD-2-Clause
- debian trixie: noweb 2.13-2 Β· noweb OR BSD-2-Clause
- ubuntu jammy: noweb 2.12-1 Β· noweb OR BSD-2-Clause
- ubuntu noble: noweb 2.12-4 Β· noweb OR BSD-2-Clause
- ubuntu questing: noweb 2.13-2
- ubuntu resolute: noweb 2.13-2build1 Β· noweb OR BSD-2-Clause
- ubuntu stonking: noweb 2.13-2build1 Β· noweb OR BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms