[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Groff] Re: finally some grohtml patches
From: |
Gaius Mulley |
Subject: |
[Groff] Re: finally some grohtml patches |
Date: |
Tue, 16 Jul 2002 15:21:02 +0100 |
oops ignore last patch - I forgot some files, here it is again
(env.cc and env.h were missing). Sorry..
Gaius
--- groff-cvs/src/devices/grohtml/post-html.cc Tue Jul 16 15:09:47 2002
+++ groff-html/src/devices/grohtml/post-html.cc Tue Jul 16 11:43:45 2002
@@ -1499,6 +1499,7 @@
void do_center (char *arg);
void do_break (void);
void do_eol (void);
+ void do_eol_ce (void);
void do_title (void);
void do_fill (int on);
void do_heading (char *arg);
@@ -2005,7 +2006,7 @@
if (! g->is_a_tag() && (! is_font_courier(g->text_style.f)))
result = FALSE;
page_contents->glyphs.move_right();
- } while ((result) &&
+ } while (result &&
(! page_contents->glyphs.is_equal_to_head()) &&
(! g->is_fi()) && (! g->is_eol()));
@@ -2015,7 +2016,7 @@
while (page_contents->glyphs.get_data() != orig)
page_contents->glyphs.move_left();
}
- return( result );
+ return result;
}
/*
@@ -2150,6 +2151,14 @@
}
}
output_hpos = indentation+pageoffset;
+}
+
+/*
+ * do_eol_ce - handle end of line specifically for a .ce
+ */
+
+void html_printer::do_eol_ce (void)
+{
if (end_center > 0) {
if (end_center > 1)
if (current_paragraph->emitted_text())
@@ -2237,6 +2246,15 @@
}
table = NULL;
+
+ if (indentation > 0) {
+ /*
+ * restore indentation
+ */
+ int newin = indentation;
+ indentation = 0;
+ do_indent(newin, pageoffset, linelength);
+ }
}
/*
@@ -2298,7 +2316,7 @@
if (g->is_eol()) {
do_eol();
} else if (g->is_eol_ce()) {
- do_eol();
+ do_eol_ce();
} else if (strncmp(t, ".sp", 3) == 0) {
if (g->get_arg() > 0)
current_paragraph->do_space();
@@ -2391,9 +2409,8 @@
do {
g = page_contents->glyphs.get_data();
- if (strcmp(g->text_string, "XXXXXX") == 0) {
+ if (strcmp(g->text_string, "XXXXXXX") == 0)
stop();
- }
if (g->is_a_tag()) {
troff_tag(g);
@@ -2561,8 +2578,6 @@
nf = calc_nf(g, nf);
if (line_start) {
- if (nf)
- stop();
if (line_start && nf && is_courier_until_eol()) {
remove_tabs();
g = page_contents->glyphs.get_data();
@@ -2644,6 +2659,7 @@
int colmin;
int colmax;
html_table *table = new html_table(&html, -1);
+ const char *tab_defs = NULL;
char align = 'L';
int nf = FALSE;
@@ -2655,9 +2671,25 @@
page_contents->glyphs.start_from_head();
g = page_contents->glyphs.get_data();
do {
+#if 0
+ if (strcmp(g->text_string, "XXXXXXX") == 0)
+ stop();
+#endif
+
nf = calc_nf(g, nf);
calc_po_in(g, nf);
if (g->is_col()) {
+ if (type_of_col == tab_tag && start_of_table != NULL) {
+ page_contents->glyphs.move_left();
+ insert_tab_te();
+ start_of_table->remember_table(table);
+ table = new html_table(&html, -1);
+ page_contents->insert_tag(string("*** TAB -> COL ***"));
+ if (tab_defs != NULL)
+ table->tab_stops->init(tab_defs);
+ start_of_table = NULL;
+ last = NULL;
+ }
type_of_col = col_tag;
found_col = TRUE;
ncol = g->get_arg();
@@ -2674,6 +2706,18 @@
if (colmax > 0)
colmax += pageoffset + indentation;
} else if (g->is_tab0()) {
+ if (type_of_col == col_tag && start_of_table != NULL) {
+ page_contents->glyphs.move_left();
+ insert_tab_te();
+ start_of_table->remember_table(table);
+ table = new html_table(&html, -1);
+ page_contents->insert_tag(string("*** COL -> TAB ***"));
+ start_of_table = NULL;
+ last = NULL;
+ }
+ if (tab_defs != NULL)
+ table->tab_stops->init(tab_defs);
+
type_of_col = tab0_tag;
ncol = 1;
colmin = 0;
@@ -2695,12 +2739,9 @@
}
}
- if (! g->is_a_tag())
+ if ((! g->is_a_tag()) || g->is_tab())
seen_text = TRUE;
- // if (strcmp(g->text_string, "ZZZZZZZ") == 0)
- // stop();
-
if ((g->is_col() || g->is_tab() || g->is_tab0())
&& (start_of_line != NULL) && (start_of_table == NULL)) {
start_of_table = insert_tab_ts(start_of_line);
@@ -2713,21 +2754,24 @@
page_contents->insert_tag(string("*** CE ***"));
start_of_table = NULL;
last = NULL;
- } else if (g->is_ta() && !table->tab_stops->compatible(g->text_string)) {
- table->tab_stops->init(g->text_string);
- if (start_of_table != NULL) {
- page_contents->glyphs.move_left();
- insert_tab_te();
- start_of_table->remember_table(table);
- table = new html_table(&html, -1);
- page_contents->insert_tag(string("*** TABS ***"));
- start_of_table = NULL;
- type_of_col = none;
- last = NULL;
+ } else if (g->is_ta()) {
+ tab_defs = g->text_string;
+ if (!table->tab_stops->compatible(tab_defs)) {
+ if (start_of_table != NULL) {
+ page_contents->glyphs.move_left();
+ insert_tab_te();
+ start_of_table->remember_table(table);
+ table = new html_table(&html, -1);
+ page_contents->insert_tag(string("*** TABS ***"));
+ start_of_table = NULL;
+ type_of_col = none;
+ last = NULL;
+ }
+ table->tab_stops->init(tab_defs);
}
}
- if ((! g->is_a_tag()) && (start_of_table != NULL)) {
+ if (((! g->is_a_tag()) || g->is_tab()) && (start_of_table != NULL)) {
// we are in a table and have a glyph
if ((ncol == 0) || (! table->add_column(ncol, colmin, colmax, align))) {
page_contents->glyphs.move_left();
--- groff-cvs/src/roff/troff/input.cc Mon May 27 13:41:06 2002
+++ groff-html/src/roff/troff/input.cc Tue Jul 16 15:18:41 2002
@@ -256,7 +256,6 @@
const char *filename;
int popened;
int newline_flag;
- int suppress_newline_flag; // used by html
int seen_escape;
enum { BUF_SIZE = 512 };
unsigned char buf[BUF_SIZE];
@@ -275,7 +274,7 @@
file_iterator::file_iterator(FILE *f, const char *fn, int po)
: fp(f), lineno(1), filename(fn), popened(po),
- newline_flag(0), suppress_newline_flag(0), seen_escape(0)
+ newline_flag(0), seen_escape(0)
{
if ((font::use_charnames_in_special) && (fn != 0)) {
if (!the_output)
@@ -313,7 +312,6 @@
fp = f;
lineno = 1;
newline_flag = 0;
- suppress_newline_flag = 0;
seen_escape = 0;
popened = 0;
ptr = 0;
@@ -323,12 +321,9 @@
int file_iterator::fill(node **)
{
- if (newline_flag && !suppress_newline_flag) {
- curenv->add_html_tag_eol();
+ if (newline_flag)
lineno++;
- }
newline_flag = 0;
- suppress_newline_flag = 0;
unsigned char *p = buf;
ptr = p;
unsigned char *e = p + BUF_SIZE;
@@ -341,8 +336,6 @@
else {
*p++ = c;
if (c == '\n') {
- if (seen_escape && is_html)
- suppress_newline_flag = 1;
seen_escape = 0;
newline_flag = 1;
break;
@@ -3002,7 +2995,6 @@
macro mac;
const char *how_invoked;
int newline_flag;
- int suppress_newline_flag; // used by html
int lineno;
char_block *bp;
int count; // of characters remaining
@@ -3023,7 +3015,7 @@
string_iterator::string_iterator(const macro &m, const char *p, symbol s)
: mac(m), how_invoked(p),
- newline_flag(0), suppress_newline_flag(0), lineno(1), nm(s)
+ newline_flag(0), lineno(1), nm(s)
{
count = mac.length;
if (count != 0) {
@@ -3044,7 +3036,6 @@
nd = 0;
ptr = eptr = 0;
newline_flag = 0;
- suppress_newline_flag = 0;
how_invoked = 0;
lineno = 1;
count = 0;
@@ -3078,8 +3069,6 @@
unsigned char c = *p;
if (c == '\n' || c == ESCAPE_NEWLINE) {
newline_flag = 1;
- if (is_html && c == ESCAPE_NEWLINE)
- suppress_newline_flag = 1;
p++;
break;
}
@@ -4696,34 +4685,6 @@
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) {
- if (!break_flag) {
- if (!topdiv->no_space_mode)
- topdiv->begin_page();
- }
- else if (topdiv->no_space_mode)
- topdiv->begin_page();
- else {
- push_page_ejector();
- topdiv->begin_page();
- topdiv->set_ejecting();
- }
- }
- else {
- push_page_ejector();
- if (break_flag)
- curenv->do_break();
- if (!topdiv->no_space_mode)
- topdiv->set_ejecting();
- }
- }
- }
- // say goodbye to all this code?
-#endif
break;
case '4':
begin_level--;
--- groff-cvs/src/roff/troff/env.cc Tue Jul 16 15:09:25 2002
+++ groff-html/src/roff/troff/env.cc Tue Jul 16 16:16:14 2002
@@ -1685,6 +1685,14 @@
}
input_line_start = line == 0 ? H0 : width_total;
if (to_be_output) {
+ if (is_html && !fill) {
+ if (curdiv == topdiv) {
+ node *n = make_html_tag("eol");
+
+ n->next = to_be_output;
+ to_be_output = n;
+ }
+ }
output_line(to_be_output, to_be_output_width);
hyphen_line_count = 0;
}
@@ -2124,23 +2132,6 @@
}
else
do_break();
-}
-
-/*
- * add_html_tag_eol - add an end of line tag if appropriate.
- */
-
-void environment::add_html_tag_eol()
-{
- if (is_html) {
- if (ignore_next_eol > 0)
- ignore_next_eol--;
- else
- if (!fill && emitted_node) {
- add_html_tag(1, "eol");
- emitted_node = 0;
- }
- }
}
/*
--- groff-cvs/src/roff/troff/env.h Tue Jul 16 15:09:25 2002
+++ groff-html/src/roff/troff/env.h Tue Jul 16 16:12:49 2002
@@ -289,7 +289,6 @@
void possibly_break_line(int start_here = 0, int forced = 0);
void do_break(int spread = 0); // .br
void final_break();
- void add_html_tag_eol();
void add_html_tag(int, const char *);
void add_html_tag(int, const char *, int);
void add_html_tag_tabs(int);