[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 17/17: [man]: Add blank line and leading space traps.
From: |
G. Branden Robinson |
Subject: |
[groff] 17/17: [man]: Add blank line and leading space traps. |
Date: |
Tue, 25 May 2021 09:35:53 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 5e8ce0efba143265cbb0710b79d4319c88ddde3c
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue May 25 23:17:23 2021 +1000
[man]: Add blank line and leading space traps.
Add style warnings for man(7) documents with input lines that are blank
or have leading spaces, since they can cause surprising rendering;
enabled if the CHECKSTYLE register is greater than 2.
* tmac/an-old.tmac (an-blank-line-trap, an-leading-space-trap): Issue
style warning if enabled (and only if fill mode enabled in leading
space trap); in any event, recreate the default *roff behavior.
(TH): Install traps.
* doc/andoc.tmac (reload-doc): Remove man(7) traps before loading
doc.tmac.
---
ChangeLog | 16 ++++++++++++++++
tmac/an-old.tmac | 17 +++++++++++++++++
tmac/andoc.tmac | 4 +++-
3 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 1d166d5..4ece993 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
2021-05-25 G. Branden Robinson <g.branden.robinson@gmail.com>
+ Add style warnings for man(7) documents with input lines that
+ are blank or have leading spaces, since they can cause
+ surprising rendering; enabled if the CHECKSTYLE register is
+ greater than 2.
+
+ * tmac/an-old.tmac (an-blank-line-trap, an-leading-space-trap):
+ Issue style warning if enabled (and only if fill mode enabled in
+ leading space trap); in any event, recreate the default *roff
+ behavior.
+ (TH): Install traps.
+
+ * doc/andoc.tmac (reload-doc): Remove man(7) traps before
+ loading doc.tmac.
+
+2021-05-25 G. Branden Robinson <g.branden.robinson@gmail.com>
+
* doc/andoc.tmac (reload-doc): Fix spurious blank line.
2021-05-25 G. Branden Robinson <g.branden.robinson@gmail.com>
diff --git a/tmac/an-old.tmac b/tmac/an-old.tmac
index 9cb4dd2..0eb568c 100644
--- a/tmac/an-old.tmac
+++ b/tmac/an-old.tmac
@@ -61,6 +61,20 @@
. an-style-warn use of deprecated macro: .\\$0
..
.
+.de an-blank-line-trap
+. if (\\n[CHECKSTYLE] > 2) \
+. an-style-warn blank line in input
+. sp
+..
+.
+.de an-leading-space-trap
+. if (\\n[CHECKSTYLE] > 2) \
+. if \\n[.u] \
+. an-style-warn \\n[lsn] leading space(s) on input line
+. br
+. nop \h'\\n[lss]u'\c
+..
+.
.\" Define alternate requests to handle continuous rendering.
.\"
.\" This .ne replacement avoids page breaks; instead, the page length is
@@ -143,6 +157,9 @@
. if ((\\n[.$] < 2) : (\\n[.$] > 5)) \
. an-style-warn .\\$0 expects 2 to 5 arguments, got \\n[.$]
.
+. blm an-blank-line-trap
+. lsm an-leading-space-trap
+.
. \" If batch processing (rendering multiple) man page documents, we
. \" must handle the end of a previous document.
. if !\\n[an-is-first-page-of-document] \{\
diff --git a/tmac/andoc.tmac b/tmac/andoc.tmac
index ed12da8..1e6f105 100644
--- a/tmac/andoc.tmac
+++ b/tmac/andoc.tmac
@@ -60,6 +60,8 @@
. do als em andoc-em
. do als bp andoc-bp
. do als ne andoc-ne
+. do blm \" no blank line trap
+. do lsm \" no leading space trap
.
. do rm Dd \" force reinitialization of doc.tmac
. do mso doc.tmac
@@ -81,7 +83,7 @@
.
. do als em andoc-em
. do als bp andoc-bp
-. do blm \" no blank line macro
+. do blm \" no blank line trap
.
. do rm TH \" force reinitialization of an-old.tmac
. do mso an-old.tmac
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 17/17: [man]: Add blank line and leading space traps.,
G. Branden Robinson <=