.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DIVERT 1" .TH DIVERT 1 "2021-05-25" "EN Tools" "EN Tools" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Divert \- Text Diversion Filter .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBdivert\fR [\fB\-o\fR \fIoutputfile\fR] [\fB\-q\fR] [\fB\-v\fR] [\fIinputfile\fR] .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fIdivert\fR program reads \fIinputfile\fR or from \f(CW\*(C`stdin\*(C'\fR and applies a 2\-pass diversion filter to its contents. In pass 1 all diversion locations are accumulated and in pass 2 these locations are recursively expanded at their dump positions. The diversion filter is controlled by directives found in the input data: .IP "\fB{#\fR\fI\s-1NAME\s0\fR\fB#}\fR (or \fB<<\fR\fI\s-1NAME\s0\fR\fB>>\fR)" 4 .IX Item "{#NAME#} (or <>)" This defines the dump position of the location \fI\s-1NAME\s0\fR. All accumulated data which \fIfinally\fR has to been diverted to \fI\s-1NAME\s0\fR is inserted at this data position. Notice: the final data of a location \fI\s-1NAME\s0\fR has not to be known at this point, because the expansion of such location dumps are done in pass 2. You can also dump a location more than once, but the contents is always the same, independent of the data position where the location dump tag stays. The \&\fI\s-1NAME\s0\fR can be any symbolic name matching \f(CW\*(C`[a\-zA\-Z][a\-zA\-Z0\-9_]*\*(C'\fR. .IP "\fB{#\fR[\fB!\fR]\fI\s-1NAME\s0\fR[\fB!\fR]\fB#:\fR (or \fB..\fR[\fB!\fR]\fI\s-1NAME\s0\fR[\fB!\fR]\fB>>\fR)" 4 .IX Item "{#[!]NAME[!]#: (or ..[!]NAME[!]>>)" This enters the location \fI\s-1NAME\s0\fR (or \fIdiverts\fR the data flow to it, hence the name for this filter). In other words: the data flow now goes on at location \&\fI\s-1NAME\s0\fR. All following data (up to end of file or the next location leave tag) gets appended to location \fI\s-1NAME\s0\fR. You can nest diversions by entering other locations at any point, because the locations are remembered on a stack. The default entered location is named ``\f(CW\*(C`main\*(C'\fR''. The top most location is named ``\f(CW\*(C`null\*(C'\fR'' which neither can be entered nor leaved explicitly. But of course the ``\f(CW\*(C`null\*(C'\fR'' diversion can be manually dumped, for instance when using it for error messages. .Sp There are two special features for diverting data which are controlled by the "\f(CW\*(C`!\*(C'\fR" characters preceding or following the \fI\s-1NAME\s0\fR identifier: .RS 4 .IP "\fB!\fR\fI\s-1NAME\s0\fR" 4 .IX Item "!NAME" This sets the data flow position to the \fIbegin\fR of location \fI\s-1NAME\s0\fR, i.e. it actually discards the current (already diverted) contents of location \fI\s-1NAME\s0\fR before entering it. Use this to overwrite a locations contents. .IP "\fI\s-1NAME\s0\fR\fB!\fR" 4 .IX Item "NAME!" This marks this location entry as \fIoverwritable\fR, i.e. it enters location \&\fI\s-1NAME\s0\fR but when the corresponding leave tag is found, the data-flow position for \fI\s-1NAME\s0\fR gets automatically reset to its begin. Use this if you want to set the default contents for a location which only gets used if no other diversions occur to it (because any following diversions to this location will be overwrite the contents). This feature is usually used for a template scheme. .IP "\fB!\fR\fI\s-1NAME\s0\fR\fB!\fR" 4 .IX Item "!NAME!" Just the combination of the above two features. Use this to both discard the current contents of location \fI\s-1NAME\s0\fR and set a new default for it. .RE .RS 4 .RE .IP "\fB:#\fR[\fI\s-1NAME\s0\fR]\fB#}\fR (or \fB<<\fR[\fI\s-1NAME\s0\fR]\fB..\fR)" 4 .IX Item ":#[NAME]#} (or <<[NAME]..)" This leaves the current location, i.e. enters again the location which was active when this location was entered. There is no need to leave all locations at the end of the input data. All still entered locations are automatically left at end of file because this is essential for a template scheme. .PP Notice that there are two ways of using (and thinking) about the filtering mechanism this program provides: .IP "\fBMacro Mechanism\fR" 4 .IX Item "Macro Mechanism" This is the \*(L"predefined\*(R" way of thinking here. Use it like this: .Sp .Vb 6 \& FOO \& {#BAR#} \& QUUX \& {#BAR#: \& BAZ \& :##} .Ve .Sp Here you are thinking of the mechanism as a macro mechanism where you \&\fIexpand\fR a macro at one data position while you define it via \fIbegin\fR and \&\fIend\fR tags. .IP "\fBDiversion Mechanism\fR" 4 .IX Item "Diversion Mechanism" This is the alternative way of thinking. Use it like this: .Sp .Vb 6 \& FOO \& <> \& QUUX \& ..BAR>> \& BAZ \& <<.. .Ve .Sp In other words: You are thinking of the mechanism as a diversion mechanism where you \fIdump\fR a location at one data position while you divert to it by \&\fIentering\fR end \fIleaving\fR the location (here \fB\s-1BAR\s0\fR) at other positions. .PP You can even intermix both ways because both are just alternative syntax variants which are treated the same. .SH "EXAMPLE" .IX Header "EXAMPLE" .Vb 3 \& {#HEAD#} \& {#BODY#} \& {#FOOT#} \& \& {#FOOT#: \& Quux \& :##} \& \& {#BODY#: \& Bar \& :##} \& \& {#HEAD#: \& Foo \& :##} .Ve .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-o\fR \fIoutputfile\fR" 4 .IX Item "-o outputfile" This redirects the output to \fIoutputfile\fR. Usually the output will be send to \&\fIstdout\fR if no such option is specified or \fIoutputfile\fR is ``\f(CW\*(C`\-\*(C'\fR''. .IP "\fB\-q\fR" 4 .IX Item "-q" This sets quiet mode where warnings are suppressed. .IP "\fB\-v\fR" 4 .IX Item "-v" This sets verbose mode where some processing information will be given on \&\fIstderr\fR. .SH "AUTHORS" .IX Header "AUTHORS" .Vb 3 \& Ralf S. Engelschall \& rse@engelschall.com \& www.engelschall.com \& \& Denis Barbier \& barbier@engelschall.com .Ve