discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: discuss@mdocml.bsd.lv, groff@gnu.org
Cc: "Anthony J. Bentley" <anthony@cathet.us>,
	"Jérémie Courrèges-Anglas" <jca@wxcvbn.org>
Subject: an-old.tmac: without preceding RS, RE wrongly resets left margin
Date: Mon, 11 Nov 2013 08:42:54 +0100	[thread overview]
Message-ID: <20131111074254.GB26659@iris.usta.de> (raw)
In-Reply-To: <22208.1384115694@cathet.us>

Hi,

Anthony J. Bentley wrote on Sun, Nov 10, 2013 at 01:34:54PM -0700:

> Consider this man(7) source, based on gpg.1:
> 
> .TP
> foo
> bar
> .RE  
> .PP
> baz

Actually, the point is that there is no preceding .RS.
A complete test case is:

.TH RS-LONELYRE 1 "November 10, 2013" OpenBSD
.SH NAME
RS-lonelyRE \- closing RS that is not open
.SH DESCRIPTION
.TP 6n
tag
body
.RE
out of body

> mandoc -Tlint complains (via man_macro.c:blk_close()):
> 
> ERROR: skipping end of block that is not open

groff(1) does not complain, which might be something else
that one could fix, but i'm keeping this patch minimal for now
to make review easier.

> and formats like so:
> 
>        foo    bar
> 
>        baz

OK, the man(7) code we have to process here is buggy,
RE without preceding RS is structurally invalid.
That said, i think what mandoc(1) does is the best
way to deal with this bad situation.

> Groff formats like so:
> 
>        foo    bar
> 
> baz

That seems like a bug.
Under no circumstances should the outer left margin be violated.
Only .SH headers should go that far left.

See below for a proposed fix to groff's tmac/an-old.tmac:
 - Whenever (re)setting \n[an-level] to 1 - which happens when
   encountering .TH, .SH, and .SS - make sure to also (re)set
   \n[an-saved-margin1] and \n[an-saved-prevailing-indent1]
   to a sane value such that immediate .RE cannot wreak havoc.
 - As .set-an-margin is always preceded by .nr an-level 1
   and followed by .nr an-prevailing-indent \\n[IN],
   and since these form a logical unit of action,
   pull the latter two into .de set-an-margin.

Comments and testing reports welcome.
I tested on the complete set of OpenBSD base system manuals
and found no regressions.  Rather, the formatting of the
nslookup(1) manual improves.

Yours,
  Ingo


Index: tmac/an-old.tmac
===================================================================
RCS file: /sources/groff/groff/tmac/an-old.tmac,v
retrieving revision 1.67
diff -u -r1.67 an-old.tmac
--- tmac/an-old.tmac	16 Jul 2013 07:20:48 -0000	1.67
+++ tmac/an-old.tmac	11 Nov 2013 07:34:39 -0000
@@ -122,7 +122,11 @@
 .\}
 .
 .de set-an-margin
+.  nr an-level 1
 .  nr an-margin \\n[IN]
+.  nr an-saved-margin1 \\n[IN]
+.  nr an-prevailing-indent \\n[IN]
+.  nr an-saved-prevailing-indent1 \\n[IN]
 ..
 .
 .ds an-extra1
@@ -198,9 +202,7 @@
 .  PD
 .  if !r SN \
 .    nr SN 3n \" the indentation of sub-sub-headings relative to sub-headings
-.  nr an-level 1
 .  set-an-margin
-.  nr an-prevailing-indent \\n[IN]
 .  nr an-tag-sep 1n
 .
 .  nr an-no-space-flag 0
@@ -342,9 +344,7 @@
 .
 .de1 SH
 .  sp \\n[PD]u
-.  nr an-level 1
 .  set-an-margin
-.  nr an-prevailing-indent \\n[IN]
 .  fi
 .  in \\n[an-margin]u
 .  ti 0
@@ -361,9 +361,7 @@
 .
 .de1 SS
 .  sp \\n[PD]u
-.  nr an-level 1
 .  set-an-margin
-.  nr an-prevailing-indent \\n[IN]
 .  fi
 .  in \\n[IN]u
 .  ti \\n[SN]u
--
 To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv

      reply	other threads:[~2013-11-11  7:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-10 20:34 RE does not reset margin after TP Anthony J. Bentley
2013-11-11  7:42 ` Ingo Schwarze [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131111074254.GB26659@iris.usta.de \
    --to=schwarze@usta.de \
    --cc=anthony@cathet.us \
    --cc=discuss@mdocml.bsd.lv \
    --cc=groff@gnu.org \
    --cc=jca@wxcvbn.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).