summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog58
-rw-r--r--Makefile.in3
-rwxr-xr-xsrc/include/htmlindicate.h20
-rw-r--r--src/include/posix.h4
-rwxr-xr-xsrc/libs/libgroff/htmlindicate.cc40
-rw-r--r--src/preproc/tbl/main.cc6
-rw-r--r--src/roff/groff/groff.cc42
-rw-r--r--src/roff/troff/div.cc4
-rw-r--r--src/roff/troff/env.cc16
-rw-r--r--src/roff/troff/env.h1
-rw-r--r--src/roff/troff/input.cc101
-rw-r--r--src/roff/troff/node.cc92
-rw-r--r--src/roff/troff/node.h4
-rw-r--r--src/roff/troff/reg.h2
-rw-r--r--src/roff/troff/request.h1
-rw-r--r--src/roff/troff/troff.h1
-rw-r--r--test-groff2
-rw-r--r--tmac/Makefile.sub5
-rw-r--r--tmac/eqnrc13
-rwxr-xr-xtmac/tmac.html-tags50
-rwxr-xr-xtmac/tmac.html262
-rw-r--r--tmac/troffrc-end1
22 files changed, 474 insertions, 54 deletions
diff --git a/ChangeLog b/ChangeLog
index 44f5e40f..7b09eec3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,61 @@
+2000-08-25 Werner LEMBERG <wl@gnu.org>
+
+ * src/include/posix.h: Remove definition of FILENAME_MAX.
+
+ * src/preproc/html2/pre-html.h, pre-html.cc: Add return type to
+ `sys_fatal' and `stop' function().
+
+ * test-groff: Updated.
+
+2000-08-24 Gaius Mulley <gaius@glam.ac.uk>
+
+ Added the new troff command .output <arg> to suppress output (while
+ still obeying motion) and also the opminx, opminy, opmaxx, opmaxy
+ registers (for passing the output dimensions to the output device).
+
+ * src/roff/troff/div.cc (top_level_diversion::output): Use `width'
+ parameter.
+ * src/roff/troff/node.h, src/roff/troff/node.cc
+ (troff_output_file::really_print_line,
+ ascii_output_file::really_print_line,
+ supress_output_file::really_print_line): Use `width' parameter.
+ (troff_output_file::really_on, troff_output_file::really_off,
+ output_file::on, output_file::off, real_output_file::on,
+ real_output_file::off, real_output_file::really_on,
+ real_output_file::really_off): New functions.
+ (real_output_file:public output_file): New variable `output_on'.
+ (real_output_file::begin_page, real_output_file::copy_file,
+ real_output_file::transparent_char, real_output_file::print_line):
+ Use it.
+ (real_output_file::print_line): Use check_output_limits.
+ * src/roff/troff/reg.h, src/roff/troff/request.h,
+ src/roff/troff/input.cc (assign_registers): New function to remove
+ two `goto's.
+ (do_ps_file): Use it.
+ (check_output_limits, reset_output_registers, output_request,
+ init_output_requests): New functions.
+ (init_input_requests): Updated.
+
+ Added new grohtml2 device and html2 preprocessor (coding
+ not yet finished) which will eventually replace grohtml.
+
+ * Makefile.in, tmac/Makefile.sub, tmac/eqnrc, tmac/troffrc-end:
+ Updated.
+ * src/include/htmlindicate.h, src/include/htmlindicate
+ (html_begin_suppress, html_end_suppress): New functions.
+ * src/preproc/tbl/main.cc: Use it.
+ * src/roff/groff/groff.cc: Add support for html2 device (which will
+ automatically invoke the html2 preprocessor).
+ * src/roff/troff/input.cc (is_html2): New variable.
+ * src/roff/troff/troff.h, src/roff/troff/env.h,
+ src/roff/troff/env.cc (environment::add_html_tag): New function
+ (uses `is_html2').
+ (environment::do_break): Use it.
+ * font/devhtml2/*: New files.
+ * src/devices/grohtml2: New device.
+ * src/preproc/html2: New preprocessor.
+ * tmac/tmac.html-tags, tmac/tmac.html2: New files.
+
2000-08-23 Werner LEMBERG <wl@gnu.org>
* src/devices/grolbp/lbp.cc: Same workaround for sinix as for AIX.
diff --git a/Makefile.in b/Makefile.in
index 9856aabe..29a3d455 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -318,11 +318,13 @@ CCPROGDIRS=\
src/preproc/grn \
src/preproc/refer \
src/preproc/soelim \
+ src/preproc/html2 \
src/devices/grops \
src/devices/grotty \
src/devices/grodvi \
src/devices/grolj4 \
src/devices/grohtml \
+ src/devices/grohtml2 \
src/devices/grolbp \
src/utils/tfmtodit \
src/utils/hpftodit \
@@ -341,6 +343,7 @@ DEVDIRS=\
font/devX100-12 \
font/devlj4 \
font/devhtml \
+ font/devhtml2 \
font/devlbp
ALLTTYDEVDIRS=\
font/devascii \
diff --git a/src/include/htmlindicate.h b/src/include/htmlindicate.h
index 96a63884..a375fb22 100755
--- a/src/include/htmlindicate.h
+++ b/src/include/htmlindicate.h
@@ -37,5 +37,25 @@ extern void graphic_start (void);
extern void graphic_end (void);
+
+/*
+ * html_begin_suppress - if the 'htmlflip' variable is set to 1 then
+ * all text following this line will be suppressed by troff
+ * and if the -Thtml2 device is specified a generic IMAGE tag
+ * is emitted which is later filled in by the pre-html preprocessor.
+ */
+
+extern void html_begin_suppress (void);
+
+/*
+ * html_end_suppress - if the 'htmlflip' variable has been set then
+ * enable generation of text after this line of troff.
+ * If 'htmlflip' and -Thtml2 is set then issue the
+ * upper x,y and lower x,y coordinates to stderr via
+ * a troff '.tm' command.
+ */
+
+extern void html_end_suppress (void);
+
#endif
diff --git a/src/include/posix.h b/src/include/posix.h
index c71f915a..1b7d5cdc 100644
--- a/src/include/posix.h
+++ b/src/include/posix.h
@@ -49,7 +49,3 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef O_RDONLY
#define O_RDONLY 0
#endif
-
-#ifndef FILENAME_MAX
-#define FILENAME_MAX 1024 /* default */
-#endif
diff --git a/src/libs/libgroff/htmlindicate.cc b/src/libs/libgroff/htmlindicate.cc
index 91e53a26..1ebfb769 100755
--- a/src/libs/libgroff/htmlindicate.cc
+++ b/src/libs/libgroff/htmlindicate.cc
@@ -21,7 +21,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <stdlib.h>
#include <string.h>
-#include "posix.h"
+#include "nonposix.h"
#include "stringclass.h"
/*
@@ -40,6 +40,42 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
static int is_in_graphic_start = 0;
/*
+ * html_begin_suppress - if the 'htmlflip' variable is set to 1 then
+ * all text following this line will be suppressed by troff
+ * and if the -Thtml2 device is specified a generic IMAGE tag
+ * is emitted which is later filled in by the pre-html preprocessor.
+ */
+
+void html_begin_suppress (void)
+{
+ /*
+ * the pre-html processor looks for <pre-html-image> and replaces it
+ * with a sensible name
+ */
+ put_string(".if r html2enable .if '\\*(.T'html2' .IMAGE <pre-html-image>\n", stdout);
+#if 1
+ // debugging information
+ put_string(".if r html2enable .if !r htmlflip .tm \"htmlflip was not set?\"\n", stdout);
+#endif
+ put_string(".if r html2enable .if r htmlflip .output 1-\\n[htmlflip]\n", stdout);
+}
+
+/*
+ * html_end_suppress - if the 'htmlflip' variable is 1 then
+ * enable generation of text after this line of troff.
+ * If 'htmlflip' and -Thtml2 is set then issue the
+ * upper x,y and lower x,y coordinates to stderr via
+ * a troff '.tm' command.
+ */
+
+void html_end_suppress (void)
+{
+ put_string(".if r html2enable .if r htmlflip .if !'\\*(.T'html2' .tm grohtml-info:page \\n% \\n[opminx] \\n[opminy] \\n[opmaxx] \\n[opmaxy] \\n[.H] \\n[.V] \\n[.F]\n",
+ stdout);
+ put_string(".if r html2enable .if r htmlflip .output \\n[htmlflip]\n", stdout);
+}
+
+/*
* graphic_start - emit a html graphic start indicator, but only
* if one has not already been issued.
*/
@@ -48,6 +84,7 @@ void graphic_start (void)
{
if (! is_in_graphic_start) {
put_string(".if '\\*(.T'html' \\X(graphic-start(\\c\n", stdout);
+ html_begin_suppress();
is_in_graphic_start = 1;
}
}
@@ -62,6 +99,7 @@ void graphic_end (void)
{
if (is_in_graphic_start) {
put_string(".if '\\*(.T'html' \\X(graphic-end(\\c\n", stdout);
+ html_end_suppress();
is_in_graphic_start = 0;
}
}
diff --git a/src/preproc/tbl/main.cc b/src/preproc/tbl/main.cc
index 5ff69e89..d70345e2 100644
--- a/src/preproc/tbl/main.cc
+++ b/src/preproc/tbl/main.cc
@@ -19,6 +19,7 @@ with groff; see the file COPYING. If not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "table.h"
+#include "htmlindicate.h"
#define MAX_POINT_SIZE 99
#define MAX_VERTICAL_SPACING 72
@@ -230,14 +231,15 @@ void process_input_file(FILE *fp)
}
putchar('\n');
printf(".if '\\*(.T'html' \\X(table-start(\n");
+ html_begin_suppress();
current_lineno++;
{
table_input input(fp);
process_table(input);
- if (input.ended())
- printf(".if '\\*(.T'html' \\X(table-end(\n");
set_troff_location(current_filename, current_lineno);
if (input.ended()) {
+ printf(".if '\\*(.T'html' \\X(table-end(\n");
+ html_end_suppress();
fputs(".TE", stdout);
while ((c = getc(fp)) != '\n') {
if (c == EOF) {
diff --git a/src/roff/groff/groff.cc b/src/roff/groff/groff.cc
index 034052a8..c80be644 100644
--- a/src/roff/groff/groff.cc
+++ b/src/roff/groff/groff.cc
@@ -84,7 +84,8 @@ public:
int lflag = 0;
char *spooler = 0;
-char *driver = 0;
+char *postdriver = 0;
+char *predriver = 0;
possible_command commands[NCOMMANDS];
@@ -191,6 +192,10 @@ int main(int argc, char **argv)
safer_flag = 0;
break;
case 'T':
+ if (strcmp(optarg, "html2") == 0) {
+ // force soelim to aid the html preprocessor
+ commands[SOELIM_INDEX].set_name(command_prefix, "soelim");
+ }
if (strcmp(optarg, "Xps") == 0) {
warning("-TXps option is obsolete: use -X -Tps instead");
device = "ps";
@@ -251,17 +256,23 @@ int main(int argc, char **argv)
font::set_unknown_desc_command_handler(handle_unknown_desc_command);
if (!font::load_desc())
fatal("invalid device `%1'", device);
- if (!driver)
+ if (!postdriver)
fatal("no `postpro' command in DESC file for device `%1'", device);
+
+ if (predriver) {
+ commands[TROFF_INDEX].insert_arg(commands[TROFF_INDEX].get_name());
+ commands[TROFF_INDEX].set_name(predriver);
+ }
+
const char *real_driver = 0;
if (Xflag) {
- real_driver = driver;
- driver = GXDITVIEW;
+ real_driver = postdriver;
+ postdriver = GXDITVIEW;
commands[TROFF_INDEX].append_arg("-r" XREG "=", "1");
}
- if (driver)
- commands[POST_INDEX].set_name(driver);
- int gxditview_flag = driver && strcmp(xbasename(driver), GXDITVIEW) == 0;
+ if (postdriver)
+ commands[POST_INDEX].set_name(postdriver);
+ int gxditview_flag = postdriver && strcmp(xbasename(postdriver), GXDITVIEW) == 0;
if (gxditview_flag && argc - optind == 1) {
commands[POST_INDEX].append_arg("-title");
commands[POST_INDEX].append_arg(argv[optind]);
@@ -372,6 +383,21 @@ void handle_unknown_desc_command(const char *command, const char *arg,
else
spooler = strsave(arg);
}
+ if (strcmp(command, "prepro") == 0) {
+ if (arg == 0)
+ error_with_file_and_line(filename, lineno,
+ "`prepro' command requires an argument");
+ else {
+ for (const char *p = arg; *p; p++)
+ if (csspace(*p)) {
+ error_with_file_and_line(filename, lineno,
+ "invalid `prepro' argument `%1'"
+ ": program name required", arg);
+ return;
+ }
+ predriver = strsave(arg);
+ }
+ }
if (strcmp(command, "postpro") == 0) {
if (arg == 0)
error_with_file_and_line(filename, lineno,
@@ -384,7 +410,7 @@ void handle_unknown_desc_command(const char *command, const char *arg,
": program name required", arg);
return;
}
- driver = strsave(arg);
+ postdriver = strsave(arg);
}
}
}
diff --git a/src/roff/troff/div.cc b/src/roff/troff/div.cc
index 013ea669..8566cd0f 100644
--- a/src/roff/troff/div.cc
+++ b/src/roff/troff/div.cc
@@ -328,7 +328,7 @@ vunits top_level_diversion::distance_to_next_trap()
}
void top_level_diversion::output(node *nd, int retain_size,
- vunits vs, vunits post_vs, hunits /*width*/)
+ vunits vs, vunits post_vs, hunits width)
{
no_space_mode = 0;
vunits next_trap_pos;
@@ -346,7 +346,7 @@ void top_level_diversion::output(node *nd, int retain_size,
vertical_position += v.pre;
vertical_position += v.pre_extra;
the_output->print_line(page_offset, vertical_position, nd,
- v.pre + v.pre_extra, v.post_extra);
+ v.pre + v.pre_extra, v.post_extra, width);
vertical_position += v.post_extra;
if (vertical_position > high_water_mark)
high_water_mark = vertical_position;
diff --git a/src/roff/troff/env.cc b/src/roff/troff/env.cc
index fbea78ed..b5e1ed74 100644
--- a/src/roff/troff/env.cc
+++ b/src/roff/troff/env.cc
@@ -1936,9 +1936,24 @@ void environment::final_break()
do_break();
}
+void environment::add_html_tag (const char *name)
+{
+ if (is_html2) {
+ // need to emit tag for post-grohtml
+ macro *m = new macro;
+
+ for (const char *p = name; *p; p++)
+ if (!illegal_input_char((unsigned char)*p))
+ m->append(*p);
+ output_pending_lines();
+ output_line(new special_node(*m), 0);
+ }
+}
+
void environment::do_break()
{
if (curdiv == topdiv && topdiv->before_first_page) {
+ add_html_tag("html-tag:eol");
topdiv->begin_page();
return;
}
@@ -1969,6 +1984,7 @@ void environment::do_break()
break;
}
}
+ add_html_tag("html-tag:eol");
node *tem = line;
line = 0;
output_line(tem, width_total);
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index 1db463da..d2a1fb34 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -270,6 +270,7 @@ public:
void spread() { spread_flag = 1; }
void do_break(); // .br
void final_break();
+ void add_html_tag (const char *name);
void newline();
void handle_tab(int is_leader = 0); // do a tab or leader
void add_node(node *);
diff --git a/src/roff/troff/input.cc b/src/roff/troff/input.cc
index 529a70f1..b4e9c70c 100644
--- a/src/roff/troff/input.cc
+++ b/src/roff/troff/input.cc
@@ -101,6 +101,7 @@ static symbol blank_line_macro_name;
static int compatible_flag = 0;
int ascii_output_flag = 0;
int suppress_output_flag = 0;
+int is_html2 = 0;
int tcommand_flag = 0;
@@ -4540,6 +4541,14 @@ int ps_get_line(char *buf, FILE *fp, const char* filename)
return 1;
}
+inline void assign_registers(int llx, int lly, int urx, int ury)
+{
+ llx_reg_contents = llx;
+ lly_reg_contents = lly;
+ urx_reg_contents = urx;
+ ury_reg_contents = ury;
+}
+
void do_ps_file(FILE *fp, const char* filename)
{
bounding_box bb;
@@ -4562,9 +4571,10 @@ void do_ps_file(FILE *fp, const char* filename)
break;
if (strncmp(buf + 2, "BoundingBox:", 12) == 0) {
int res = parse_bounding_box(buf + 14, &bb);
- if (res == 1)
- goto assign_registers;
- else if (res == 2) {
+ if (res == 1) {
+ assign_registers(bb.llx, bb.lly, bb.urx, bb.ury);
+ return;
+ } else if (res == 2) {
bb_at_end = 1;
break;
}
@@ -4611,18 +4621,13 @@ void do_ps_file(FILE *fp, const char* filename)
}
}
}
- if (got_bb)
- goto assign_registers;
+ if (got_bb) {
+ assign_registers(bb.llx, bb.lly, bb.urx, bb.ury);
+ return;
+ }
}
}
error("%%%%BoundingBox comment not found in `%1'", filename);
- return;
-
-assign_registers:
- llx_reg_contents = bb.llx;
- lly_reg_contents = bb.lly;
- urx_reg_contents = bb.urx;
- ury_reg_contents = bb.ury;
}
void ps_bbox_request()
@@ -5689,6 +5694,7 @@ int main(int argc, char **argv)
case 'T':
device = optarg;
tflag = 1;
+ is_html2 = (strcmp(device, "html2") == 0);
break;
case 'C':
compatible_flag = 1;
@@ -5797,6 +5803,7 @@ int main(int argc, char **argv)
init_column_requests();
#endif /* COLUMN */
init_node_requests();
+ init_output_requests();
number_reg_dictionary.define(".T", new constant_reg(tflag ? "1" : "0"));
init_registers();
init_reg_requests();
@@ -5871,6 +5878,72 @@ static void init_registers()
: "0"));
}
+/*
+ * .output request and associated registers
+ */
+
+static int output_reg_minx_contents = -1;
+static int output_reg_miny_contents = -1;
+static int output_reg_maxx_contents = -1;
+static int output_reg_maxy_contents = -1;
+
+void check_output_limits (int x, int y)
+{
+ if ((output_reg_minx_contents == -1) || (x < output_reg_minx_contents)) {
+ output_reg_minx_contents = x;
+ }
+ if (x > output_reg_maxx_contents) {
+ output_reg_maxx_contents = x;
+ }
+ if ((output_reg_miny_contents == -1) || (y < output_reg_miny_contents)) {
+ output_reg_miny_contents = y;
+ }
+ if (y > output_reg_maxy_contents) {
+ output_reg_maxy_contents = y;
+ }
+ // fprintf(stderr, "x = %d y=%d miny=%d maxy=%d\n", x, y, output_reg_miny_contents, output_reg_maxy_contents);
+}
+
+void reset_output_registers()
+{
+ // fprintf(stderr, "reset_output_registers\n");
+ output_reg_minx_contents = -1;
+ output_reg_miny_contents = -1;
+ output_reg_maxx_contents = -1;
+ output_reg_maxy_contents = -1;
+}
+
+void output_request()
+{
+ if (has_arg()) {
+ int n;
+
+ if (! get_integer(&n)) {
+ error("missing integer argument for output request");
+ n = 1;
+ }
+
+ if (break_flag)
+ curenv->do_break();
+
+ if (!the_output)
+ init_output();
+ if (n == 0) {
+ the_output->off();
+ } else {
+ the_output->on();
+ }
+ } else {
+ error("missing argument for output request");
+ }
+ skip_line();
+}
+
+void init_output_requests()
+{
+ init_request("output", output_request);
+}
+
void init_input_requests()
{
init_request("ds", define_string);
@@ -5960,6 +6033,10 @@ void init_input_requests()
number_reg_dictionary.define("lly", new variable_reg(&lly_reg_contents));
number_reg_dictionary.define("urx", new variable_reg(&urx_reg_contents));
number_reg_dictionary.define("ury", new variable_reg(&ury_reg_contents));
+ number_reg_dictionary.define("opminx", new variable_reg(&output_reg_minx_contents));
+ number_reg_dictionary.define("opminy", new variable_reg(&output_reg_miny_contents));
+ number_reg_dictionary.define("opmaxx", new variable_reg(&output_reg_maxx_contents));
+ number_reg_dictionary.define("opmaxy", new variable_reg(&output_reg_maxy_contents));
}
object_dictionary request_dictionary(501);
diff --git a/src/roff/troff/node.cc b/src/roff/troff/node.cc
index d53bf333..3c0d936e 100644
--- a/src/roff/troff/node.cc
+++ b/src/roff/troff/node.cc
@@ -647,13 +647,16 @@ class real_output_file : public output_file {
#ifndef POPEN_MISSING
int piped;
#endif
- int printing;
+ int printing; // decision via optional page list
+ int output_on; // .output 1 or .output 0 requests
virtual void really_transparent_char(unsigned char) = 0;
virtual void really_print_line(hunits x, vunits y, node *n,
- vunits before, vunits after) = 0;
+ vunits before, vunits after, hunits width) = 0;
virtual void really_begin_page(int pageno, vunits page_length) = 0;
virtual void really_copy_file(hunits x, vunits y, const char *filename);
virtual void really_put_filename(const char *filename);
+ virtual void really_on();
+ virtual void really_off();
protected:
FILE *fp;
public:
@@ -661,9 +664,11 @@ public:
~real_output_file();
void flush();
void transparent_char(unsigned char);
- void print_line(hunits x, vunits y, node *n, vunits before, vunits after);
+ void print_line(hunits x, vunits y, node *n, vunits before, vunits after, hunits width);
void begin_page(int pageno, vunits page_length);
void put_filename(const char *filename);
+ void on();
+ void off();
int is_printing();
void copy_file(hunits x, vunits y, const char *filename);
};
@@ -672,7 +677,7 @@ class suppress_output_file : public real_output_file {
public:
suppress_output_file();
void really_transparent_char(unsigned char);
- void really_print_line(hunits x, vunits y, node *n, vunits, vunits);
+ void really_print_line(hunits x, vunits y, node *n, vunits, vunits, hunits width);
void really_begin_page(int pageno, vunits page_length);
};
@@ -680,7 +685,7 @@ class ascii_output_file : public real_output_file {
public:
ascii_output_file();
void really_transparent_char(unsigned char);
- void really_print_line(hunits x, vunits y, node *n, vunits, vunits);
+ void really_print_line(hunits x, vunits y, node *n, vunits, vunits, hunits width);
void really_begin_page(int pageno, vunits page_length);
void outc(unsigned char c);
void outs(const char *s);
@@ -740,10 +745,12 @@ public:
void end_special();
void word_marker();
void really_transparent_char(unsigned char c);
- void really_print_line(hunits x, vunits y, node *n, vunits before, vunits after);
+ void really_print_line(hunits x, vunits y, node *n, vunits before, vunits after, hunits width);
void really_begin_page(int pageno, vunits page_length);
void really_copy_file(hunits x, vunits y, const char *filename);
void really_put_filename(const char *filename);
+ void really_on();
+ void really_off();
void draw(char, hvpair *, int, font_size);
int get_hpos() { return hpos; }
int get_vpos() { return vpos; }
@@ -801,7 +808,7 @@ inline void troff_output_file::moveto(hunits h, vunits v)
}
void troff_output_file::really_print_line(hunits x, vunits y, node *n,
- vunits before, vunits after)
+ vunits before, vunits after, hunits width)
{
moveto(x, y);
while (n != 0) {
@@ -1092,6 +1099,16 @@ void troff_output_file::draw(char code, hvpair *point, int npoints,
put('\n');
}
+void troff_output_file::really_on ()
+{
+ flush_tbuf();
+}
+
+void troff_output_file::really_off ()
+{
+ flush_tbuf();
+}
+
void troff_output_file::really_put_filename(const char *filename)
{
flush_tbuf();
@@ -1213,8 +1230,16 @@ void output_file::put_filename(const char *filename)
{
}
+void output_file::on()
+{
+}
+
+void output_file::off()
+{
+}
+
real_output_file::real_output_file()
-: printing(0)
+: printing(0), output_on(1)
{
#ifndef POPEN_MISSING
if (pipe_command) {
@@ -1277,27 +1302,36 @@ 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)
+ if (printing && output_on)
really_begin_page(pageno, page_length);
}
void real_output_file::copy_file(hunits x, vunits y, const char *filename)
{
- if (printing)
+ if (printing && output_on)
really_copy_file(x, y, filename);
+ check_output_limits(x.to_units(), y.to_units());
}
void real_output_file::transparent_char(unsigned char c)
{
- if (printing)
+ if (printing && output_on)
really_transparent_char(c);
}
void real_output_file::print_line(hunits x, vunits y, node *n,
- vunits before, vunits after)
+ vunits before, vunits after, hunits width)
{
- if (printing)
- really_print_line(x, y, n, before, after);
+ if (printing && output_on)
+ really_print_line(x, y, n, before, after, width);
+
+ if (before.to_units() < after.to_units()) {
+ check_output_limits(x.to_units() , y.to_units()+before.to_units());
+ check_output_limits(x.to_units()+width.to_units(), y.to_units()+after.to_units()+n->size());
+ } else {
+ check_output_limits(x.to_units() , y.to_units()+after.to_units());
+ check_output_limits(x.to_units()+width.to_units(), y.to_units()+before.to_units()+n->size());
+ }
delete_node_list(n);
}
@@ -1315,6 +1349,32 @@ void real_output_file::really_put_filename(const char *filename)
{
}
+void real_output_file::on()
+{
+ really_on();
+ if (output_on == 0) {
+ output_on = 1;
+ }
+ /*
+ * lastly we reset the output registers
+ */
+ reset_output_registers();
+}
+
+void real_output_file::off()
+{
+ really_off();
+ output_on = 0;
+}
+
+void real_output_file::really_on()
+{
+}
+
+void real_output_file::really_off()
+{
+}
+
/* ascii_output_file */
void ascii_output_file::really_transparent_char(unsigned char c)
@@ -1322,7 +1382,7 @@ void ascii_output_file::really_transparent_char(unsigned char c)
putc(c, fp);
}
-void ascii_output_file::really_print_line(hunits, vunits, node *n, vunits, vunits)
+void ascii_output_file::really_print_line(hunits, vunits, node *n, vunits, vunits, hunits width)
{
while (n != 0) {
n->ascii_print(this);
@@ -1346,7 +1406,7 @@ suppress_output_file::suppress_output_file()
{
}
-void suppress_output_file::really_print_line(hunits, vunits, node *, vunits, vunits)
+void suppress_output_file::really_print_line(hunits, vunits, node *, vunits, vunits, hunits)
{
}
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index b5095575..21e585dc 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -462,11 +462,13 @@ public:
virtual void flush() = 0;
virtual void transparent_char(unsigned char) = 0;
virtual void print_line(hunits x, vunits y, node *n,
- vunits before, vunits after) = 0;
+ vunits before, vunits after, hunits width) = 0;
virtual void begin_page(int pageno, vunits page_length) = 0;
virtual void copy_file(hunits x, vunits y, const char *filename) = 0;
virtual int is_printing() = 0;
virtual void put_filename (const char *filename);
+ virtual void on();
+ virtual void off();
#ifdef COLUMN
virtual void vjustify(vunits, symbol);
#endif /* COLUMN */
diff --git a/src/roff/troff/reg.h b/src/roff/troff/reg.h
index 51d5b9a1..b983b875 100644
--- a/src/roff/troff/reg.h
+++ b/src/roff/troff/reg.h
@@ -66,6 +66,8 @@ public:
extern object_dictionary number_reg_dictionary;
extern void set_number_reg(symbol nm, units n);
+extern void check_output_limits(int x, int y);
+extern void reset_output_registers (void);
reg *lookup_number_reg(symbol);
#if 0
diff --git a/src/roff/troff/request.h b/src/roff/troff/request.h
index 57031756..7b3ad014 100644
--- a/src/roff/troff/request.h
+++ b/src/roff/troff/request.h
@@ -66,6 +66,7 @@ public:
};
extern void init_input_requests();
+extern void init_output_requests();
extern void init_div_requests();
extern void init_node_requests();
extern void init_reg_requests();
diff --git a/src/roff/troff/troff.h b/src/roff/troff/troff.h
index c5585016..1f1e612b 100644
--- a/src/roff/troff/troff.h
+++ b/src/roff/troff/troff.h
@@ -41,6 +41,7 @@ extern units units_per_inch;
extern int ascii_output_flag;
extern int suppress_output_flag;
+extern int is_html2;
extern int tcommand_flag;
extern int vresolution;
diff --git a/test-groff b/test-groff
index 83492ea6..21567e40 100644
--- a/test-groff
+++ b/test-groff
@@ -19,12 +19,14 @@ $builddir/preproc/tbl:\
$builddir/preproc/grn:\
$builddir/preproc/refer:\
$builddir/preproc/soelim:\
+$builddir/preproc/html2:\
$builddir/devices/grops:\
$builddir/devices/grodvi:\
$builddir/devices/grotty:\
$builddir/devices/grolj4:\
$builddir/devices/grolbp:\
$builddir/devices/grohtml:\
+$builddir/devices/grohtml2:\
$srcdir/$builddir/xditview:\
$PATH
diff --git a/tmac/Makefile.sub b/tmac/Makefile.sub
index dc59a36e..b852710c 100644
--- a/tmac/Makefile.sub
+++ b/tmac/Makefile.sub
@@ -12,8 +12,9 @@ MAN7=\
NORMALFILES=\
tmac.mandoc tmac.andoc tmac.pic tmac.ps tmac.psnew tmac.psold tmac.pspic \
tmac.psatk tmac.dvi tmac.tty tmac.tty-char tmac.X tmac.Xps tmac.latin1 \
- tmac.lj4 eqnrc troffrc troffrc-end tmac.safer tmac.html tmac.markup \
- tmac.arkup tmac.a4 tmac.trace tmac.me tmac.mdoc tmac.an.old
+ tmac.lj4 eqnrc troffrc troffrc-end tmac.safer tmac.html tmac.html2 \
+ tmac.html-tags tmac.markup tmac.arkup tmac.a4 tmac.trace tmac.me \
+ tmac.mdoc tmac.an.old
SPECIALFILES=tmac.an tmac.s tmac.man tmac.ms
STRIPFILES=tmac.e tmac.doc tmac.doc.old
MDOCFILES=doc-common doc-ditroff doc-nroff doc-syms
diff --git a/tmac/eqnrc b/tmac/eqnrc
index cfdbf3f9..4c6a5a15 100644
--- a/tmac/eqnrc
+++ b/tmac/eqnrc
@@ -15,11 +15,12 @@ ifdef X100 ! define X %1% !
ifdef X75-12 ! define X %1% !
ifdef X100-12 ! define X %1% !
-ifdef ps ! define ps|X|html %1% !
-ifdef X ! define ps|X|html %1% !
-ifdef html ! define ps|X|html %1% !
+ifdef ps ! define ps|X|html|html2 %1% !
+ifdef X ! define ps|X|html|html2 %1% !
+ifdef html ! define ps|X|html|html2 %1% !
+ifdef html2 ! define ps|X|html|html2 %1% !
-ifdef ps|X|html ! sdefine inf %"\s[\En[.s]*13u/10u]\v'12M'\(if\v'-12M'\s0"% !
+ifdef ps|X|html|html2 ! sdefine inf %"\s[\En[.s]*13u/10u]\v'12M'\(if\v'-12M'\s0"% !
ifdef dvi !
sdefine int %{type "operator" vcenter \(is}%
@@ -47,7 +48,7 @@ set big_op_spacing5 10
ifdef X ! set axis_height 32 !
-ifdef ps|X|html ! set draw_lines 1 !
+ifdef ps|X|html|html2 ! set draw_lines 1 !
ifdef ascii ! define n %1% !
ifdef latin1 ! define n %1% !
@@ -58,6 +59,6 @@ set nroff 1
!
undef X
-undef ps|X|html
+undef ps|X|html|html2
undef n
.EN
diff --git a/tmac/tmac.html-tags b/tmac/tmac.html-tags
new file mode 100755
index 00000000..b01f8b9f
--- /dev/null
+++ b/tmac/tmac.html-tags
@@ -0,0 +1,50 @@
+.\"
+.\" tmac.html-tags - issues tags for post-html2
+.\"
+.als html-sp-old sp
+.de sp
+\X^html-tag:.sp \\$*^
+. html-sp-old \\$*
+..
+.als html-br-old br
+.de br
+\X^html-tag:.br \\$*^
+. html-br-old \\$*
+..
+.als html-ce-old ce
+.de ce
+\X^html-tag:.ce \\$*^
+. html-ce-old \\$*
+..
+.als html-tl-old tl
+.de tl
+\X^html-tag:.tl \\$*^
+. html-tl-old \\$*
+..
+.als html-in-old in
+.de in
+\X^html-tag:.in \\$*^
+. html-in-old \\$*
+..
+.als html-ti-old ti
+.de ti
+\X^html-tag:.ti \\$*^
+. html-ti-old \\$*
+..
+.als html-ta-old ta
+.de ta
+\X^html-tag:.ta \\$*^
+. html-ta-old \\$*
+..
+.\" these definitions should be removed once grohtml2 has been finished
+.\" and tmac.arkup is working with html2 (actually expect html2 to replace html).
+.de HTML
+. if '\*(.T'html2' \{\
+.\" the following line makes the vertical mode leave, so to say
+\&
+\X^html:\\$*^
+. \}
+..
+.de IMAGE
+. HTML <img src="\\$1">
+..
diff --git a/tmac/tmac.html2 b/tmac/tmac.html2
new file mode 100755
index 00000000..7fa88661
--- /dev/null
+++ b/tmac/tmac.html2
@@ -0,0 +1,62 @@
+.nr _C \n(.C
+.cp 0
+.ftr CW CR
+.ftr C CR
+.ftr CO CI
+.ftr CX CBI
+.ftr H HR
+.ftr HO HI
+.ftr HX HBI
+.ftr NX NBI
+.char \(ru \D'l .5m 0'
+.char \(ul \v'.25m'\D'l .5m 0'\v'-.25m'
+.char \(br \v'.25m'\D'l 0 -1m'\v'.75m'
+.char \(rn \v'-.75m'\D'l .5m 0'\v'.75m'
+.\" .char ~ \v'-.55m'\\s[\\n(.s/2u]\v'.2m'\(ti\v'-.2m'\s0\v'.55m'
+.\" .char ^ \v'-.55m'\\s[\\n(.s/2u]\v'.3m'\(ha\v'-.3m'\s0\v'.55m'
+.if !c\(va .char \(va \o'\(ua\(da'
+.if !c\(em .char \(em --
+.if !c\(en .char \(en \-
+.if !c\(fi .char \(fi fi
+.if !c\(fl .char \(fl fl
+.if !c\(ff .char \(ff ff
+.if !c\(Fi .char \(Fi ffi
+.if !c\(Fl .char \(Fl ffl
+.if !c\(ci .char \(ci \v'-.25m'\h'.05m'\D'c .5m'\h'.05m'\v'.25m'
+.if !c\(sq .char \(sq \h'.05m'\D'l .5m 0'\D'l 0 -.5m'\D'l -.5m 0'\D'l 0 .5m'\h'.55m'
+.if !c\(ga .char \(ga \Z'\v'-.7m'\D'l .22m .18m''\h'.33m'
+.if !c\(dg .char \(dg \Z'\h'.25m'\v'.15m'\D'l 0 -.8m'\v'.2m'\h'-.195m'\
+\D'l .39m 0''\h'.5m'
+.if !c\(dd .char \(dd \Z'\h'.25m'\v'.15m'\D'l 0 -.8m'\v'.2m'\h'-.195m'\
+\D'l .39m 0'\v'.4m'\D'l -.39m 0''\h'.5m'
+.if !c\(lq .char \(lq ``
+.if !c\(rq .char \(rq ''
+.if !c\(Bq .char \(bq ,,
+.if !c\(OE .char \(OE O\h'-.25m'E
+.if !c\(oe .char \(oe o\h'-.14m'e
+.if !c\(ah .char \(ah \v'-.55m'\s[\En[.s]/2u]v\s0\v'.55m'
+.if !c\(ao .char \(ao \v'-.55m'\s[\En[.s]*6u/10u]\D'c .25m'\s0\v'.55m'
+.if !c\(ho .char \(ho \s[\En[.s]/2u]\v'.4m'c\v'-.4m'\s0
+.if !c\(lh .char \(lh <-
+.if !c\(rh .char \(rh ->
+.if !c\(bq .tr \(bq,
+.if !c\(aq .tr \(aq'
+.if '\*(.T'html' .char \[radicalex] \h'-\w'\(sr'u'\[radicalex]\h'\w'\(sr'u'
+.if !\n(_C .mso tmac.pspic
+.cp \n(_C
+.\" now turn off all headers and footers for ms, me and mm macro sets
+.if d EF .EF '''
+.if d EH .EH '''
+.if d OF .OF '''
+.if d OH .OH '''
+.if d ef .ef '''
+.if d of .of '''
+.if d oh .oh '''
+.if d eh .eh '''
+.\" it doesn't make sense to use hyphenation with html, so we turn it off.
+.hy 0
+.nr HY 0
+.\" avoid line breaks after hyphen-like characters.
+.cflags 0 -\(hy\(em\(en\[shc]
+.\" now load the tag macros
+.mso tmac.html-tags
diff --git a/tmac/troffrc-end b/tmac/troffrc-end
index edd23e4f..090849b9 100644
--- a/tmac/troffrc-end
+++ b/tmac/troffrc-end
@@ -3,4 +3,5 @@
.\" this file is parsed after all macro sets have been read
.\"
.if '\*(.T'html' .mso tmac.html
+.if '\*(.T'html2' .mso tmac.html2
.\" Don't let blank lines creep in here. \ No newline at end of file