Werner LEMBERG <[EMAIL PROTECTED]> writes: > Gaius, > > > look at chapter 15.4 in pic-15.html. There you can see this: > > sh { anything... > > } > > but it should be this: > > sh { anything... } > > Definitely a bug.
Hi Werner, I've fixed this bug and a few others (many vertical space bugs have been quashed). Manual page production looks much better, I think.. In particular the changes include: * modifying the indentation implementation to use <p style=margin-left: n%>. Many thanks to Peter and Larry for suggesting this solution. Grohtml only uses tables for .IP and related tags when the first operand has a short width. Hopefully it is now using a nail and hammer approach rather than screwdriver and hammer :-) * modified all vertical space code, by default grohtml sets up a style sheet which uses no vertical space between table, pre and p tags. It forces spaces when it needs them using style="margin-top: 1em". * modified the DC macro within www.tmac to issue a percentage dropcap image. I think this produces a better drop capital. Also modified MPIMG so that the height and width can also be given as a percentage. Modified the manual page to document this feature. hope these are useful, Gaius --- groff-cvs/tmac/www.tmac Sat Dec 18 08:09:39 2004 +++ groff-html/tmac/www.tmac Mon Jan 24 22:50:15 2005 @@ -524,6 +524,33 @@ . wh \\n[www-left-ll-trap]u . nr www-left-ll-trap 0 .. +. +.\" www-handle-percent arg N1 N2 S1 +.\" arg - input string (number or number%) +.\" output parameters: +.\" N1 - name of number register 1=absolute 0=percentage +.\" N2 - number register name for absolute value +.\" S1 - string register name for percentage value +. +.de www-handle-percent +. ds www-percent \\$1 +. substring www-percent -1 -1 +. +. ie '\\*[www-percent]'%' \{\ +. ds www-abs \\$1 +. substring www-abs 0 -2 +. nr \\$2 0 +. nr \\$3 \\*[www-abs] +. ds \\$4 \\$1 +. \} +. el \{\ +. nr \\$2 1 +. nr \\$3 \\$1 +. ds \\$4 none +. \} +. \} +. +.. .\" -------------------------------------------------------------------- .\" MPIMG [-R|-L] [-G gap] filename [width [height]] .\" @@ -531,6 +558,10 @@ .\" -Tps and -Thtml. The default value for WIDTH is 1i; default value .\" for HEIGHT is WIDTH; the default alignment is left (-L). .\" -G is used to insert a gap between the text and the image. +.\" The height and width can also be given as a percentage. +.\" The PostScript device converts the percentage width into an +.\" absolute value by using \\n[.l] and the height by using \\n[.p]. +.\" .\" .\" Note: This macro can only be used with the `-U' option of groff, .\" activating unsafe mode, if not used with -Thtml; the PNG image @@ -561,24 +592,74 @@ . \} . break . \} +. . nr www-width 1i -. if !'\\$2'' \ -. nr www-width \\$2 -. nr www-height \\n[www-width] -. if !'\\$3'' \ -. nr www-height \\$3 -. nr www-width (\\n[www-width] * 100 / 240) -. nr www-height (\\n[www-height] * 100 / 240) +. nr www-height 1i +. ds www-size-specs "width=\\n[www-width] height=\\n[www-height] +. ie !'\\$2'' \{\ +. nr www-is-absolute 0 +. nr www-absolute 0 +. ds www-percentage "none +. www-handle-percent \\$2 www-is-absolute www-absolute www-percentage +. ie !\\n[www-is-absolute] \{\ +. \" percentage of linelength requested +. nr www-width (\\n[www-absolute] * \\n[.l] / 100) +. if \\n[www-html] \ +. nr www-width (\\n[www-width] * 100 / 240) +. ds www-size-specs "width=\\*[www-percentage] +. \} +. el \{\ +. nr www-width \\n[www-absolute] +. if \\n[www-html] \ +. nr www-width (\\n[www-width] * 100 / 240) +. ds www-size-specs "width=\\n[www-width] +. \} +. +. nr www-height \\n[www-width] +. ie !'\\$3'' \{\ +. nr www-is-absolute 0 +. nr www-absolute 0 +. ds www-percentage "none +. www-handle-percent \\$3 www-is-absolute www-absolute www-percentage +. ie !\\n[www-is-absolute] \{\ +. \" percentage of pagelength requested +. nr www-height (\\n[www-absolute] * \\n[.p] / 100) +. if \\n[www-html] \ +. nr www-height (\\n[www-height] * 100 / 240) +. ds www-size-specs "\\*[www-size-specs] height=\\*[www-percentage] +. \} +. el \{\ +. nr www-height \\n[www-absolute] +. if \\n[www-html] \ +. nr www-height (\\n[www-height] * 100 / 240) +. ds www-size-specs "\\*[www-size-specs] height=\\*[www-height] +. \} +. \} +. \} +. el \{\ +. \" height not specified use width value +. ie !\\n[www-is-absolute] \{\ +. \" percentage value +. ds www-size-specs "\\*[www-size-specs] height=\\*[www-percentage] +. nr www-height \\n[www-width] +. \} +. el \{\ +. ds www-size-specs "\\*[www-size-specs] height=\\*[www-percentage] +. nr www-height \\n[www-width] +. \} +. \} . . ie \\n[www-html] \{\ . ie !\\n[www-image-just] \ . HTML <img src="\\$1" alt="Image \\$1" hspace=\\n[www-htmlimage-gap] \ - align=right width=\\n[www-width] height=\\n[www-height]> + align=right \\*[www-size-specs]> . el \ . HTML <img src="\\$1" alt="Image \\$1" hspace=\\n[www-htmlimage-gap] \ - align=left width=\\n[www-width] height=\\n[www-height]> + align=left \\*[www-size-specs]> . \} . el \{\ +. tm www-width is \\n[www-width] +. tm www-height is \\n[www-height] . if !r ps4html \{\ . www-make-unique-name . sy pngtopnm \\$1 | pnmcrop -white | @PNMTOPS_NOSETPAGE@ -noturn > \\*[www-unique-name].eps @@ -589,7 +670,7 @@ . wh \\n[www-left-ll-trap]u . if (\\n[www-left-po-trap] > 0) \ . wh \\n[www-left-po-trap]u -. PSPIC -R \\*[www-unique-name].eps \\$2 \\$3 +. PSPIC -R \\*[www-unique-name].eps \\n[www-width]u \\n[www-height]u . sp -\\n[ps-desht]u . nr www-right-indent \\n[ps-deswid]u . \" we want to have some space between text and image, @@ -608,7 +689,7 @@ . \" we must now disable a possible right image trap . if (\\n[www-right-ll-trap] > 0) \ . wh \\n[www-right-ll-trap]u -. PSPIC -L \\*[www-unique-name].eps \\$2 \\$3 +. PSPIC -L \\*[www-unique-name].eps \\n[www-width]u \\n[www-height]u . sp -\\n[ps-desht]u . nr www-left-indent \\n[ps-deswid]u . \" increase offset by gap @@ -790,7 +871,8 @@ . ds www-dropcolor \\$3 . ie '\*(.T'html' \{\ . www-make-unique-name -. MPIMG -L \\*[www-unique-name].png "(\\n[.v] * 2u)" +. nr www-drop-width (100u * \\n[.v]u * 3u / \\n[.l]u) +. MPIMG -L \\*[www-unique-name].png "\\n[www-drop-width]%" . \} . el \{\ . ie r ps4html \{\ @@ -801,9 +883,9 @@ . \" glyphs overlap. . bp . ev www-DC -. vs 80p +. vs 320p . nop \O[5i\\*[www-unique-name].png]\O[1] -. nop \m[\\*[www-dropcolor]]\s[40]\O[3]\\$1\O[4] +. nop \m[\\*[www-dropcolor]]\s[160]\O[3]\\$1\O[4] . nop \O[2]\O[0] . br . ev --- groff-cvs/tmac/groff_www.man Sat Nov 20 09:27:57 2004 +++ groff-html/tmac/groff_www.man Wed Jan 26 18:46:23 2005 @@ -329,6 +329,21 @@ .ft P .fi .RE +.IP +The height and width may also be given as percentages. The PostScript +device calculates the width from the +.B .l +register and the height from the +.B .p +register. For example: +.RS +.IP +.nf +.ft B +\&.MPIMG -L -G 2c foo.png 15% +.ft P +.fi +.RE . .TP .B .HnS n --- groff-cvs/src/devices/grohtml/post-html.cpp Thu Dec 16 13:09:54 2004 +++ groff-html/src/devices/grohtml/post-html.cpp Mon Feb 14 14:58:54 2005 @@ -1993,6 +1993,8 @@ int next_center; int seen_space; int seen_break; + int current_column; + int row_space; assert_state as; void flush_sbuf (); @@ -2019,6 +2021,7 @@ void start_font (const char *name); void end_font (const char *name); int is_font_courier (font *f); + int is_line_start (int nf); int is_courier_until_eol (void); void start_size (int from, int to); void do_font (text_glob *g); @@ -2090,7 +2093,7 @@ void do_end_para (text_glob *g); int round_width (int x); void handle_tag_within_title (text_glob *g); - + void writeHeadMetaStyle (void); // ADD HERE public: @@ -2199,18 +2202,20 @@ determine_space(g); current_paragraph->do_emittext(g->text_string, g->text_length); } else { + int space = current_paragraph->retrieve_para_space() || seen_space; + current_paragraph->done_para(); shutdown_table(); switch (next_tag) { case CENTERED: - current_paragraph->do_para("align=center"); + current_paragraph->do_para("align=center", space); break; case LEFT: - current_paragraph->do_para(&html, "align=left", get_troff_indent(), pageoffset, linelength); + current_paragraph->do_para(&html, "align=left", get_troff_indent(), pageoffset, linelength, space); break; case RIGHT: - current_paragraph->do_para(&html, "align=right", get_troff_indent(), pageoffset, linelength); + current_paragraph->do_para(&html, "align=right", get_troff_indent(), pageoffset, linelength, space); break; default: fatal("unknown enumeration"); @@ -2409,6 +2414,8 @@ void html_printer::write_header (void) { if (! header.header_buffer.empty()) { + int space = current_paragraph->retrieve_para_space() || seen_space; + if (header.header_level > 7) { header.header_level = 7; } @@ -2492,7 +2499,7 @@ header.no_of_headings, header.no_of_headings, header.no_of_headings, header.no_of_headings); - current_paragraph->do_para(&html, "", get_troff_indent(), pageoffset, linelength); + current_paragraph->do_para(&html, "", get_troff_indent(), pageoffset, linelength, space); } } @@ -2688,7 +2695,8 @@ { if ((device_indent != -1) && (pageoffset+device_indent != in+pageoff)) { - + + int space = current_paragraph->retrieve_para_space() || seen_space; current_paragraph->done_para(); device_indent = in; @@ -2697,7 +2705,7 @@ linelength = linelen; current_paragraph->do_para(&html, "", device_indent, - pageoffset, max_linelength); + pageoffset, max_linelength, space); } } @@ -2765,7 +2773,7 @@ if (fill_on != on) { if (on) - current_paragraph->do_para(""); + current_paragraph->do_para("", seen_space); fill_on = on; } } @@ -2796,9 +2804,10 @@ seen_center = FALSE; if (next_center > 0) { if (end_center == 0) { + int space = current_paragraph->retrieve_para_space() || seen_space; current_paragraph->done_para(); supress_sub_sup = TRUE; - current_paragraph->do_para("align=center"); + current_paragraph->do_para("align=center", space); } else if (strcmp("align=center", current_paragraph->get_alignment()) != 0) { @@ -2806,9 +2815,10 @@ * different alignment, so shutdown paragraph and open * a new one. */ + int space = current_paragraph->retrieve_para_space() || seen_space; current_paragraph->done_para(); supress_sub_sup = TRUE; - current_paragraph->do_para("align=center"); + current_paragraph->do_para("align=center", space); } else /* * same alignment, if we have emitted text then issue a break. @@ -2820,6 +2830,7 @@ * next_center == 0 */ if (end_center > 0) { + seen_space = seen_space || current_paragraph->retrieve_para_space(); current_paragraph->done_para(); supress_sub_sup = TRUE; } @@ -2956,6 +2967,11 @@ seen_space = atoi(arg); as.check_sp(seen_space); +#if 0 + if (n>0 && table) + table->set_space(TRUE); +#endif + while (n>0) { current_paragraph->do_space(); n--; @@ -2972,6 +2988,7 @@ html_table *t = g->get_table(); if (t != NULL) { + current_column = 0; current_paragraph->done_pre(); current_paragraph->done_para(); current_paragraph->remove_para_space(); @@ -2982,7 +2999,13 @@ t->set_linelength(max_linelength); t->add_indent(pageoffset); +#if 0 + t->emit_table_header(seen_space); +#else t->emit_table_header(FALSE); + row_space = current_paragraph->retrieve_para_space() || seen_space; + seen_space = FALSE; +#endif } table = t; @@ -2996,6 +3019,7 @@ { if (table) { current_paragraph->done_para(); + current_paragraph->remove_para_space(); table->emit_finish_table(); } @@ -3043,8 +3067,13 @@ void html_printer::do_col (char *s) { if (table) { + if (atoi(s) < current_column) + row_space = seen_space; + + current_column = atoi(s); current_paragraph->done_para(); - table->emit_col(atoi(s)); + table->emit_col(current_column); + current_paragraph->do_para("", row_space); } } @@ -3165,9 +3194,6 @@ page_contents->glyphs.start_from_head(); do { g = page_contents->glyphs.get_data(); - if (strcmp(g->text_string, "Here") == 0) - stop(); - #if 0 fprintf(stderr, "[%s:%d:%d:%d:%d]", g->text_string, g->minv, g->minh, g->maxv, g->maxh) ; @@ -3731,6 +3757,37 @@ } /* + * is_line_start - returns TRUE if we are at the start of a line. + */ + +int html_printer::is_line_start (int nf) +{ + int line_start = FALSE; + int result = TRUE; + text_glob *orig = page_contents->glyphs.get_data(); + text_glob *g; + + if (! page_contents->glyphs.is_equal_to_head()) { + do { + page_contents->glyphs.move_left(); + g = page_contents->glyphs.get_data(); + result = !g->is_a_tag(); + if (g->is_fi()) + nf = FALSE; + else if (g->is_nf()) + nf = TRUE; + line_start = g->is_col() || g->is_br() || (nf && g->is_eol()); + } while ((!line_start) && (result)); + /* + * now restore our previous position. + */ + while (page_contents->glyphs.get_data() != orig) + page_contents->glyphs.move_right(); + } + return result; +} + +/* * is_font_courier - returns TRUE if the font, f, is courier. */ @@ -3790,24 +3847,28 @@ current_paragraph->do_bold(); current_paragraph->do_italic(); } else if (strcmp(fontname, "CR") == 0) { - if ((! fill_on) && (is_courier_until_eol())) { + if ((! fill_on) && (is_courier_until_eol()) && + is_line_start(fill_on)) { current_paragraph->do_pre(); } current_paragraph->do_tt(); } else if (strcmp(fontname, "CI") == 0) { - if ((! fill_on) && (is_courier_until_eol())) { + if ((! fill_on) && (is_courier_until_eol()) && + is_line_start(fill_on)) { current_paragraph->do_pre(); } current_paragraph->do_tt(); current_paragraph->do_italic(); } else if (strcmp(fontname, "CB") == 0) { - if ((! fill_on) && (is_courier_until_eol())) { + if ((! fill_on) && (is_courier_until_eol()) && + is_line_start(fill_on)) { current_paragraph->do_pre(); } current_paragraph->do_tt(); current_paragraph->do_bold(); } else if (strcmp(fontname, "CBI") == 0) { - if ((! fill_on) && (is_courier_until_eol())) { + if ((! fill_on) && (is_courier_until_eol()) && + is_line_start(fill_on)) { current_paragraph->do_pre(); } current_paragraph->do_tt(); @@ -3968,6 +4029,7 @@ { do_font(g); current_paragraph->done_para(); + current_paragraph->remove_para_space(); html.put_string(g->text_string+9); output_vpos = g->minv; output_hpos = g->maxh; @@ -4125,7 +4187,9 @@ seen_center(FALSE), next_center(0), seen_space(0), - seen_break(0) + seen_break(0), + current_column(0), + row_space(FALSE) { file_list.add_new_file(xtmpfile()); html.set_file(file_list.get_file()); @@ -4435,7 +4499,7 @@ output_vpos_max = -1; current_paragraph = new html_text(&html); do_indent(get_troff_indent(), pageoffset, linelength); - current_paragraph->do_para(""); + current_paragraph->do_para("", FALSE); } void html_printer::end_page(int) @@ -4557,6 +4621,7 @@ fflush(stdout); freopen(split_file.contents(), "w", stdout); fragment_no++; + writeHeadMetaStyle(); write_navigation(top, prev, next, current); } if (file_list.are_links_required()) @@ -4568,6 +4633,31 @@ write_rule(); } +/* + * writeHeadMetaStyle - emits the <head> <meta> and <style> tags and + * related information. + */ + +void html_printer::writeHeadMetaStyle (void) +{ + fputs("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n", stdout); + fputs("\"http://www.w3.org/TR/html4/loose.dtd\">\n", stdout); + + fputs("<html>\n", stdout); + fputs("<head>\n", stdout); + fputs("<meta name=\"generator\" " + "content=\"groff -Thtml, see www.gnu.org\">\n", stdout); + fputs("<meta http-equiv=\"Content-Type\" " + "content=\"text/html; charset=US-ASCII\">\n", stdout); + fputs("<meta name=\"Content-Style\" content=\"text/css\">\n", stdout); + + fputs("<style type=\"text/css\">\n", stdout); + fputs(" p { margin-top: 0; margin-bottom: 0; }\n", stdout); + fputs(" pre { margin-top: 0; margin-bottom: 0; }\n", stdout); + fputs(" table { margin-top: 0; margin-bottom: 0; }\n", stdout); + fputs("</style>\n", stdout); +} + html_printer::~html_printer() { #ifdef LONG_FOR_TIME_T @@ -4590,16 +4680,8 @@ .put_string(ctime(&t), strlen(ctime(&t))-1) .end_comment(); - fputs("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n", stdout); - fputs("\"http://www.w3.org/TR/html4/loose.dtd\">\n", stdout); + writeHeadMetaStyle(); - fputs("<html>\n", stdout); - fputs("<head>\n", stdout); - fputs("<meta name=\"generator\" " - "content=\"groff -Thtml, see www.gnu.org\">\n", stdout); - fputs("<meta http-equiv=\"Content-Type\" " - "content=\"text/html; charset=US-ASCII\">\n", stdout); - fputs("<meta name=\"Content-Style\" content=\"text/css\">\n", stdout); write_title(TRUE); head_info += '\0'; fputs(head_info.contents(), stdout); --- groff-cvs/src/devices/grohtml/html-text.cpp Fri Oct 15 06:08:35 2004 +++ groff-html/src/devices/grohtml/html-text.cpp Fri Feb 11 16:11:46 2005 @@ -41,11 +41,12 @@ #include "html-text.h" #undef DEBUGGING +// #define DEBUGGING html_text::html_text (simple_output *op) : stackptr(NULL), lastptr(NULL), out(op), space_emitted(TRUE), current_indentation(-1), pageoffset(-1), linelength(-1), - blank_para(TRUE), start_space(TRUE) + blank_para(TRUE), start_space(FALSE) { } @@ -146,11 +147,11 @@ case I_TAG: out->put_string("</i>"); break; case B_TAG: out->put_string("</b>"); break; case P_TAG: if (t->indent == NULL) { - if (t->really_issued) - out->put_string("</p>"); + out->put_string("</p>"); } else { delete t->indent; t->indent = NULL; + out->put_string("</p>"); } out->enable_newlines(FALSE); blank_para = TRUE; break; @@ -158,7 +159,11 @@ case SUP_TAG: out->put_string("</sup>"); break; case TT_TAG: out->put_string("</tt>"); break; case PRE_TAG: out->put_string("</pre>"); out->enable_newlines(TRUE); - blank_para = TRUE; break; + blank_para = TRUE; + if (t->indent != NULL) + delete t->indent; + t->indent = NULL; + break; case SMALL_TAG: out->put_string("</small>"); break; case BIG_TAG: out->put_string("</big>"); break; case COLOR_TAG: out->put_string("</font>"); break; @@ -170,19 +175,29 @@ /* * issue_tag - writes out an html tag with argument. + * space == 0 if no space is requested + * space == 1 if a space is requested + * space == 2 if tag should not have a space style */ -void html_text::issue_tag (const char *tagname, const char *arg) +void html_text::issue_tag (const char *tagname, const char *arg, + int space) { - if ((arg == 0) || (strlen(arg) == 0)) { + if ((arg == 0) || (strlen(arg) == 0)) out->put_string(tagname); - out->put_string(">"); - } else { + else { out->put_string(tagname); out->put_string(" "); out->put_string(arg); - out->put_string(">"); } + if (space == TRUE) { + out->put_string(" style=\"margin-top: "); + out->put_string(STYLE_VERTICAL_SPACE); + out->put_string("\""); + } + if (space == TRUE || space == FALSE) + out->put_string(" valign=\"top\""); + out->put_string(">"); } /* @@ -221,28 +236,26 @@ #if defined(DEBUGGING) out->simple_comment("INDENTATION"); #endif - t->indent->begin(FALSE); - t->really_issued = FALSE; - } else if (start_space) { + out->put_string("\n<p"); + t->indent->begin(start_space); + issue_tag("", (char *)t->arg1); + } else { out->nl(); - issue_tag("\n<p", (char *)t->arg1); - t->really_issued = TRUE; - } else - t->really_issued = FALSE; + issue_tag("\n<p", (char *)t->arg1, start_space); + } out->enable_newlines(TRUE); break; case SUB_TAG: issue_tag("<sub", (char *)t->arg1); break; case SUP_TAG: issue_tag("<sup", (char *)t->arg1); break; case TT_TAG: issue_tag("<tt", (char *)t->arg1); break; - case PRE_TAG: if (t->indent != NULL) { - out->nl(); -#if defined(DEBUGGING) - out->simple_comment("INDENTATION"); -#endif - t->indent->begin(FALSE); - } - out->enable_newlines(TRUE); - out->nl(); issue_tag("<pre", (char *)t->arg1); + case PRE_TAG: out->enable_newlines(TRUE); + out->nl(); out->put_string("<pre"); + if (t->indent == NULL) + issue_tag("", (char *)t->arg1, start_space); + else { + t->indent->begin(start_space); + issue_tag("", (char *)t->arg1); + } out->enable_newlines(FALSE); break; case SMALL_TAG: issue_tag("<small", (char *)t->arg1); break; case BIG_TAG: issue_tag("<big", (char *)t->arg1); break; @@ -273,7 +286,6 @@ free(p); } lastptr = NULL; - start_space = TRUE; } /* @@ -367,7 +379,6 @@ p->arg1 = arg; p->text_emitted = FALSE; p->indent = in; - p->really_issued= FALSE; if (t == PRE_TAG && is_present(PRE_TAG)) fatal("cannot have multiple PRE_TAGs"); @@ -389,7 +400,6 @@ p->col = *c; p->text_emitted = FALSE; p->indent = NULL; - p->really_issued= FALSE; do_push(p); } @@ -633,7 +643,7 @@ void html_text::do_emittext (const char *s, int length) { if ((! is_present(P_TAG)) && (! is_present(PRE_TAG))) - do_para(""); + do_para("", FALSE); if (is_present(BREAK_TAG)) { int text = remove_break(); @@ -656,7 +666,7 @@ * do_para - starts a new paragraph */ -void html_text::do_para (const char *arg, html_indent *in) +void html_text::do_para (const char *arg, html_indent *in, int space) { if (! is_present(P_TAG)) { if (is_present(PRE_TAG)) { @@ -670,17 +680,18 @@ } remove_sub_sup(); push_para(P_TAG, (void *)arg, in); + start_space = space; } } -void html_text::do_para (const char *arg) +void html_text::do_para (const char *arg, int space) { - do_para(arg, NULL); + do_para(arg, NULL, space); } void html_text::do_para (simple_output *op, const char *arg1, int indentation_value, int page_offset, - int line_length) + int line_length, int space) { html_indent *ind; @@ -688,7 +699,7 @@ ind = NULL; else ind = new html_indent(op, indentation_value, page_offset, line_length); - do_para(arg1, ind); + do_para(arg1, ind, space); } /* @@ -723,8 +734,7 @@ /* * remove_para_space - removes the leading space to a paragraph - * (effectively this trims off the <p> and </p> - * tags. + * (effectively this trims off a leading `.sp' tag). */ void html_text::remove_para_space (void) @@ -739,23 +749,14 @@ void html_text::do_space (void) { if (is_in_pre()) { -#if 0 - if (blank_para) - start_space = TRUE; - else { -#endif - do_emittext("", 0); - out->force_nl(); - space_emitted = TRUE; -#if 0 - } -#endif + do_emittext("", 0); + out->force_nl(); + space_emitted = TRUE; } else { html_indent *i = remove_indent(P_TAG); - do_para(done_para(), i); + do_para(done_para(), i, TRUE); space_emitted = TRUE; - start_space = TRUE; } } @@ -765,13 +766,11 @@ void html_text::do_break (void) { - if (! is_present(PRE_TAG)) { - if (emitted_text()) { - if (! is_present(BREAK_TAG)) { + if (! is_present(PRE_TAG)) + if (emitted_text()) + if (! is_present(BREAK_TAG)) push_para(BREAK_TAG); - } - } - } + space_emitted = TRUE; } @@ -797,7 +796,8 @@ } /* - * ever_emitted_text - returns TRUE if we have ever emitted text in this paragraph. + * ever_emitted_text - returns TRUE if we have ever emitted text in this + * paragraph. */ int html_text::ever_emitted_text (void) @@ -815,6 +815,23 @@ } /* + * retrieve_para_space - returns TRUE, if the paragraph starts with + * a space and text has not yet been emitted. + * If TRUE is returned, then the, start_space, + * variable is set to FALSE. + */ + +int html_text::retrieve_para_space (void) +{ + if (start_space && blank_para) { + start_space = FALSE; + return TRUE; + } + else + return FALSE; +} + +/* * emit_space - writes a space providing that text was written beforehand. */ @@ -951,7 +968,7 @@ if (p->type == P_TAG && p->arg1 != NULL) { html_indent *i = remove_indent(P_TAG); done_para(); - do_para("", i); + do_para("", i, space_emitted); return; } p = p->next; @@ -1021,4 +1038,3 @@ { push_para(SUB_TAG); } - --- groff-cvs/src/devices/grohtml/html-text.h Tue Oct 12 22:39:31 2004 +++ groff-html/src/devices/grohtml/html-text.h Fri Feb 11 16:01:03 2005 @@ -28,6 +28,8 @@ #include "html.h" #include "html-table.h" +#define STYLE_VERTICAL_SPACE "1em" + /* * html tags */ @@ -41,7 +43,6 @@ void *arg1; int text_emitted; color col; - int really_issued; html_indent *indent; tag_definition *next; } tag_definition ; @@ -65,9 +66,10 @@ void do_pre (void); void do_small (void); void do_big (void); - void do_para (const char *arg); // used for no indentation + void do_para (const char *arg, int space); // used for no indentation void do_para (simple_output *op, const char *arg1, - int indentation, int pageoffset, int linelength); + int indentation, int pageoffset, int linelength, + int space); void do_sup (void); void do_sub (void); void do_space (void); @@ -88,6 +90,7 @@ int emitted_text (void); int ever_emitted_text (void); int starts_with_space (void); + int retrieve_para_space (void); void emit_space (void); int is_in_pre (void); int uses_indent (void); @@ -112,7 +115,7 @@ int is_present (HTML_TAG t); void end_tag (tag_definition *t); void start_tag (tag_definition *t); - void do_para (const char *arg, html_indent *in); + void do_para (const char *arg, html_indent *in, int space); void push_para (HTML_TAG t); void push_para (HTML_TAG t, void *arg, html_indent *in); void push_para (color *c); @@ -120,7 +123,7 @@ char *shutdown (HTML_TAG t); void check_emit_text (tag_definition *t); int remove_break (void); - void issue_tag (const char *tagname, const char *arg); + void issue_tag (const char *tagname, const char *arg, int space=2); void issue_color_begin (color *c); void remove_def (tag_definition *t); html_indent *remove_indent (HTML_TAG tag); --- groff-cvs/src/devices/grohtml/html-table.h Tue Oct 12 22:39:31 2004 +++ groff-html/src/devices/grohtml/html-table.h Fri Feb 4 12:38:06 2005 @@ -92,14 +92,15 @@ void add_indent (int indent); void finish_row (void); int get_effective_linelength (void); + void set_space (int space); tabs *tab_stops; /* tab stop positions */ + simple_output *out; private: cols *columns; /* column entries */ - simple_output *out; int linelength; cols *last_col; /* last column started */ - int start_space; /* encapsulate with <p> </p> */ + int start_space; /* have we seen a `.sp' tag? */ void remove_cols (cols *c); }; --- groff-cvs/src/devices/grohtml/html-table.cpp Tue Nov 23 09:20:48 2004 +++ groff-html/src/devices/grohtml/html-table.cpp Mon Feb 7 17:33:55 2005 @@ -32,6 +32,7 @@ #include "html-table.h" #include "ctype.h" #include "html.h" +#include "html-text.h" #if !defined(TRUE) # define TRUE (1==1) @@ -335,19 +336,18 @@ out->nl(); out->nl(); -#if 0 - if (space) - out->put_string("<p>"); -#endif - - start_space = space; out->put_string("<table width=\"100%\"") .put_string(" border=0 rules=\"none\" frame=\"void\"\n") - .put_string(" cellspacing=\"0\" cellpadding=\"0\"") - .put_string(start_space ? " style=\"margin-top: 8px; margin-bottom: 8px\"" : "") - .put_string(">") + .put_string(" cellspacing=\"0\" cellpadding=\"0\""); + out->put_string(">") .nl(); - out->put_string("<tr valign=\"top\" align=\"left\">").nl(); + out->put_string("<tr valign=\"top\" align=\"left\""); + if (space) { + out->put_string(" style=\"margin-top: "); + out->put_string(STYLE_VERTICAL_SPACE); + out->put_string("\""); + } + out->put_string(">").nl(); } } @@ -365,6 +365,16 @@ } /* + * set_space - assigns start_space. Used to determine the + * vertical alignment when generating the next table row. + */ + +void html_table::set_space (int space) +{ + start_space = space; +} + +/* * emit_col - moves onto column, n. */ @@ -478,7 +488,15 @@ void html_table::emit_new_row (void) { finish_row(); - out->put_string("<tr valign=\"top\" align=\"left\">").nl(); + + out->put_string("<tr valign=\"top\" align=\"left\""); + if (start_space) { + out->put_string(" style=\"margin-top: "); + out->put_string(STYLE_VERTICAL_SPACE); + out->put_string("\""); + } + out->put_string(">").nl(); + start_space = FALSE; last_col = NULL; } @@ -486,10 +504,6 @@ { finish_row(); out->put_string("</table>"); -#if 0 - if (start_space) - out->put_string("</p>"); -#endif } /* @@ -718,7 +732,6 @@ in = ind; pg = pageoffset; ll = linelength; - is_used = FALSE; } html_indent::~html_indent (void) @@ -729,18 +742,33 @@ void html_indent::begin (int space) { - if (! is_used) { - table->emit_table_header(space); - table->emit_col(1); - is_used = TRUE; + if (in + pg == 0) { + if (space) { + table->out->put_string(" style=\"margin-top: "); + table->out->put_string(STYLE_VERTICAL_SPACE); + table->out->put_string("\""); + } + } + else { + // + // we use exactly the same mechanism for calculating + // indentation as html_table::emit_col + // + table->out->put_string(" style=\"margin-left:") + .put_number(((in + pg) * 100 + ll/2) / ll - + (ll/2)/ll) + .put_string("%;"); + + if (space) { + table->out->put_string(" margin-top: "); + table->out->put_string(STYLE_VERTICAL_SPACE); + } + table->out->put_string("\""); } } void html_indent::end (void) { - if (is_used) - table->emit_finish_table(); - is_used = FALSE; } /* _______________________________________________ Groff mailing list Groff@gnu.org http://lists.gnu.org/mailman/listinfo/groff