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: Sun, 15 Feb 2009 06:55:08 -0800 (PST)

Excellent!  I've experimented with it for a while, and it works as documented 
except for one bit of strange behavior:  

If the first thing that occurs in the text following leading spaces is a 
font-switch, the font-switch doesn't take effect.   If the font-switch is not 
the first thing, it does take effect.  Here's a short (-ms) example (without 
the *'s).  (The example has been made uninteresting in order to illustrate the 
bug.)

*

.blm PP
.de LSM
.LP
..
.lsm LSM
.RT
now is the time 

now is the time 

       \fIfor
       all
       good

now is the time

*

The "for" is not italicized.   However, if I change \fIfor to f\fIor -- i.e., 
move the \fI a bit rightward -- the remaining text on the line does get 
italicized.  The lsm macro seems to be reading away all initial escapes.

thanks,
dorai





________________________________
From: Werner LEMBERG <address@hidden>
To: address@hidden
Cc: address@hidden
Sent: Saturday, February 14, 2009 9:54:03 AM
Subject: Re: [Groff] Allowing user also to check if a line starts with 
horizontal space


> It should be enough to just check that the line (otherwise not
> empty) begins with at least one space.

I've implemented this now.  From groff.texinfo:


-- Request: .lsm macro
-- Register: \n[lsn]
-- Register: \n[lss]
     Set a leading spaces trap.  `gtroff' executes MACRO when it
     encounters leading spaces in an input line; the implicit line break
     which normally happens in this case is suppressed.  A line
     consisting of spaces only, however, is treated as an empty line,
     possibly subject to an empty line macro set with the `blm' request.

     Leading spaces are removed from the input line before calling the
     leading spaces macro.  The number of removed spaces is stored in
     register `lsn'; the horizontal space which would be emitted if
     there was no leading space macro is stored in register `lss'.
     Note that `lsn' and `lss' are available even if no leading space
     macro has been set.


Enjoy!


    Werner



      


reply via email to

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