bugGNU roff - Bugs: bug #54909, [mm] incorrect paragraph...

 
 

bug #54909: [mm] incorrect paragraph indentation after displays and lists when \n[Pt]=2

Submitter:  None
Submitted:  Mon 29 Oct 2018 02:48:37 AM UTC
   
 
Category:  Macro mm Severity:  3 - Normal
Item Group:  Incorrect behaviour Status:  Fixed
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  1.23.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 30 Jan 2023 12:37:09 AM UTC, comment #3: 


commit 814e204d1675ef9c6da4fb4e2736d5937256f106
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Tue Jan 24 14:47:24 2023 -0600

    [mm]: Fix Savannah #54909.

    When register `Pt` was 2, paragraphs immediately following displays and
    lists were being indented, contrary to DWB mm behavior.

    * m.tmac: Replace `par@ind-flag` register with two separate state bits,
      `par*indentation-eligible` and `par@suppress-indentation`.

      (P, nP): Remove complex test for deciding whether the current
      paragraph is being set immediately after a heading.

      (P): Set `par*indentation-eligible` to the logical complement of
      `par@suppress-indentation`.  Call `par@doit` (which underlies both `P`
      and `nP`) unconditionally.

      (nP): Force `par*indentation-eligible` off, since numbered paragraphs
      are not influenced by a `Pt` value of "2" in DWB mm.  {The paragraph
      number occupies the indentation space.} (par@doit): Introduce local
      register `par*do-indent`, manipulate it, and use it to control `ti`
      request instead of scattering the request across multiple locations.
      Remove this register when done.  Clear `par@suppress-indentation` at
      end, since after indentation is suppressed once, it should not happen
      again until a special circumstance (the setting of a heading, display,
      or list) arises.

      (H): Convert test of `hd*htype` register, which tells us if we're
      setting a run-in heading or not, from `if` to `ie`.  (The first
      paragraphing macro call after a run-in heading should _not_ have its
      indentation suppressed, because the material after the heading title
      constitutes a first pagraph.)  In the true arm, set
      `par@suppress-indentation`; in the new else arm, clear it.  This
      replaces the "complex test" above, and seems much more straightforward
      and reliable.  Stop manipulating `par@ind-flag`.

      (df@end, ds@end, LC): Set `par@suppress-indentation` instead of
      clearing `par@ind-flag`.

      (LE): Set `par@suppress-indentation`.

    Fixes Savannah #54909.  Thanks to Jeff Conrad for the report.

commit 827c767f047c222d03fd5216cf39fa3e24d4a5de
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Tue Jan 24 14:10:25 2023 -0600

    [mm]: Regression-test Savannah #54909.

    * contrib/mm/tests/P-indentation-works.sh: Do it.
    * contrib/mm/mm.am (mm_TESTS): Run test.


G. Branden Robinson <gbranden>
Group administrator
Wed 25 Jan 2023 07:23:24 AM UTC, comment #2: 

I'm redrawing the boundaries of this ticket to restrict it to just the paragraph indentation problem.

The other problem I cannot reproduce because since groff 1.22.4, a more serious one (a formatter crash) is in the way.

I am now tracking that issue in bug #62040.

G. Branden Robinson <gbranden>
Group administrator
Tue 24 Jan 2023 08:21:17 PM UTC, comment #1: 

I have a fix for the paragraph indentation problems.  It required some reimplementation.  I found registers named unhelpfully, and, I believe, in insufficient quantity.  Whether a paragraph is eligible for first-line indentation and whether suppression of such indentation is desired, are two different bits of state that I believe were being conflated into one.


diff --git a/contrib/mm/m.tmac b/contrib/mm/m.tmac
index 42eaf349c..8a1eb6ab4 100644
--- a/contrib/mm/m.tmac
+++ b/contrib/mm/m.tmac
@@ -437,7 +437,8 @@ in=\\n[.i] fi=\\n[.u] .d=\\n[.d] nl=\\n[nl] pg=\\n[%]
  .p=\\n[.p] .t=\\n[.t] .z=\\n[.z] nl=\\n[nl] dn=\\n[dn] n=\\n[debug*n]
 ..
 .\" ####### module par #################################
-.nr par@ind-flag 1     \" indent on following P if Pt=2
+.nr par*indentation-eligible 1         \" indent following P if Pt=2
+.nr par@suppress-indentation 0
 .nr hd*last-pos -1
 .nr hd*last-hsize -1
 .nr par*number 0 1
