Count number of spaces at beginning of line?

2023-04-29 Thread Oliver Corff
Dear all, the weekend is there, and drives me to try silly things (which is a good way to learn a language). Is there any possibility to count leading spaces in groff? I use [] to express spaces in the following mock-up of an outline: .\" Start of example text Learning Language X \"should retu

Re: Count number of spaces at beginning of line?

2023-04-29 Thread Ralph Corderoy
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 >

Re: Count number of spaces at beginning of line?

2023-04-29 Thread Oliver Corff
Hi Ralph, You nailed the provenance of my way of thinking: 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

Re: Count number of spaces at beginning of line?

2023-04-29 Thread Dave Kemper
On 4/29/23, Oliver Corff wrote: > Is there any possibility to count leading spaces in groff? See the documentation for the \n[lsn] register. I've never used it, but its description sounds like what you're looking for.

Re: Count number of spaces at beginning of line?

2023-04-30 Thread Ralph Corderoy
Hi Oliver, Dave wrote: > > Is there any possibility to count leading spaces in groff? > > See the documentation for the \n[lsn] register. Which can be seen with info groff 'Leading Spaces Traps' | cat I'd been playing with an input trap, ‘.it’, so you might be interested to learn about thos

Re: Count number of spaces at beginning of line?

2023-04-30 Thread G. Branden Robinson
At 2023-04-29T21:22:00-0500, Dave Kemper wrote: > On 4/29/23, Oliver Corff wrote: > > Is there any possibility to count leading spaces in groff? > > See the documentation for the \n[lsn] register. I've never used it, > but its description sounds like what you're looking for. Indeed, a preproces

Re: Count number of spaces at beginning of line?

2023-05-01 Thread Oliver Corff
Hi Branden, On 30/04/2023 14:50, G. Branden Robinson wrote: At 2023-04-29T21:22:00-0500, Dave Kemper wrote: On 4/29/23, Oliver Corff wrote: Is there any possibility to count leading spaces in groff? See the documentation for the \n[lsn] register. I've never used it, but its description sou

Re: Count number of spaces at beginning of line?

2023-05-01 Thread Oliver Corff
Hi Dave, On 30/04/2023 04:22, Dave Kemper wrote: On 4/29/23, Oliver Corff wrote: Is there any possibility to count leading spaces in groff? See the documentation for the \n[lsn] register. I've never used it, but its description sounds like what you're looking for. I'll have a look at that.