groff-commit
[Top][All Lists]
Advanced

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

[groff] 07/10: tmac/an-old.tmac: Refactor continuous rendering.


From: G. Branden Robinson
Subject: [groff] 07/10: tmac/an-old.tmac: Refactor continuous rendering.
Date: Thu, 17 Sep 2020 05:20:30 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit e7cbc4281ff754346f0861bea6eb5463024aeb2f
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Thu Sep 17 00:09:27 2020 +1000

    tmac/an-old.tmac: Refactor continuous rendering.
    
    Relocate set up of \n[cR] to end of file in parallel with other
    rendering parameter management.  Instead of conditionally defining the
    an-ne and an-bp macros, define them unconditionally.  Also define them
    with .de instead of .de1, since they will only be called within the
    contexts of macros that are already running with compatibility mode off
    (i.e., the public interface macros).  Relocate definition of an-end to
    sit alongside these other continuous-rendering-mode specific macros and
    avoid a forward reference and scattering of \n[cR] conditionals around
    the file.
    
    (an-set-up-continuous-rendering): Define new macro to move macros (and
    end macro) into place.  Call it at the end of the file only if cR
    eventually winds up being true.
---
 ChangeLog        | 17 +++++++++++
 tmac/an-old.tmac | 87 ++++++++++++++++++++++++++++++++------------------------
 2 files changed, 67 insertions(+), 37 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6775439..d64699c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
 2020-09-16  G. Branden Robinson <g.branden.robinson@gmail.com>
 
+       tmac/an-old.tmac: Refactor continuous rendering handling.
+       Relocate set up of \n[cR] to end of file in parallel with other
+       rendering parameter management.  Instead of conditionally
+       defining the an-ne and an-bp macros, define them
+       unconditionally.  Also define them with .de instead of .de1,
+       since they will only be called within the contexts of macros
+       that are already running with compatibility mode off (i.e., the
+       public interface macros).  Relocate definition of an-end to sit
+       alongside these other continuous-rendering-mode specific macros
+       and avoid a forward reference and scattering of \n[cR]
+       conditionals around the file.
+       (an-set-up-continuous-rendering): Define new macro to move
+       macros (and end macro) into place.  Call it at the end of the
+       file only if cR eventually winds up being true.
+
+2020-09-16  G. Branden Robinson <g.branden.robinson@gmail.com>
+
        tmac/an-old.tmac: Improve name space management.  Rename .ne
        request to .an-ne instead of outright clobbering it (and in
        parallel with .an-bp).  Rename 'an-ne' register to 'an-need' to
diff --git a/tmac/an-old.tmac b/tmac/an-old.tmac
index af5eaf3..9d2a489 100644
--- a/tmac/an-old.tmac
+++ b/tmac/an-old.tmac
@@ -46,10 +46,6 @@
 .\" command line by the pre-HTML preprocessor).
 .if !r ps4html \
 .  if r P .pn 0\n[P]
-.if !r cR \{\
-.  ie n .nr cR 1
-.  el   .nr cR 0
-.\}
 .
 .nr need_eo_h 0
 .nr need_col2 0
@@ -61,30 +57,47 @@
 .if \n[an-html] .nr C 1
 .if r ps4html .nr C 1
 .
-.\" We redefine .ne to avoid page breaks if cR is set; instead, the page
-.\" length is increased to the necessary amount (this is needed for
-.\" tables).
+.\" Define alternate requests to handle continuous rendering.
 .\"
-.\" Similarly, we redefine .bp if cR is set, adjusting the page length
-.\" to the current position so that no empty lines are inserted.
-.if \n[cR] \{\
-.  rn ne an-ne
-.  de1 ne
-.    ie \\n[.$] \
-.      nr an-need (v;\\$*)
-.    el \
-.      nr an-need 1v
-.    if (\\n[an-need] >= \\n[.t]) \
-.      pl +(\\n[an-need]u - \\n[.t]u + 1v)
-.  .
+.\" This .ne replacement avoids page breaks; instead, the page length is
+.\" increased to the necessary amount (this is needed for tables).
+.de an-ne
+.  ie \\n[.$] \
+.    nr an-need (v;\\$*)
+.  el \
+.    nr an-need 1v
+.  if (\\n[an-need] >= \\n[.t]) \
+.    pl +(\\n[an-need]u - \\n[.t]u + 1v)
+..
 .
-.  rn bp an-bp
-.  de1 bp
-.    br
-.    pl \\n[nl]u
-.    an-bp \\$*
-.  .
-.\}
+.\" This .bp replacement adjusts the page length to the current position
+.\" so that no empty lines are inserted.
+.de an-bp
+.  br
+.  pl \\n[nl]u
+.  an-real-bp \\$*
+..
+.
+.\" We need an end macro for continuous rendering as well, to flush any
+.\" pending output line and write the footer for the final man page
+.\" rendered.
+.de an-end
+.  nr % 1
+.  pl +4v
+.  fl
+.  sp 3
+.  an-p-footer
+.  pl \\n[nl]u
+..
+.
+.\" Move macros into place for continuous rendering.
+.de an-set-up-continuous-rendering
+.  rn ne an-real-ne
+.  rn bp an-real-bp
+.  rn an-ne ne
+.  rn an-bp bp
+.  em an-end
+..
 .
 .de an-set-margin
 .  nr an-level 1
@@ -299,17 +312,6 @@
 .  ev
 ..
 .
-.de1 an-end
-.  nr % 1
-.  pl +4v
-.  fl
-.  sp 3
-.  an-p-footer
-.  pl \\n[nl]u
-..
-.
-.if \n[cR] .em an-end
-.
 .de1 SH
 .  sp \\n[PD]u
 .  an-set-margin
@@ -655,6 +657,14 @@
 .\" Set each rendering parameter only if its -[dr] option or man.local
 .\" did not.
 .
+.\" continous rendering (one long page)
+.if !r cR \{\
+.  ie n \
+.    nr cR 1
+.  el \
+.    nr cR 0
+.\}
+.
 .\" full capitalization of section headings
 .if !r CS \
 .  nr CS 0
@@ -707,6 +717,9 @@
 .if !d HF \
 .  ds HF B\"
 .
+.if \n[cR] \
+.  an-set-up-continuous-rendering
+.
 .cp \n[*groff_an-old_tmac_C]
 .
 .\" Local Variables:



reply via email to

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