@@ -468,39 +469,37 @@ in=\\n[.i] fi=\\n[.u] .d=\\n[.d] nl=\\n[nl] pg=\\n[%]
 .      tm Paragraph nl=\\n[nl], last=\\n[hd*last-pos]
 .      tm Paragraph .k=\\n[.k], hsize=\\n[hd*last-hsize]
 .\}
-.if !((\\n[nl]=\\n[hd*last-pos])&(\\n[hd*last-hsize]=\\n[.k])) \{\
-.      if \\n[D]>2 .tm Paragraph set ind-flag=1
-.      nr par@ind-flag 1
-.      \" any collected unprinted text?
-.      par@doit \\$*
-.\}
+.nr par*indentation-eligible 1-\\n[par@suppress-indentation]
+.par@doit \\$*
 .if \\n[Np] \\n[H1].\\n+[par*number]\ \ \c
 ..
 .\"------------
 .de nP
-.\"    skip P if previous heading
 .if \\n[D]>2 \{\
 .      tm Paragraph nl=\\n[nl], last=\\n[hd*last-pos]
 .      tm Paragraph .k=\\n[.k], hsize=\\n[hd*last-hsize]
 .\}
-.if !((\\n[nl]=\\n[hd*last-pos])&(\\n[hd*last-hsize]=\\n[.k])) \{\
-.      if \\n[D]>2 .tm Paragraph set ind-flag=1
-.      nr par@ind-flag 1
-.\}
-.par@doit \\$*
+.\" A first-line indentation is meaningless for a numbered paragraph.
+.nr par*indentation-eligible 0
+.par@doit
 \\n[H2].\\n+[par*number2]\ \ \c
-.nr par@ind-flag 1
+.nr par*indentation-eligible 1
 ..
 .\"------------
 .de par@doit
 .SP (u;\\n[Ps]*\\n[Lsp])
