summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwlemb <wlemb>2002-05-22 21:51:16 +0000
committerwlemb <wlemb>2002-05-22 21:51:16 +0000
commit0aff73492920c1981a51fc6f4443736197a5666f (patch)
tree7dd5cc17b8294af19e5230c0a3ff4f4b8482cc00
parente83cbb022e9bf35bdf651e30eac64513f4598db8 (diff)
downloadgroff-0aff73492920c1981a51fc6f4443736197a5666f.tar.gz
Change syntax of \O: \O[0] suppresses output, \O[1] enables output
if at outer level; at start-up we are at outer level. * src/roff/troff/input.cc (do_suppress): Implement it. Simplify \O[3]. Add option -p to show progress information. pre-grohtml will now render only one page at a time, reducing the size of needed disk resources enormously. * src/preproc/html/pre-html.cc (imagePageStem): Replaced with... (imagePageName): New global variable. (psPageName, show_progress, currentPageNo): New global variables. (html_system): Close saved stderr and stdout handles. (write_end_image): Accept a parameter to control \O escape. (write_start_image): Adapted to new \O meaning. (char_buffer::write_upto_newline): Updated. (createAllPages): Replaced with... (createPage): This new function to create a single page for images. It uses `psselect' from the psutils package. (removeAllPages): Removed. (createImage): Updated. Handle progress display. (char_buffer::do_html, char_buffer::do_image) [DEBUGGING]: Removed. (scanArguments): Add option -p. (makeTempFiles): Updated to create temp files for psPageName and imagePageName. (removeTempFiles): Removed. (main): Updated. * src/devices/grohtml/post-html.cc (header_desc::write_headings, html_printer::write_header): Append `\0' to `buffer'. (html_printer::do_eol): Depend on `current_paragraph->emitted_text'. (main): Handle -p. * src/devices/grohtml/html-text.cc (html_text::dump_stack_element): Handle `text_emitted'. (html_text::table_is_void): Slightly rewritten. (stop): New external symbol. (html_text::do_push) [DEBUGGING]: Use it and simplify. (html_text::shutdown): Call `dump_stack'. (html_text::do_space): Rewritten. * src/devices/grohtml/grohtml.man: Document -p and the need of `psselect'. * tmac/www.tmac (DC, HTML-DO-IMAGE, HTML-IMAGE-END): Updated to new \O syntax. Call \O[0] if `ps4html' is active. * tmac/s.tmac (@EQ, @EN): Handle html better. (@TS, TE): Ditto. * tmac/html.tmac: Don't use black for background colour. * src/roff/troff/node.cc: Include `div.h'. (troff_output_file::really_print_line): Don't use `is_on'. (troff_output_file::word_marker, troff_output_file::flush_tbuf troff_output_file::check_charinfo, troff_output_file::put_char_width, troff_output_file::put_char, troff_output_file::determine_line_limits, troff_output_file::draw, real_output_file::begin_page, glyph_color_node::tprintf, fill_color_node::tprint, hline_node::tprint, vline_node::tprint): Use `is_on'. (troff_output_file::really_on): Call `do_motion'. (suppress_node::tprint): Use `get_page_number' instead of `%' register. Call `reset_output_registers' conditionally on `is_on'. * doc/groff.texinfo: Document new syntax of \O. * NEWS, man/groff_diff.man: Updated.
-rw-r--r--ChangeLog70
-rw-r--r--NEWS4
-rw-r--r--doc/groff.texinfo29
-rw-r--r--doc/pic.ms4
-rw-r--r--man/groff_diff.man20
-rw-r--r--src/devices/grohtml/grohtml.man10
-rw-r--r--src/devices/grohtml/html-text.cc38
-rw-r--r--src/devices/grohtml/post-html.cc20
-rw-r--r--src/preproc/html/pre-html.cc199
-rw-r--r--src/roff/troff/input.cc14
-rw-r--r--src/roff/troff/node.cc128
-rw-r--r--tmac/html.tmac3
-rw-r--r--tmac/s.tmac19
-rw-r--r--tmac/www.tmac16
14 files changed, 375 insertions, 199 deletions
diff --git a/ChangeLog b/ChangeLog
index 00e2c4ef..f1d3a6ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,73 @@
+2002-05-22 Gaius Mulley <gaius@glam.ac.uk>
+
+ Change syntax of \O: \O[0] suppresses output, \O[1] enables output
+ if at outer level; at start-up we are at outer level.
+
+ * src/roff/troff/input.cc (do_suppress): Implement it.
+ Simplify \O[3].
+
+ Add option -p to show progress information.
+ pre-grohtml will now render only one page at a time, reducing the
+ size of needed disk resources enormously.
+
+ * src/preproc/html/pre-html.cc (imagePageStem): Replaced with...
+ (imagePageName): New global variable.
+ (psPageName, show_progress, currentPageNo): New global variables.
+ (html_system): Close saved stderr and stdout handles.
+ (write_end_image): Accept a parameter to control \O escape.
+ (write_start_image): Adapted to new \O meaning.
+ (char_buffer::write_upto_newline): Updated.
+ (createAllPages): Replaced with...
+ (createPage): This new function to create a single page for images.
+ It uses `psselect' from the psutils package.
+ (removeAllPages): Removed.
+ (createImage): Updated.
+ Handle progress display.
+ (char_buffer::do_html, char_buffer::do_image) [DEBUGGING]: Removed.
+ (scanArguments): Add option -p.
+ (makeTempFiles): Updated to create temp files for psPageName and
+ imagePageName.
+ (removeTempFiles): Removed.
+ (main): Updated.
+
+ * src/devices/grohtml/post-html.cc (header_desc::write_headings,
+ html_printer::write_header): Append `\0' to `buffer'.
+ (html_printer::do_eol): Depend on `current_paragraph->emitted_text'.
+ (main): Handle -p.
+ * src/devices/grohtml/html-text.cc (html_text::dump_stack_element):
+ Handle `text_emitted'.
+ (html_text::table_is_void): Slightly rewritten.
+ (stop): New external symbol.
+ (html_text::do_push) [DEBUGGING]: Use it and simplify.
+ (html_text::shutdown): Call `dump_stack'.
+ (html_text::do_space): Rewritten.
+ * src/devices/grohtml/grohtml.man: Document -p and the need of
+ `psselect'.
+
+ * tmac/www.tmac (DC, HTML-DO-IMAGE, HTML-IMAGE-END): Updated to
+ new \O syntax.
+ Call \O[0] if `ps4html' is active.
+ * tmac/s.tmac (@EQ, @EN): Handle html better.
+ (@TS, TE): Ditto.
+ * tmac/html.tmac: Don't use black for background colour.
+
+ * src/roff/troff/node.cc: Include `div.h'.
+ (troff_output_file::really_print_line): Don't use `is_on'.
+ (troff_output_file::word_marker, troff_output_file::flush_tbuf
+ troff_output_file::check_charinfo,
+ troff_output_file::put_char_width, troff_output_file::put_char,
+ troff_output_file::determine_line_limits, troff_output_file::draw,
+ real_output_file::begin_page, glyph_color_node::tprintf,
+ fill_color_node::tprint, hline_node::tprint, vline_node::tprint):
+ Use `is_on'.
+ (troff_output_file::really_on): Call `do_motion'.
+ (suppress_node::tprint): Use `get_page_number' instead of `%'
+ register.
+ Call `reset_output_registers' conditionally on `is_on'.
+
+ * doc/groff.texinfo: Document new syntax of \O.
+ * NEWS, man/groff_diff.man: Updated.
+
2002-05-22 Werner LEMBERG <wl@gnu.org>
* MORE.STUFF: Add info about David Frey's deroff implementation.
diff --git a/NEWS b/NEWS
index fe2badbf..102c7708 100644
--- a/NEWS
+++ b/NEWS
@@ -142,8 +142,8 @@ o For compatibility with plan 9's troff, multiple `pi' requests are
.pi foo | bar
-o A new escape sequence `\O' is available (mainly for internal use with
- grohtml). Please see groff_diff.7 and groff.texinfo for more details.
+o A new escape sequence `\O' is available to disable and enable glyph
+ output. Please see groff_diff.7 and groff.texinfo for more details.
o The escapes `\%', `\&', `\)', and `\:' no longer cause an error in \X;
they are ignored now.
diff --git a/doc/groff.texinfo b/doc/groff.texinfo
index ab425733..1d9f3c1b 100644
--- a/doc/groff.texinfo
+++ b/doc/groff.texinfo
@@ -11072,9 +11072,9 @@ Disable or enable output depending on the value of @var{num}:
@table @samp
@item \O0
-Disable any glyphs from being emitted to the device driver,
-provided that the escape occurs at the outer level (see @code{\O3} and
-@code{\O4}).
+Disable any glyphs from being emitted to the device driver, provided that
+the escape occurs at the outer level (see @code{\O[3]} and @code{\O[4]}).
+Motion is not suppressed so effectively @code{\O[0]} means @emph{pen up}.
@item \O1
Enable output of glyphs, provided that the escape occurs at the outer
@@ -11090,6 +11090,19 @@ level.
@xref{Register Index}. These four registers mark the top left and
bottom right hand corners of a box which encompasses all written glyphs.
+For example the input text:
+
+@Example
+Hello \O[0]world \O[1]this is a test.
+@endExample
+
+@noindent
+produces the following output:
+
+@Example
+Hello this is a test.
+@endExample
+
@table @samp
@item \O2
Provided that the escape occurs at the outer level, enable output of
@@ -11098,17 +11111,12 @@ registers encompassing the glyphs previously written since the last call
to @code{\O}.
@item \O3
-Begin a nesting level. This is really an internal mechanism for
-@code{grohtml} while producing images. They are generated by running
-the troff source through troff to the PostScript device and GhostScript
-to produce images in PNG format. The @code{\O3} escape will start a new
-page if the device is not html (to reduce the possibility of images
-crossing a page boundary).
+Begin a nesting level. At start-up, @code{gtroff} is at outer level.
@item \O4
End a nesting level.
-@item \O[5Pfilename]
+@item \O[5@var{P}@var{filename}]
This escape is @code{grohtml} specific. Provided that this escape
occurs at the outer nesting level write the @code{filename} to
@code{stderr}. The position of the image, @var{P}, must be specified
@@ -11118,7 +11126,6 @@ production of the next inline image.
@end table
@endDefesc
-
@c =====================================================================
@node Colors, I/O, Suppressing output, gtroff Reference
diff --git a/doc/pic.ms b/doc/pic.ms
index dcbddb19..b85e8b98 100644
--- a/doc/pic.ms
+++ b/doc/pic.ms
@@ -10,7 +10,7 @@
.\" This document was written for free use and redistribution by
.\" Eric S. Raymond <esr@thyrsus.com> in August 1995.
.\"
-.\" $Id: pic.ms,v 1.14 2002/05/17 12:09:09 wlemb Exp $
+.\" $Id: pic.ms,v 1.15 2002/05/22 21:51:17 wlemb Exp $
.\"
.\" Set a proper TeX
.ie t .ds tx T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
@@ -830,7 +830,7 @@ object) as \fB5th ""\fP.
.PP
Objects are also numbered backwards by type from the last one.
You can say \fB2nd last box\fP to get the second-to-last box, or
-\fB3rd last ellipse\fP to get the third-to-last box.
+\fB3rd last ellipse\fP to get the third-to-last ellipse.
.PP
In places where \fIn\/\fBth\fR is allowed, \fB`\fIexpr\/\fB'th\fR is
also allowed. Note that
diff --git a/man/groff_diff.man b/man/groff_diff.man
index 8944c260..6cec4a5a 100644
--- a/man/groff_diff.man
+++ b/man/groff_diff.man
@@ -3,7 +3,7 @@
.ig
groff_diff.man
-Last update : 11 May 2002
+Last update : 22 May 2002
This file is part of groff, the GNU roff type-setting system.
It is the source of the man-page groff_diff(7).
@@ -495,6 +495,8 @@ escape sequence is the only way to use these.
.
.TP
.BI \[rs]O n
+.TQ
+.BI \[rs]O[ n ]
Suppressing troff output.
.
The escapes
@@ -545,12 +547,20 @@ encompassing the glyphs previously written since the last call to
.B \[rs]O3
Begin a nesting level.
.
+At start-up,
+.B troff
+is at outer level.
+.
This is really an internal mechanism for
.B \%grohtml
while producing images.
.
-They are generated by running the troff source through troff to the
-postscript device and ghostscript to produce images in PNG format.
+They are generated by running the troff source through
+.B troff
+to the postscript device and
+.B ghostscript
+to produce images in PNG format.
+.
The
.B \[rs]O3
escape will start a new page if the device is not html (to reduce the
@@ -559,6 +569,7 @@ possibility of images crossing a page boundary).
.TP
.B \[rs]O4
End a nesting level.
+.
.TP
.BI \[rs]O5[ Pfilename ]
This escape is
@@ -571,8 +582,9 @@ to stderr.
.
The position of the image,
.IR P ,
-must be specified and must be one of l, r, c or i (left, right,
+must be specified and must be one of l, r, c, or i (left, right,
centered, inline).
+.
.I filename
will be associated with the production of the next inline image.
.RE
diff --git a/src/devices/grohtml/grohtml.man b/src/devices/grohtml/grohtml.man
index 4e72fa8d..d8693e37 100644
--- a/src/devices/grohtml/grohtml.man
+++ b/src/devices/grohtml/grohtml.man
@@ -142,6 +142,11 @@ This can cause problems when a heading contains a `?' on some browsers
(netscape).
This flag is automatically turned on if a heading contains an image.
.TP
+.B -p
+Display page rendering progress to stderr.
+.B grohtml
+only displays a page number when an image is required.
+.TP
.BI \-F dir
Prepend directory
.IB dir /dev name
@@ -193,6 +198,11 @@ and GhostScript
and
.B \%pnmcut
from the netpbm package (version 9.16 or greater) will work also.
+It is also dependent upon
+.B \%psselect
+from the
+.B PSUtils
+package.
Images are generated whenever a table, picture, equation or line is
encountered.
.SH BUGS
diff --git a/src/devices/grohtml/html-text.cc b/src/devices/grohtml/html-text.cc
index 67f02f4a..8da70982 100644
--- a/src/devices/grohtml/html-text.cc
+++ b/src/devices/grohtml/html-text.cc
@@ -101,6 +101,8 @@ void html_text::dump_stack_element (tag_definition *p)
}
default: fprintf(stderr, "unknown tag");
}
+ if (p->text_emitted)
+ fprintf(stderr, "[t] ");
}
/*
@@ -222,11 +224,23 @@ void html_text::start_tag (tag_definition *t)
int html_text::table_is_void (tag_definition *t)
{
- if (linelength > 0) {
- return current_indentation*100/linelength <= 0;
- } else {
- return FALSE;
+#if 1
+ return (linelength > 0
+ && current_indentation*100/linelength <= 0);
+
+#else
+ if (t->next != NULL
+ && linelength > 0
+ && current_indentation*100/linelength <= 0) {
+ t = t->next;
+ while (t != NULL) {
+ if (t->text_emitted)
+ return FALSE;
+ t = t->next;
+ }
}
+ return TRUE;
+#endif
}
void html_text::issue_table_begin (char *arg)
@@ -292,6 +306,7 @@ int html_text::is_present (HTML_TAG t)
return FALSE;
}
+extern void stop();
/*
* do_push - places, tag_definition, p, onto the stack
@@ -302,8 +317,10 @@ void html_text::do_push (tag_definition *p)
HTML_TAG t = p->type;
#if defined(DEBUGGING)
+ if (t == PRE_TAG)
+ stop();
debugStack = TRUE;
- fprintf(stderr, "entering do_push (");
+ fprintf(stderr, "\nentering do_push (");
dump_stack_element(p);
fprintf(stderr, ")\n");
dump_stack();
@@ -357,10 +374,6 @@ void html_text::do_push (tag_definition *p)
#if defined(DEBUGGING)
dump_stack();
- if (stackptr && (stackptr->type == COLOR_TAG) &&
- stackptr->next && (stackptr->next->type == TABLE_TAG) &&
- stackptr->next->next && (stackptr->next->next->type == P_TAG))
-
fprintf(stderr, "exiting do_push\n");
#endif
}
@@ -547,6 +560,7 @@ char *html_text::shutdown (HTML_TAG t)
tag_definition *temp =NULL;
int notext =TRUE;
+ dump_stack();
while ((stackptr != NULL) && (stackptr->type != t)) {
notext = (notext && (! stackptr->text_emitted));
if (! notext) {
@@ -765,12 +779,10 @@ char *html_text::done_para (void)
void html_text::do_space (void)
{
- if (is_in_pre())
- do_emittext("", 0);
- else {
+ if (! is_in_pre()) {
do_para(done_para());
+ space_emitted = TRUE;
}
- space_emitted = TRUE;
}
/*
diff --git a/src/devices/grohtml/post-html.cc b/src/devices/grohtml/post-html.cc
index 43e52896..85a556eb 100644
--- a/src/devices/grohtml/post-html.cc
+++ b/src/devices/grohtml/post-html.cc
@@ -1134,6 +1134,7 @@ void header_desc::write_headings (FILE *f, int force)
string buffer(ANCHOR_TEMPLATE);
buffer += as_string(h);
+ buffer += '\0';
fprintf(f, buffer.contents());
} else
fputs(g->text_string, f);
@@ -1594,6 +1595,7 @@ void html_printer::write_header (void)
string buffer(ANCHOR_TEMPLATE);
buffer += as_string(header.no_of_headings);
+ buffer += '\0';
html.put_string(buffer.contents());
} else {
html.put_string(header.header_buffer);
@@ -1896,14 +1898,17 @@ void html_printer::do_fill (int on)
void html_printer::do_eol (void)
{
if (! fill_on) {
- current_paragraph->do_newline();
- current_paragraph->do_break();
+ if (current_paragraph->emitted_text()) {
+ current_paragraph->do_newline();
+ current_paragraph->do_break();
+ }
}
output_hpos = indentation+pageoffset;
if (end_center > 0) {
- if (end_center > 1) {
- current_paragraph->do_break();
- }
+ if (end_center > 1)
+ if (current_paragraph->emitted_text())
+ current_paragraph->do_break();
+
end_center--;
if (end_center == 0) {
current_paragraph->done_para();
@@ -2832,7 +2837,7 @@ int main(int argc, char **argv)
{ "version", no_argument, 0, 'v' },
{ NULL, 0, 0, 0 }
};
- while ((c = getopt_long(argc, argv, "a:g:o:i:I:D:F:vbdhlrn", long_options, NULL))
+ while ((c = getopt_long(argc, argv, "a:g:o:i:I:D:F:vbdhlrnp", long_options, NULL))
!= EOF)
switch(c) {
case 'v':
@@ -2869,6 +2874,9 @@ int main(int argc, char **argv)
case 'o':
/* handled by pre-html */
break;
+ case 'p':
+ /* handled by pre-html */
+ break;
case 'i':
/* handled by pre-html */
break;
diff --git a/src/preproc/html/pre-html.cc b/src/preproc/html/pre-html.cc
index 84697589..48edbf2c 100644
--- a/src/preproc/html/pre-html.cc
+++ b/src/preproc/html/pre-html.cc
@@ -96,8 +96,9 @@ static int stdoutfd = 1; // output file descriptor - norm
static int copyofstdoutfd =-1; // a copy of stdout, so we can restore stdout when
// writing to post-html
static char *psFileName = NULL; // name of postscript file
+static char *psPageName = NULL; // name of file containing postscript current page
static char *regionFileName = NULL; // name of file containing all image regions
-static char *imagePageStem = NULL; // stem of all files containing page images
+static char *imagePageName = NULL; // name of bitmap image containing current page
static char *image_device = "pnmraw";
static int image_res = DEFAULT_IMAGE_RES;
static int vertical_offset = 0;
@@ -109,6 +110,8 @@ static char *gsPaper = NULL; // the paper size that gs must u
static int textAlphaBits = MAX_ALPHA_BITS;
static int graphicAlphaBits = MAX_ALPHA_BITS;
static char *antiAlias = NULL; // antialias arguments we pass to gs.
+static int show_progress = FALSE; // should we display page numbers as they are processed?
+static int currentPageNo = -1; // current image page number
#if defined(DEBUGGING)
static int debug = FALSE;
static char *troffFileName = NULL; // output of pre-html output which is sent to troff -Tps
@@ -227,6 +230,8 @@ void html_system(const char *s, int redirect_stdout)
fprintf(stderr, "Calling `%s' failed\n", s);
else if (status)
fprintf(stderr, "Calling `%s' returned status %d\n", s, status);
+ close(save_stderr);
+ close(save_stdout);
}
/*
@@ -467,7 +472,7 @@ static void checkImageDir (void)
* write_end_image - ends the image. It writes out the image extents if we are using -Tps.
*/
-static void write_end_image (void)
+static void write_end_image (int is_html)
{
/*
* if we are producing html then these
@@ -477,7 +482,11 @@ static void write_end_image (void)
* in which case these generate image
* boundaries
*/
- writeString("\\O[2]\\O[1]\\O[4]");
+ writeString("\\O[4]\\O[2]");
+ if (is_html)
+ writeString("\\O[1]");
+ else
+ writeString("\\O[0]");
}
/*
@@ -490,7 +499,7 @@ static void write_end_image (void)
static void write_start_image (IMAGE_ALIGNMENT pos, int is_html)
{
- writeString("\\O[3]\\O[5");
+ writeString("\\O[5");
switch (pos) {
case INLINE:
@@ -509,10 +518,10 @@ static void write_start_image (IMAGE_ALIGNMENT pos, int is_html)
}
writeString(image_template); writeString(".png]");
if (is_html)
- writeString("\\O[0]");
+ writeString("\\O[0]\\O[3]");
else
// reset min/max registers
- writeString("\\O[1]");
+ writeString("\\O[1]\\O[3]");
}
/*
@@ -538,7 +547,7 @@ void char_buffer::write_upto_newline (char_block **t, int *i, int is_html)
if (can_see(t, &j, HTML_IMAGE_INLINE_BEGIN))
write_start_image(INLINE, is_html);
else if (can_see(t, &j, HTML_IMAGE_INLINE_END))
- write_end_image();
+ write_end_image(is_html);
else {
if (j < (*t)->used) {
*i = j;
@@ -748,33 +757,54 @@ imageList::~imageList ()
}
/*
- * createAllPages - creates a set of images, one per page.
+ * createPage - creates one image of, page pageno, from the postscript file.
*/
-static int createAllPages (void)
+static int createPage (int pageno)
{
- char buffer[4096];
char *s;
- imagePageStem = xtmptemplate(PAGE_TEMPLATE_LONG, PAGE_TEMPLATE_SHORT);
- strcpy(buffer, imagePageStem);
+ if (currentPageNo == pageno)
+ return 0;
- if (mksdir(imagePageStem) < 0) {
- sys_fatal("mksdir");
- return -1;
+ if (currentPageNo >= 1) {
+ unlink(imagePageName);
+ unlink(psPageName);
+ }
+
+ if (show_progress) {
+ fprintf(stderr, "[%d] ", pageno);
+ fflush(stderr);
}
+#if defined(DEBUGGING)
+ if (debug)
+ fprintf(stderr, "creating page %d\n", pageno);
+#endif
+
+ s = make_message("psselect -q -p%d %s %s\n",
+ pageno, psFileName, psPageName);
+
+ if (s == NULL)
+ sys_fatal("make_message");
+#if defined(DEBUGGING)
+ if (debug) {
+ fwrite(s, sizeof(char), strlen(s), stderr);
+ fflush(stderr);
+ }
+#endif
+ html_system(s, 1);
+
s = make_message("echo showpage | "
- "%s%s %s -q -dSAFER -sDEVICE=%s -r%d %s"
- "-sOutputFile=%s/%%d %s -",
- GS_NAME,
+ "gs%s %s -q -dBATCH -dSAFER -sDEVICE=%s -r%d %s"
+ "-sOutputFile=%s %s -\n",
EXE_EXT,
gsPaper,
image_device,
image_res,
antiAlias,
- imagePageStem,
- psFileName);
+ imagePageName,
+ psPageName);
if (s == NULL)
sys_fatal("make_message");
#if defined(DEBUGGING)
@@ -785,30 +815,11 @@ static int createAllPages (void)
#endif
html_system(s, 1);
a_delete s;
+ currentPageNo = pageno;
return 0;
}
/*
- * removeAllPages - removes all page images.
- */
-
-static void removeAllPages (void)
-{
- char *s=NULL;
- int i=1;
-
- do {
- if (s)
- a_delete s;
- s = make_message("%s/%d", imagePageStem, i);
- if (s == NULL)
- sys_fatal("make_message");
- i++;
- } while (unlink(s) == 0);
- rmdir(imagePageStem);
-}
-
-/*
* min - returns the minimum of two numbers.
*/
@@ -846,25 +857,29 @@ static void createImage (imageItem *i)
int y1 = max((image_res*vertical_offset/72)+min(i->Y1, i->Y2)*image_res/postscriptRes-IMAGE_BOARDER_PIXELS, 0);
int x2 = max(i->X1, i->X2)*image_res/postscriptRes+1*IMAGE_BOARDER_PIXELS;
int y2 = (image_res*vertical_offset/72)+(max(i->Y1, i->Y2)*image_res/postscriptRes)+1+IMAGE_BOARDER_PIXELS;
- s = make_message("pnmcut%s %d %d %d %d < %s/%d | pnmcrop -quiet | pnmtopng%s %s > %s \n",
- EXE_EXT,
- x1, y1, x2-x1+1, y2-y1+1,
- imagePageStem,
- i->pageNo,
- EXE_EXT,
- TRANSPARENT,
- i->imageName);
- if (s == NULL)
- sys_fatal("make_message");
+ if (createPage(i->pageNo) == 0) {
+ s = make_message("pnmcut%s %d %d %d %d < %s | pnmcrop -quiet | pnmtopng%s %s > %s \n",
+ EXE_EXT,
+ x1, y1, x2-x1+1, y2-y1+1,
+ imagePageName,
+ EXE_EXT,
+ TRANSPARENT,
+ i->imageName);
+ if (s == NULL)
+ sys_fatal("make_message");
#if defined(DEBUGGING)
- if (debug) {
- fprintf(stderr, s);
+ if (debug) {
+ fprintf(stderr, s);
+ fflush(stderr);
+ }
+#endif
+ html_system(s, 0);
+ a_delete s;
+ } else {
+ fprintf(stderr, "failed to generate image of page %d\n", i->pageNo);
fflush(stderr);
}
-#endif
- html_system(s, 0);
- a_delete s;
#if defined(DEBUGGING)
} else {
if (debug) {
@@ -958,6 +973,10 @@ static void generateImages (char *regionFileName)
fputc(f->getPB(), stderr);
}
}
+ if (show_progress) {
+ fprintf(stderr, "done\n");
+ fflush(stderr);
+ }
}
/*
@@ -1114,15 +1133,6 @@ int char_buffer::do_html(int argc, char *argv[])
argv = addRegDef(argc, argv, s.contents());
argc++;
-#if defined(DEBUGGING)
- if (debug) {
- dump_args(argc, argv);
- writeString("\n<<< html ************** \n");
- write_file_html();
- return 0;
- }
-#else
-
if (pipe(pdes) < 0)
sys_fatal("pipe");
@@ -1162,7 +1172,6 @@ int char_buffer::do_html(int argc, char *argv[])
write_file_html();
waitForChild(pid);
}
-#endif
return 0;
}
@@ -1188,11 +1197,6 @@ int char_buffer::do_image(int argc, char *argv[])
argv = addRegDef(argc, argv, s.contents());
argc++;
-#if defined(DEBUGGING)
- if (debug)
- dump_args(argc, argv);
-#endif
-
if (pipe(pdes) < 0)
sys_fatal("pipe");
@@ -1269,7 +1273,7 @@ int scanArguments (int argc, char **argv)
{ "version", no_argument, 0, 'v' },
{ NULL, 0, 0, 0 }
};
- while ((c = getopt_long(argc, argv, "+a:g:o:i:I:D:F:vbdhlrn", long_options, NULL))
+ while ((c = getopt_long(argc, argv, "+a:g:o:i:I:D:F:vbdhlrnp", long_options, NULL))
!= EOF)
switch(c) {
case 'v':
@@ -1308,6 +1312,9 @@ int scanArguments (int argc, char **argv)
vertical_offset = atoi(optarg);
gsPaper = ""; // do not specify the paper size now
break;
+ case 'p':
+ show_progress = TRUE;
+ break;
case 'd':
#if defined(DEBUGGING)
debug = TRUE;
@@ -1350,13 +1357,34 @@ static int makeTempFiles (void)
#if defined(DEBUGGING)
psFileName = "/tmp/prehtml-ps";
regionFileName = "/tmp/prehtml-region";
- imagePageStem = "/tmp/prehtml-page";
+ imagePageName = "/tmp/prehtml-page";
+ psPageName = "/tmp/prehtml-psn";
troffFileName = "/tmp/prehtml-troff";
htmlFileName = "/tmp/prehtml-html";
#else
-
FILE *f;
+ /* psPageName contains a single page of postscript */
+ f = xtmpfile(&psPageName,
+ PS_TEMPLATE_LONG, PS_TEMPLATE_SHORT,
+ FALSE);
+ if (f == NULL) {
+ sys_fatal("xtmpfile");
+ return -1;
+ }
+ fclose(f);
+
+ /* imagePageName contains a bitmap image of the single postscript page */
+ f = xtmpfile(&imagePageName,
+ PAGE_TEMPLATE_LONG, PAGE_TEMPLATE_SHORT,
+ FALSE);
+ if (f == NULL) {
+ sys_fatal("xtmpfile");
+ return -1;
+ }
+ fclose(f);
+
+ /* psFileName contains a postscript file of the complete document */
f = xtmpfile(&psFileName,
PS_TEMPLATE_LONG, PS_TEMPLATE_SHORT,
FALSE);
@@ -1365,6 +1393,8 @@ static int makeTempFiles (void)
return -1;
}
fclose(f);
+
+ /* regionFileName contains a list of the images and their boxed coordinates */
f = xtmpfile(&regionFileName,
REGION_TEMPLATE_LONG, REGION_TEMPLATE_SHORT,
FALSE);
@@ -1378,20 +1408,6 @@ static int makeTempFiles (void)
return 0;
}
-/*
- * removeTempFiles - remove the temporary files
- */
-
-static void removeTempFiles (void)
-{
-#if defined(DEBUGGING)
- if (debug)
- return;
-#endif
- unlink(psFileName);
- unlink(regionFileName);
-}
-
int main(int argc, char **argv)
{
program_name = argv[0];
@@ -1426,14 +1442,9 @@ int main(int argc, char **argv)
return 1;
ok = inputFile.do_image(argc, argv);
if (ok == 0) {
- ok = createAllPages();
- if (ok == 0) {
- generateImages(regionFileName);
- ok = inputFile.do_html(argc, argv);
- removeAllPages();
- }
+ generateImages(regionFileName);
+ ok = inputFile.do_html(argc, argv);
}
- removeTempFiles();
return ok;
}
diff --git a/src/roff/troff/input.cc b/src/roff/troff/input.cc
index d3ff2ea3..9f04e37c 100644
--- a/src/roff/troff/input.cc
+++ b/src/roff/troff/input.cc
@@ -4663,19 +4663,23 @@ static node *do_suppress(symbol nm)
const char *s = nm.contents();
switch (*s) {
case '0':
- if (begin_level == 1)
+ if (begin_level == 0)
+ // suppress generation of glyphs
return new suppress_node(0, 0);
break;
case '1':
- if (begin_level == 1)
+ if (begin_level == 0)
+ // enable generation of glyphs
return new suppress_node(1, 0);
break;
case '2':
- if (begin_level == 1)
+ if (begin_level == 0)
return new suppress_node(1, 1);
break;
case '3':
begin_level++;
+#if 0
+ // say goodbye to all this code ?
if ((begin_level == 1) && (!is_html)) {
if (curdiv == topdiv) {
if (topdiv->before_first_page) {
@@ -4700,6 +4704,8 @@ static node *do_suppress(symbol nm)
}
}
}
+ // say goodbye to all this code?
+#endif
break;
case '4':
begin_level--;
@@ -4725,7 +4731,7 @@ static node *do_suppress(symbol nm)
return 0;
}
image_no++;
- if (begin_level == 1)
+ if (begin_level == 0)
return new suppress_node(symbol(s), position, image_no);
}
break;
diff --git a/src/roff/troff/node.cc b/src/roff/troff/node.cc
index 61177771..afdef9c0 100644
--- a/src/roff/troff/node.cc
+++ b/src/roff/troff/node.cc
@@ -36,6 +36,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "font.h"
#include "reg.h"
#include "input.h"
+#include "div.h"
#include "geometry.h"
#include "nonposix.h"
@@ -670,7 +671,7 @@ class real_output_file : public output_file {
int piped;
#endif
int printing; // decision via optional page list
- int output_on; // .output 1 or .output 0 requests
+ int output_on; // \O[0] or \O[1] escape calls
virtual void really_transparent_char(unsigned char) = 0;
virtual void really_print_line(hunits x, vunits y, node *n,
vunits before, vunits after, hunits width) = 0;
@@ -866,8 +867,7 @@ void troff_output_file::really_print_line(hunits x, vunits y, node *n,
{
moveto(x, y);
while (n != 0) {
- if (is_on() || (n->force_tprint()))
- n->tprint(this);
+ n->tprint(this);
n = n->next;
}
flush_tbuf();
@@ -886,7 +886,8 @@ void troff_output_file::really_print_line(hunits x, vunits y, node *n,
inline void troff_output_file::word_marker()
{
flush_tbuf();
- put('w');
+ if (is_on())
+ put('w');
}
inline void troff_output_file::right(hunits n)
@@ -942,6 +943,11 @@ void troff_output_file::do_motion()
void troff_output_file::flush_tbuf()
{
+ if (!is_on()) {
+ tbuf_len = 0;
+ return;
+ }
+
if (tbuf_len == 0)
return;
if (tbuf_kern == 0)
@@ -962,6 +968,9 @@ void troff_output_file::flush_tbuf()
void troff_output_file::check_charinfo(tfont *tf, charinfo *ci)
{
+ if (!is_on())
+ return;
+
int height = tf->get_char_height(ci).to_units();
int width = tf->get_width(ci).to_units()
+ tf->get_italic_correction(ci).to_units();
@@ -973,12 +982,17 @@ void troff_output_file::check_charinfo(tfont *tf, charinfo *ci)
void troff_output_file::put_char_width(charinfo *ci, tfont *tf, hunits w,
hunits k)
{
+ int kk = k.to_units();
+ if (!is_on()) {
+ flush_tbuf();
+ hpos += w.to_units() + kk;
+ return;
+ }
if (tf != current_tfont) {
flush_tbuf();
set_font(tf);
}
char c = ci->get_ascii_code();
- int kk = k.to_units();
if (c == '\0') {
flush_tbuf();
do_motion();
@@ -1041,6 +1055,9 @@ void troff_output_file::put_char_width(charinfo *ci, tfont *tf, hunits w,
void troff_output_file::put_char(charinfo *ci, tfont *tf)
{
flush_tbuf();
+ if (!is_on())
+ return;
+
if (tf != current_tfont)
set_font(tf);
char c = ci->get_ascii_code();
@@ -1238,6 +1255,10 @@ void troff_output_file::determine_line_limits(char code, hvpair *point,
int npoints)
{
int i, x, y;
+
+ if (!is_on())
+ return;
+
switch (code) {
case 'c':
case 'C':
@@ -1318,32 +1339,33 @@ void troff_output_file::determine_line_limits(char code, hvpair *point,
void troff_output_file::draw(char code, hvpair *point, int npoints,
font_size fsize)
{
+ int i;
flush_tbuf();
do_motion();
- int size = fsize.to_scaled_points();
- if (current_size != size) {
- put('s');
- put(size);
- put('\n');
- current_size = size;
- current_tfont = 0;
- }
- put('D');
- put(code);
- int i;
- if (code == 'c') {
- put(' ');
- put(point[0].h.to_units());
- }
- else
- for (i = 0; i < npoints; i++) {
- put(' ');
- put(point[i].h.to_units());
+ if (is_on()) {
+ int size = fsize.to_scaled_points();
+ if (current_size != size) {
+ put('s');
+ put(size);
+ put('\n');
+ current_size = size;
+ current_tfont = 0;
+ }
+ put('D');
+ put(code);
+ if (code == 'c') {
put(' ');
- put(point[i].v.to_units());
+ put(point[0].h.to_units());
}
-
- determine_line_limits(code, point, npoints);
+ else
+ for (i = 0; i < npoints; i++) {
+ put(' ');
+ put(point[i].h.to_units());
+ put(' ');
+ put(point[i].v.to_units());
+ }
+ determine_line_limits(code, point, npoints);
+ }
for (i = 0; i < npoints; i++)
output_hpos += point[i].h.to_units();
@@ -1353,12 +1375,15 @@ void troff_output_file::draw(char code, hvpair *point, int npoints,
output_vpos += point[i].v.to_units();
vpos = output_vpos;
}
- put('\n');
+ if (is_on())
+ put('\n');
}
void troff_output_file::really_on ()
{
flush_tbuf();
+ force_motion = 1;
+ do_motion();
}
void troff_output_file::really_off ()
@@ -1558,7 +1583,7 @@ int real_output_file::is_printing()
void real_output_file::begin_page(int pageno, vunits page_length)
{
printing = in_output_page_list(pageno);
- if (printing && output_on)
+ if (printing)
really_begin_page(pageno, page_length);
}
@@ -1600,9 +1625,8 @@ void real_output_file::really_put_filename(const char *filename)
void real_output_file::on()
{
really_on();
- if (output_on == 0) {
+ if (output_on == 0)
output_on = 1;
- }
}
void real_output_file::off()
@@ -1613,7 +1637,7 @@ void real_output_file::off()
int real_output_file::is_on()
{
- return( output_on );
+ return output_on;
}
void real_output_file::really_on()
@@ -3659,7 +3683,7 @@ inline int min(int a, int b)
void suppress_node::tprint(troff_output_file *out)
{
- int current_page = get_reg_int("%");
+ int current_page = topdiv->get_page_number();
// firstly check to see whether this suppress node contains
// an image filename & position.
if (is_on == 2) {
@@ -3667,6 +3691,7 @@ void suppress_node::tprint(troff_output_file *out)
last_position = position;
last_image_filename = strdup(filename.contents());
last_image_id = image_id;
+ // printf("start of image and page = %d\n", current_page);
}
else {
// now check whether the suppress node requires us to issue limits.
@@ -3705,11 +3730,15 @@ void suppress_node::tprint(troff_output_file *out)
if (suppress_start_page > 0 && current_page != suppress_start_page)
error("suppression limit registers span more than one page;\n"
"image description %1 will be wrong", image_no);
+ // if (topdiv->get_page_number() != suppress_start_page)
+ // fprintf(stderr, "end of image and topdiv page = %d and suppress_start_page = %d\n",
+ // topdiv->get_page_number(), suppress_start_page);
+
// remember that the filename will contain a %d in which the
// image_no is placed
fprintf(stderr,
"grohtml-info:page %d %d %d %d %d %d %s %d %d %s\n",
- current_page,
+ topdiv->get_page_number(),
get_reg_int("opminx"), get_reg_int("opminy"),
get_reg_int("opmaxx"), get_reg_int("opmaxy"),
// page offset + line length
@@ -3719,12 +3748,13 @@ void suppress_node::tprint(troff_output_file *out)
}
}
else {
- if (is_on)
+ if (is_on) {
out->on();
+ // lastly we reset the output registers
+ reset_output_registers(out->get_vpos());
+ }
else
out->off();
- // lastly we reset the output registers
- reset_output_registers(out->get_vpos());
suppress_start_page = current_page;
}
}
@@ -3774,7 +3804,8 @@ hunits glyph_color_node::width()
void glyph_color_node::tprint(troff_output_file *out)
{
- out->glyph_color(c);
+ if (out->is_on())
+ out->glyph_color(c);
}
/* page color_node */
@@ -3811,7 +3842,8 @@ hunits fill_color_node::width()
void fill_color_node::tprint(troff_output_file *out)
{
- out->fill_color(c);
+ if (out->is_on())
+ out->fill_color(c);
}
/* composite_node */
@@ -4222,20 +4254,23 @@ void hline_node::tprint(troff_output_file *out)
hunits xx = x - w;
hunits xx2 = xx/2;
out->right(xx2);
- n->tprint(out);
+ if (out->is_on())
+ n->tprint(out);
out->right(xx - xx2);
}
else {
hunits rem = x - w*i;
if (rem > H0)
if (n->overlaps_horizontally()) {
- n->tprint(out);
+ if (out->is_on())
+ n->tprint(out);
out->right(rem - w);
}
else
out->right(rem);
while (--i >= 0)
- n->tprint(out);
+ if (out->is_on())
+ n->tprint(out);
}
}
@@ -4264,11 +4299,13 @@ void vline_node::tprint(troff_output_file *out)
if (overlaps) {
n->zero_width_tprint(out);
out->down(-rem);
- n->tprint(out);
+ if (out->is_on())
+ n->tprint(out);
out->down(-h);
}
else {
- n->tprint(out);
+ if (out->is_on())
+ n->tprint(out);
out->down(-h - rem);
}
}
@@ -4289,7 +4326,8 @@ void vline_node::tprint(troff_output_file *out)
n->zero_width_tprint(out);
out->down(h);
}
- n->tprint(out);
+ if (out->is_on())
+ n->tprint(out);
}
}
}
diff --git a/tmac/html.tmac b/tmac/html.tmac
index bd4ec423..f016330d 100644
--- a/tmac/html.tmac
+++ b/tmac/html.tmac
@@ -701,9 +701,6 @@
.defcolor yellow1 rgb #fffc17
.defcolor yellowgreen rgb #52d017
.
-.\" set default glyph color to black (leave the background color alone)
-\m[black]\c
-.
.cp \n(_C
.
.if !\n(_C \
diff --git a/tmac/s.tmac b/tmac/s.tmac
index 7597374f..7fd95aee 100644
--- a/tmac/s.tmac
+++ b/tmac/s.tmac
@@ -1569,7 +1569,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
. HTML-IMAGE-INLINE
.\}
.if \\n[eqn*type]=2 .HTML-IMAGE
-.nf
+.if !'\*(.T'html' .nf
..
.de @div-end!eqn*div
.@EN
@@ -1583,12 +1583,16 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
. nr eqn*have-num 0
. if !'\\*[eqn*num]'' .nr eqn*have-num 1
. ie \\n[dl]:\\n[eqn*have-num] \{\
-. sp \\n[DD]u
+. if !'\*(.T'html' .sp \\n[DD]u
. par@reset
. ds eqn*tabs \\n[.tabs]
. nf
. ie \\n[dl] \{\
-. ds@need \\n[dn]u-1v+\n[.V]u
+.\" --fixme-- this really should not be necessary
+.\" and indicates that there is extra space creeping into
+.\" an equation when ps4html is enabled..
+. ie r ps4html .ds@need \\n[dn]u-1v+\n[.V]u+1i
+. el .ds@need \\n[dn]u-1v+\n[.V]u
. chop eqn*div
. ie \\n[eqn*type]=0 \{\
. ta (u;\\n[.l]-\\n[.i])R
@@ -1606,7 +1610,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
. ta (u;\\n[.l]-\\n[.i])R
\t\\*[eqn*num]
. \}
-. sp \\n[DD]u
+. if !'\*(.T'html' .sp \\n[DD]u
. ta \\*[eqn*tabs]
. \}
. el \{
@@ -1616,7 +1620,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
. if '\*(.T'html' \\*[eqn*div]
. if r ps4html \\*[eqn*div]
. \}
-. fi
+. if !'\*(.T'html' .fi
. if \\n[eqn*type]=0 .HTML-IMAGE-END
. if \\n[eqn*type]=1 \{\
. HTML-IMAGE-END
@@ -1638,8 +1642,9 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
..
.de @TS
.sp \\n[DD]u
-.HTML-IMAGE
+.\" .if !'\*(.T'html' .sp \\n[DD]u
.if '\\$1'H' .di tbl*header-div
+.HTML-IMAGE
..
.de tbl@top-hook
.if \\n[tbl*have-header] \{\
@@ -1681,7 +1686,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
.ie '\\n(.z'tbl*header-div' .@error-recover .TS H but no .TH before .TE
.el \{\
. nr tbl*have-header 0
-. sp \\n[DD]u
+. if !'\*(.T'html' .sp \\n[DD]u
.\}
. HTML-IMAGE-END
.\" reset tabs
diff --git a/tmac/www.tmac b/tmac/www.tmac
index 47237a95..22f829e1 100644
--- a/tmac/www.tmac
+++ b/tmac/www.tmac
@@ -494,9 +494,9 @@
. el \{\
. ie r ps4html \{\
. www-make-unique-name
-. nop \O[3]\O[5i\\*[www-unique-name].png]\O[1]
-. nop \\m[\\*[www-dropcolor]]\\s[40]\\$1\\s0
-. nop \O[2]\O[1]\O[4]
+. nop \O[5i\\*[www-unique-name].png]\O[1]
+. nop \\m[\\*[www-dropcolor]]\\s[40]\O[3]\\$1\O[4]\\s0
+. nop \O[2]\O[1]
. \}
. el \{\
. nr dummy \\w'\\$1'u
@@ -526,18 +526,18 @@
.\"
.de HTML-DO-IMAGE
. if r ps4html \
-. nop \O[3]\O[5\\$2\\$1.png]\O[1]
+. nop \O[5\\$2\\$1.png]\O[1]\O[3]
. if \\n[www-html] \
-. nop \O[3]\O[5\\$2\\$1.png]\O[0]
+. nop \O[5\\$2\\$1.png]\O[0]\O[3]
..
.\"
.\" HTML-IMAGE-END - terminates an image for html
.\"
.de HTML-IMAGE-END
. if r ps4html \
-. nop \O[2]\O[1]\O[4]
+. nop \O[4]\O[2]\O[0]
. if \\n[www-html] \
-. nop \O[2]\O[1]\O[4]
+. nop \O[4]\O[2]\O[1]
..
.
.nr www-png-no 0
@@ -575,11 +575,11 @@
. HTML-DO-IMAGE \\*[www-unique-name] i
..
.
-.
.if \n[www-html] \{\
. nh
. nr HY 0
.\}
+.if r ps4html .nop \O[0]
.cp \n(_C
.
.\" now set