[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Groff] grohtml patches
From: |
Gaius Mulley |
Subject: |
[Groff] grohtml patches |
Date: |
Mon, 20 May 2002 07:53:08 +0100 |
Hi Werner,
here are some patches for grohtml containing some of the items on the
wish list.
+ the \O[0] and \O[1] now operate in a device independant manner.
\O[0] suppresses output and \O[1] enables output.
\O[3] begins a new level. \O[4] ends a level.
So:
`hello \O[0]world\O[1] again'
yields:
`hello again'
+ modified groff.texi to reflect new \O behaviour.
+ new -p option to grohtml displays progress.
Updated the grohtml.man to reflect this.
+ pre-grohtml has been fixes so that it only renders a page
at a time. _Much_ less disk resource is used :-)
Grohtml should be faster as it no longer uses a page per
image.
+ html.tmac no longer issues the \M[black]\c as requested which
in turn generates better html :-) as the device driver
uses \M[default] until the users say otherwise. Thus
it no longer sets the color in every paragraph.
+ modified pre-html.cc to make the debugging option more effective.
Fixed a file descriptor open leak in html_system.
+ Fixed non null terminated strings inside section heading links.
Exhibited when processing Lester's paper.
hope they meet with approval?
Gaius
--- groff-cvs/src/preproc/html/pre-html.cc Thu Apr 11 20:38:11 2002
+++ groff-html/src/preproc/html/pre-html.cc Sun May 19 12:43:13 2002
@@ -96,8 +96,9 @@
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 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 @@
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 @@
* 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 @@
* 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_start_image (IMAGE_ALIGNMENT pos, int is_html)
{
- writeString("\\O[3]\\O[5");
+ writeString("\\O[5");
switch (pos) {
case INLINE:
@@ -509,10 +518,10 @@
}
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 @@
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,32 +757,54 @@
}
/*
- * 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 | "
- "gs%s %s -q -dSAFER -sDEVICE=%s -r%d %s"
- "-sOutputFile=%s/%%d %s -",
+ "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)
@@ -784,30 +815,11 @@
#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.
*/
@@ -845,25 +857,29 @@
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) {
@@ -957,6 +973,10 @@
fputc(f->getPB(), stderr);
}
}
+ if (show_progress) {
+ fprintf(stderr, "done\n");
+ fflush(stderr);
+ }
}
/*
@@ -1113,15 +1133,6 @@
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");
@@ -1161,7 +1172,6 @@
write_file_html();
waitForChild(pid);
}
-#endif
return 0;
}
@@ -1187,11 +1197,6 @@
argv = addRegDef(argc, argv, s.contents());
argc++;
-#if defined(DEBUGGING)
- if (debug)
- dump_args(argc, argv);
-#endif
-
if (pipe(pdes) < 0)
sys_fatal("pipe");
@@ -1268,7 +1273,7 @@
{ "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':
@@ -1307,6 +1312,9 @@
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;
@@ -1349,13 +1357,34 @@
#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);
@@ -1364,6 +1393,8 @@
return -1;
}
fclose(f);
+
+ /* regionFileName contains a list of the images and their boxed coordinates
*/
f = xtmpfile(®ionFileName,
REGION_TEMPLATE_LONG, REGION_TEMPLATE_SHORT,
FALSE);
@@ -1377,20 +1408,6 @@
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];
@@ -1425,14 +1442,9 @@
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;
}
--- groff-cvs/src/devices/grohtml/post-html.cc Thu Apr 11 20:38:09 2002
+++ groff-html/src/devices/grohtml/post-html.cc Fri May 17 21:19:06 2002
@@ -1134,6 +1134,7 @@
string buffer(ANCHOR_TEMPLATE);
buffer += as_string(h);
+ buffer += '\0';
fprintf(f, buffer.contents());
} else
fputs(g->text_string, f);
@@ -1594,6 +1595,7 @@
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_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 @@
{ "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':
@@ -2867,6 +2872,9 @@
manufacture_headings = TRUE;
break;
case 'o':
+ /* handled by pre-html */
+ break;
+ case 'p':
/* handled by pre-html */
break;
case 'i':
--- groff-cvs/src/devices/grohtml/grohtml.man Mon Jan 28 05:05:30 2002
+++ groff-html/src/devices/grohtml/grohtml.man Sun May 19 11:38:41 2002
@@ -142,6 +142,11 @@
(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
.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
--- groff-cvs/src/devices/grohtml/html-text.cc Sun Feb 17 17:05:53 2002
+++ groff-html/src/devices/grohtml/html-text.cc Wed May 15 19:03:07 2002
@@ -101,6 +101,8 @@
}
default: fprintf(stderr, "unknown tag");
}
+ if (p->text_emitted)
+ fprintf(stderr, "[t] ");
}
/*
@@ -222,11 +224,23 @@
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 @@
return FALSE;
}
+extern void stop();
/*
* do_push - places, tag_definition, p, onto the stack
@@ -302,8 +317,10 @@
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 @@
#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 @@
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 @@
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;
}
/*
--- groff-cvs/tmac/www.tmac Mon Apr 15 11:21:16 2002
+++ groff-html/tmac/www.tmac Fri May 17 18:02:36 2002
@@ -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
--- groff-cvs/tmac/s.tmac Sun Feb 17 17:05:56 2002
+++ groff-html/tmac/s.tmac Sun May 19 12:23:15 2002
@@ -1569,7 +1569,7 @@
. HTML-IMAGE-INLINE
.\}
.if \\n[eqn*type]=2 .HTML-IMAGE
-.nf
+.if !'\*(.T'html' .nf
..
.de @div-end!eqn*div
address@hidden
@@ -1583,12 +1583,16 @@
. 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
. address@hidden
. ds eqn*tabs \\n[.tabs]
. nf
. ie \\n[dl] \{\
-. address@hidden \\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 address@hidden \\n[dn]u-1v+\n[.V]u+1i
+. el address@hidden \\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 @@
. 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 @@
. 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 @@
..
.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 address@hidden
.if \\n[tbl*have-header] \{\
@@ -1681,7 +1686,7 @@
.ie '\\n(.z'tbl*header-div' address@hidden .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
--- groff-cvs/tmac/html.tmac Sun Mar 24 11:38:34 2002
+++ groff-html/tmac/html.tmac Fri May 10 10:31:22 2002
@@ -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 \
--- groff-cvs/src/roff/troff/node.cc Fri Mar 15 21:56:24 2002
+++ groff-html/src/roff/troff/node.cc Sun May 19 13:01:44 2002
@@ -36,6 +36,7 @@
#include "font.h"
#include "reg.h"
#include "input.h"
+#include "div.h"
#include "geometry.h"
#include "nonposix.h"
@@ -670,7 +671,7 @@
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] requests
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 @@
{
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 @@
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::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::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,19 @@
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 +1057,9 @@
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 +1257,10 @@
int npoints)
{
int i, x, y;
+
+ if (! is_on())
+ return;
+
switch (code) {
case 'c':
case 'C':
@@ -1318,32 +1341,34 @@
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 +1378,15 @@
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 +1586,7 @@
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 +1628,8 @@
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 +1640,7 @@
int real_output_file::is_on()
{
- return( output_on );
+ return output_on;
}
void real_output_file::really_on()
@@ -3659,7 +3686,8 @@
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 +3695,7 @@
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 +3734,15 @@
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 +3752,13 @@
}
}
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 +3808,8 @@
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 +3846,8 @@
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 +4258,23 @@
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 +4303,13 @@
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 +4330,8 @@
n->zero_width_tprint(out);
out->down(h);
}
- n->tprint(out);
+ if (out->is_on())
+ n->tprint(out);
}
}
}
--- groff-cvs/src/roff/troff/input.cc Sat Apr 20 15:51:10 2002
+++ groff-html/src/roff/troff/input.cc Fri May 10 13:01:05 2002
@@ -4658,19 +4658,23 @@
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) {
@@ -4695,6 +4699,8 @@
}
}
}
+ // say goodbye to all this code?
+#endif
break;
case '4':
begin_level--;
@@ -4720,7 +4726,7 @@
return 0;
}
image_no++;
- if (begin_level == 1)
+ if (begin_level == 0)
return new suppress_node(symbol(s), position, image_no);
}
break;
--- groff-cvs/doc/groff.texinfo Fri May 17 18:42:34 2002
+++ groff-html/doc/groff.texinfo Fri May 3 14:04:40 2002
@@ -11436,8 +11436,7 @@
@item \O0
Disable any ditroff glyphs from being emitted to the device driver,
provided that the escape occurs at the outer level (see @code{\O3} and
address@hidden). Motion is not suppressed so effectively @code{\O[0]}
-means @emph{pen up}.
address@hidden).
@item \O1
Enable output of glyphs, provided that the escape occurs at the outer
@@ -11452,17 +11451,6 @@
@samp{opminy}, @samp{opmaxx}, and @samp{opmaxy} to @minus{}1.
@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:
-
address@hidden
-Hello \O[0]world\O[1] this is a test
address@hidden
-
-produces the following output:
-
address@hidden
-Hello this is a test
address@hidden
@table @samp
@item \O2
@@ -11472,15 +11460,10 @@
to @code{\O}.
@item \O3
-Begin a nesting level. This is really an internal mechanism for
address@hidden 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).
+Increase a nesting level.
@item \O4
-End a nesting level.
+Decrease a nesting level.
@item \O[5Pfilename]
This escape is @code{grohtml} specific. Provided that this escape
- [Groff] grohtml patches,
Gaius Mulley <=