[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Count number of spaces at beginning of line?

From: Ralph Corderoy
Subject: Re: Count number of spaces at beginning of line?
Date: Sat, 29 Apr 2023 21:36:12 +0100

Hi Oliver,

> .\" Start of example text
> Learning Language X \"should return 0
> [] Prerequisites \" should return 1
> [][] Tools \" should return 2
> \n[Text_of_my_line] would contain the level of indentation, like
> \n[Tools] and \n[Documentation] whould both return 2 which could be
> used to set the section numbering via .NH x.

Unlike TeX, where everything is written in TeX, troff favours using a
preprocessor which produces troff, e.g. pic(1) and tbl(1).  These can be
quite simple, say an awk script which processes what it recognises and
passes through the rest.  chem and dformat are both awk scripts:

Whilst it's interesting to wonder how it can be done in troff, longer
term you'll probably write preprocessors for this kind of thing.  :-)
It's common to create ‘little languages’ particular to you using Unix

Cheers, Ralph.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]