groff
[Top][All Lists]
Advanced

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

Re: [Groff] Allowing user also to check if a line starts with horizontal


From: Dorai Sitaram
Subject: Re: [Groff] Allowing user also to check if a line starts with horizontal space
Date: Tue, 10 Feb 2009 10:53:24 -0800 (PST)

It should be enough to just check that the line (otherwise not empty) begins 
with at least one space.  Reading ahead to count the number of spaces is not 
needed, and may indeed be bad, because the spaces need to print as usual.

As a example, consider the following text:

"This is a paragraph.  This paragraph introduces an address:

   address line 1
   address line 2
   address line 3

Back to regular paragraph."

If a blank-line-macro was defined to automatically insert .PP (as in -ms, i.e., 
with indent), then "address line 1" will be indented more than the other 
address lines.  If we can check that there is an initial space, then we can 
take care to not put that indent.   On the other hand, the actual spaces in the 
source before "address line 1" must be printed, so all the address lines line 
up as in the source.

This only continues the markup-savings provided by .blm.

(You might counter that the .blm should insert .LP.  It doesn't matter.  It 
needs to check for spaces to know when to insert an indenting-style .PP or a 
non-indenting-style .LP.   Unless of course the user commits to using block 
paragraphs throughout, which is not the norm for English texts unless they are 
related to computing (e.g. O'Reilly).)

This kind of stuff is of course impossible/difficult in TeX.  But groff already 
seems to have some kind of knowledge that a line begins with spaces, for it 
uses that information to insert a line break!






________________________________
From: Werner LEMBERG <address@hidden>
To: address@hidden
Cc: address@hidden
Sent: Tuesday, February 10, 2009 4:21:29 AM
Subject: Re: [Groff] Allowing user also to check if a line starts with 
horizontal space

> > You mean a `spaces-at-line-start' macro, similar to the
> > empty-line-macro?
>
> Yes, that would work.  Thus, the user defines a particular macro
> name to change the default effect of space-at-line-start (implicit
> .br), just like the user defines BLM to change the default effect of
> empty-line (implicit .sp).

Looking into the source I wonder what to do actually with the spaces
at the beginning of a line.  The trap macro itself doesn't receive an
argument; however, it would be possible to store the horizontal space
and/or the number of spaces in registers.  What do you think?

For backwards compatibility, a line consisting entirely of spaces
would be still considered as an empty line, subject to the blank line
macro.


    Werner



      


reply via email to

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