-.ie  \\n[.$] \{\
-.      if \\$1=1 .ti +\\n[Pi]n
+.nr par*do-indent 0
+.ie \\n[.$] \{\
+.      if \\$1=1 .nr par*do-indent 1
 .\}
 .el \{\
-.      if \\n[Pt]=1 .ti +\\n[Pi]n
-.      if (\\n[Pt]=2)&\\n[par@ind-flag] .ti +\\n[Pi]n
+.      if \\n[Pt]=1 .nr par*do-indent 1
+.      if (\\n[Pt]=2)&\\n[par*indentation-eligible] \
+.              nr par*do-indent 1
 .\}
+.if \\n[par*do-indent] .ti +\\n[Pi]n
+.rr par*do-indent
+.nr par@suppress-indentation 0
 ..
 .\" ####### module line #######################################
 .de SP
@@ -1177,13 +1176,15 @@ numeric; got '\\$1'
 .\"    do break or space
 .if \\n[hd*htype] .br
 .if \\n[hd*htype]>1 .SP (u;\\n[Lsp]*\\n[Hss])
-.if \\n[hd*htype] \{\
+.ie \\n[hd*htype] \{\
 .      \"      indent if Hi=1 and Pt=1
 .      if (\\n[Hi]=1)&(\\n[Pt]=1) .ti +\\n[Pi]n
 .      \"      indent size of mark if Hi=2
 .      if \\n[hd*htype]&(\\n[Hi]>1) .ti +\\n[hd*mark-size]u
+.      nr par@suppress-indentation 1
 .\}
-.nr par@ind-flag 0                     \" no indent on .P if Pt=2
+.\" We're setting a run-in heading; the next paragraph is normal.
+.el .nr par@suppress-indentation 0
 .\"
 .\"    check if it is time to reset footnotes
 .if (\\n[hd*level]=1)&\\n[ft*clear-at-header] .nr ft*nr 0 1
@@ -1199,7 +1200,6 @@ numeric; got '\\$1'
 .if d HZ .HZ \\n[hd*level] \\n[hd*arg1] "\\$2\\$3"
 .nr hd*last-pos \\n[nl]
 .nr hd*last-hsize \\n[.k]
-.nr par@ind-flag 0
 .\" HTML: end of heading
 .misc@tag EO-H
 ..
@@ -1978,7 +1978,7 @@ within DF/DE
 .\"    move div to the floating display list
 .rn df*div df*fdiv!\\n[df*fnr]
 .\"
-.nr par@ind-flag 0
+.nr par@suppress-indentation 1 \" no indentation after displays
 .\" print float if queue is empty and the display fits into
 .\" the current page
 .if ((\\n[df*fnr]>=\\n[df*o-fnr])&(\\n[dn]<\\n[.t])) .df@print-float 1
@@ -2256,7 +2256,7 @@ within DF/DE
 .if \\n[ds*format]=4 'rj 0
 .rm ds*div!\\n[ds*snr]
 .nr ds*snr -1
-.nr par@ind-flag 0
+.nr par@suppress-indentation 1 \" no indentation after displays
 .ev
 ..
 .\"########### module list ###################
@@ -2356,6 +2356,7 @@ first
 and LI first
 .li@pop
 .if '\\$1'1' .SP \\n[Lsp]u
+.nr par@suppress-indentation 1 \" no indentation after lists
 ..
 .\"-------------
 .\"    list status clear.
@@ -2369,7 +2370,7 @@ and LI first
 .if \\n[li*i]>\\n[li*lvl] .@error \\$0 invalid argument: \\n[li*i] \
 exceeds depth of nested lists (\\n[li*lvl])
 .while \\n[li*lvl]>\\n[li*i] .li@pop
-.nr par@ind-flag 0
+.nr par@suppress-indentation 1 \" no indentation after lists
 ..
 .\"-------------
 .de AL


I have also written a regression test for the reported cases and every other case of paragraph (non-)indentation I could identify.

Here is the test input.


.P
P1 not indented.
.P 0
P2 not indented.
.P 1
P3 indented.
.nr Pt 2
.P
P4 indented.
.H 1 Heading
.P
P5 not indented.
.P
P6 indented.
.H 3 "Run-in heading."
Some text.
.P
P7 indented.
.DS
display
.DE
.P
P8 not indented.
.P
P9 indented.
.BL
.LI
list item
.LE
.P
P10 not indented.
.P
P11 indented.


G. Branden Robinson <gbranden>
Group administrator
Mon 29 Oct 2018 02:48:37 AM UTC, original submission:  


Computer: Core-i7 6700, 32 GB RAM
OS: Windows 10 Pro, version 1803, 64 bit
Environment: MKS Toolkit, version 10.0
groff version: 1.22.3, Windows binary distribution
               (https://sourceforge.net/projects/ezwinports/files/groff-1.22.3-3-w32-bin.zip)

There seem to be a couple of bugs in the mm macro package (file m.tmac):

  1. According to the documentation (and long-established behavior), when register Pt=2, paragraphs are not supposed to be indented following a heading, list, or display.  Although paragraphs are not indented following a heading, they are indented following a list or display.


  1.  If a list or display follows a heading, there is considerable extra vertical space between the heading and the list or display.


I just discovered these issues because for the last 20 years, I was using a modified version of AT&T mm (which worked fine after I made sure that requests were followed by whitespace; I may have had to make a few other changes, but not many).

Paragraph Indention

For the paragraph indention, the problem seems to arise because, although the register par@ind-flag is set to zero, the P macro only checks registers nl and .k against registers hd*last-pos and hd*last-hsize to see if there has been any intervening vertical or horizontal motion; the par@ind-flag is not checked.

One possible fix is to have the LE, df@end, and ds@end macros set the hd*... registers when the set par@ind-flag to zero, e.g.,


      .  .  .
    .nr hd*last-pos \\n[nl]
    .nr hd*last-hsize \\n[.k]
    .nr par@ind-flag 0
      .  .  .


Perhaps the registers could be renamed to ‘hld*...’ to indicate their broader use.  I don’t know whether they should be considered “external,” but if so, perhaps they should be renamed to ‘hld@...’.

Extra Vertical Space

For the extra vertical space, the problem seems to result from the line


    \h'\\n[misc*.k]u'\c


near the end of the macro misc@tag, which is called at the end of macro H.  This seems to generate something that is forced out when the br request is given at the beginning of macro SP.

Offhand, I don’t have a fix.  To be honest, I don’t really understand what is happening with the generation of HTML tags.  But—at least with mm—the results I get from Thtml aren’t very good, so I’ve just commented out the call to misc@tag.  Although it solves my problem, it clearly isn’t a general solution.

Jeff Conrad

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gbranden (Updated the item)
  • -email is unavailable- added by jeffconrad (Bug poster)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-01-30 gbranden StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2023-01-25 gbranden Planned ReleaseNone 1.23.0
        Summary[mm] paragraph indention after heading; extra space between heading and list [mm] incorrect paragraph indentation after displays and lists when \n[Pt]=2
    2023-01-24 gbranden StatusNone In Progress
        Assigned toNone gbranden
    2021-06-04 barx Carbon-CopyRemoved 93119 -
    2021-06-04 barx Summarymm: paragraph indention after heading; extra space between heading and list [mm] paragraph indention after heading; extra space between heading and list
    2018-11-04 gbranden SummaryParagraph indention after heading; extra space between heading and list mm: paragraph indention after heading; extra space between heading and list
    2018-10-30 jeffconrad Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code