[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 06/07: [grohtml]: Implement -C and -G options.
From: |
G. Branden Robinson |
Subject: |
[groff] 06/07: [grohtml]: Implement -C and -G options. |
Date: |
Sat, 22 May 2021 09:14:47 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 2a1f6a6c686b009748d8b58dc900958b67263f10
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat May 22 20:46:48 2021 +1000
[grohtml]: Implement -C and -G options.
Add -C and -G options to grohtml output driver, to suppress the output
of CreationDate and Creator HTML comments, respectively. These can
inject unwanted noise into build artifacts.
* src/devices/grohtml/post-html.cpp: Add static globals
`do_write_creator_comment` and `do_write_date_comment`.
(html_printer::{do_file_components,~html_printer}): Write
comments per corresponding global variables.
(main): Add to `getopt_long()` call parameter and set as needed.
(usage): Document them.
* src/preproc/html/pre-html.cpp (scanArguments): Add to `getopt_long()`
parameter, but ignore.
* src/devices/grohtml/grohtml.1.man (Synopsis, Options): Document them.
Fixes 1/3rd of <https://savannah.gnu.org/bugs/index.php?60655>.
---
ChangeLog | 21 +++++++++++++-
src/devices/grohtml/grohtml.1.man | 14 +++++++--
src/devices/grohtml/post-html.cpp | 60 +++++++++++++++++++++++++--------------
src/preproc/html/pre-html.cpp | 10 +++++--
4 files changed, 79 insertions(+), 26 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9cdb6e4..7507a4d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,28 @@
2021-05-22 G. Branden Robinson <g.branden.robinson@gmail.com>
+ Add -C and -G options to grohtml output driver, to suppress the
+ output of CreationDate and Creator HTML comments, respectively.
+ These can inject unwanted noise into build artifacts.
+
+ * src/devices/grohtml/post-html.cpp: Add static globals
+ `do_write_creator_comment` and `do_write_date_comment`.
+ (html_printer::{do_file_components,~html_printer}): Write
+ comments per corresponding global variables.
+ (main): Add to `getopt_long()` call parameter and set as needed.
+ (usage): Document them.
+
+ * src/preproc/html/pre-html.cpp (scanArguments): Add to
+ `getopt_long()` parameter, but ignore.
+
+ * src/devices/grohtml/grohtml.1.man (Synopsis, Options):
+ Document them.
+
* src/roff/groff/tests/output_driver_C_and_G_options_work.sh:
- Add regression test for *grohtml.
+ Test them.
* tmac/tmac.am (groff_TESTS): Run test.
+ Fixes 1/3rd of <https://savannah.gnu.org/bugs/index.php?60655>.
+
2021-05-22 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/preproc/html/pre-html.cpp (usage):
diff --git a/src/devices/grohtml/grohtml.1.man
b/src/devices/grohtml/grohtml.1.man
index 263fcb0..1bb34df 100644
--- a/src/devices/grohtml/grohtml.1.man
+++ b/src/devices/grohtml/grohtml.1.man
@@ -7,7 +7,7 @@ grohtml, post\-grohtml, pre\-grohtml \- groff output driver for
HTML
.\" Legal Terms
.\" ====================================================================
.\"
-.\" Copyright (C) 1999-2020 Free Software Foundation, Inc.
+.\" Copyright (C) 1999-2021 Free Software Foundation, Inc.
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
@@ -71,7 +71,7 @@ grohtml, post\-grohtml, pre\-grohtml \- groff output driver
for HTML
.
.
.SY post\-grohtml
-.RB [ \-bhlnrVy ]
+.RB [ \-bCGhlnrVy ]
.RB [ \-F
.IR font-directory ]
.RB [ \-j
@@ -218,6 +218,11 @@ Initialize the background color to white.
.
.
.TP
+.B \-C
+Suppress output of \[lq]CreationDate:\[rq] HTML comment.
+.
+.
+.TP
.BI \-D \~image-directory
Instruct
.I grohtml
@@ -257,6 +262,11 @@ usually
.
.
.TP
+.B \-G
+Suppress output of \[lq]Creator:\[rq] HTML comment.
+.
+.
+.TP
.BI \-g \~anti-aliasing-graphic-bits
Number of bits of antialiasing information to be used by
.I graphics
diff --git a/src/devices/grohtml/post-html.cpp
b/src/devices/grohtml/post-html.cpp
index 057cbe5..e451342 100644
--- a/src/devices/grohtml/post-html.cpp
+++ b/src/devices/grohtml/post-html.cpp
@@ -77,6 +77,8 @@ static int auto_rule = TRUE; /* by
default we enable an
static int simple_anchors = FALSE; /* default to anchors
with heading text */
static int manufacture_headings = FALSE; /* default is to use the
Hn html headings, */
/* rather than
manufacture our own. */
+static int do_write_creator_comment = TRUE; /* write Creator HTML
comment */
+static int do_write_date_comment = TRUE; /* write CreationDate
HTML comment */
static color *default_background = NULL; /* has user requested
initial bg color? */
static string job_name; /* if set then the output
is split into */
/* multiple files with
'job_name'-%d.html */
@@ -5007,16 +5009,20 @@ void html_printer::do_file_components (void)
if (dialect == xhtml)
writeHeadMetaStyle();
- html.begin_comment("Creator : ")
- .put_string("groff ")
- .put_string("version ")
- .put_string(Version_string)
- .end_comment();
+ if (do_write_creator_comment) {
+ html.begin_comment("Creator : ")
+ .put_string("groff ")
+ .put_string("version ")
+ .put_string(Version_string)
+ .end_comment();
+ }
- t = current_time();
- html.begin_comment("CreationDate: ")
- .put_string(ctime(&t), strlen(ctime(&t))-1)
- .end_comment();
+ if (do_write_date_comment) {
+ t = current_time();
+ html.begin_comment("CreationDate: ")
+ .put_string(ctime(&t), strlen(ctime(&t))-1)
+ .end_comment();
+ }
if (dialect == html4)
writeHeadMetaStyle();
@@ -5120,16 +5126,20 @@ html_printer::~html_printer()
if (dialect == xhtml)
writeHeadMetaStyle();
- html.begin_comment("Creator : ")
- .put_string("groff ")
- .put_string("version ")
- .put_string(Version_string)
- .end_comment();
+ if (do_write_creator_comment) {
+ html.begin_comment("Creator : ")
+ .put_string("groff ")
+ .put_string("version ")
+ .put_string(Version_string)
+ .end_comment();
+ }
- t = current_time();
- html.begin_comment("CreationDate: ")
- .put_string(ctime(&t), strlen(ctime(&t))-1)
- .end_comment();
+ if (do_write_date_comment) {
+ t = current_time();
+ html.begin_comment("CreationDate: ")
+ .put_string(ctime(&t), strlen(ctime(&t))-1)
+ .end_comment();
+ }
if (dialect == html4)
writeHeadMetaStyle();
@@ -5451,8 +5461,8 @@ int main(int argc, char **argv)
{ "version", no_argument, 0, 'v' },
{ NULL, 0, 0, 0 }
};
- while ((c = getopt_long(argc, argv, "a:bdD:eF:g:hi:I:j:lno:prs:S:vVx:y",
- long_options, NULL))
+ while ((c = getopt_long(argc, argv,
+ "a:bCdD:eF:g:Ghi:I:j:lno:prs:S:vVx:y", long_options, NULL))
!= EOF)
switch(c) {
case 'a':
@@ -5463,6 +5473,10 @@ int main(int argc, char **argv)
default_background = new color;
default_background->set_gray(color::MAX_COLOR_VAL);
break;
+ case 'C':
+ // Don't write CreationDate HTML comments.
+ do_write_date_comment = FALSE;
+ break;
case 'd':
/* handled by pre-html */
break;
@@ -5478,6 +5492,10 @@ int main(int argc, char **argv)
case 'g':
/* graphic antialiasing bits - handled by pre-html */
break;
+ case 'G':
+ // Don't write Creator HTML comments.
+ do_write_creator_comment = FALSE;
+ break;
case 'h':
/* do not use the Hn headings of html, but manufacture our own */
manufacture_headings = TRUE;
@@ -5554,7 +5572,7 @@ int main(int argc, char **argv)
static void usage(FILE *stream)
{
- fprintf(stream, "usage: %s [-bhlnrVy] [-F FONT-DIRECTORY]"
+ fprintf(stream, "usage: %s [-bCGhlnrVy] [-F FONT-DIRECTORY]"
" [-j OUTPUT-STEM] [-s BASE-POINT-SIZE] [-S HEADING-LEVEL]"
" [-x HTML-DIALECT] [FILE ...]\n",
program_name);
diff --git a/src/preproc/html/pre-html.cpp b/src/preproc/html/pre-html.cpp
index 041e385..2b80663 100644
--- a/src/preproc/html/pre-html.cpp
+++ b/src/preproc/html/pre-html.cpp
@@ -1587,8 +1587,8 @@ static int scanArguments(int argc, char **argv)
{ "version", no_argument, 0, 'v' },
{ NULL, 0, 0, 0 }
};
- while ((c = getopt_long(argc, argv, "+a:bdD:eF:g:hi:I:j:lno:prs:S:vVx:y",
- long_options, NULL))
+ while ((c = getopt_long(argc, argv,
+ "+a:bCdD:eF:g:Ghi:I:j:lno:prs:S:vVx:y", long_options, NULL))
!= EOF)
switch(c) {
case 'a':
@@ -1602,6 +1602,9 @@ static int scanArguments(int argc, char **argv)
case 'b':
// handled by post-grohtml (set background color to white)
break;
+ case 'C':
+ // handled by post-grohtml (don't write Creator HTML comment)
+ break;
case 'd':
#if defined(DEBUGGING)
debug = TRUE;
@@ -1624,6 +1627,9 @@ static int scanArguments(int argc, char **argv)
exit(1);
}
break;
+ case 'G':
+ // handled by post-grohtml (don't write CreationDate HTML comment)
+ break;
case 'h':
// handled by post-grohtml (write headings with font size changes)
break;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 06/07: [grohtml]: Implement -C and -G options.,
G. Branden Robinson <=