[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] Re: indentation including .IP
From: |
Gaius Mulley |
Subject: |
Re: [Groff] Re: indentation including .IP |
Date: |
Sat, 17 Mar 2001 10:30:30 +0000 |
> May I ask that you check out the latest changes and
> resend me your patch?
here it is,
Thanks Gaius
--- groff-cvs/tmac/s.tmac Fri Mar 16 15:48:32 2001
+++ groff-html/tmac/s.tmac Fri Mar 16 12:12:57 2001
@@ -1153,19 +1153,20 @@
. par*pop-tag-env
. di
. chop par*label
-. ie '\*(.T'html' \{\
-. ti -\\n[\\n[.ev]:ai]u
+. ie '\*(.T'html' \{\
+. if \\n[dl]+1n<=\\n[\\n[.ev]:ai] .HTML-TAG ".ip"
+. ti 0
\\*[par*label]
. br
-. \}
-. el \{\
+. \}
+. el \{\
. ti -\\n[\\n[.ev]:ai]u
. ie \\n[dl]+1n<=\\n[\\n[.ev]:ai]
\\*[par*label]\h'|\\n[\\n[.ev]:ai]u'\c
. el \{\
\\*[par*label]
. br
. \}
-. \}
+. \}
. rm par*label
.\}
..
--- groff-cvs/tmac/groff_mwww.man Wed Jan 17 14:17:26 2001
+++ groff-html/tmac/groff_mwww.man Thu Mar 15 21:42:13 2001
@@ -268,7 +268,6 @@
.B Grohtml
was written by
.MAILTO address@hidden "Gaius Mulley"
-.LINE
.SH BUGS
Report bugs to the
.MAILTO address@hidden "Groff Bug Mailing List" .
--- groff-cvs/tmac/www.tmac Sun Mar 4 22:22:57 2001
+++ groff-html/tmac/www.tmac Thu Mar 15 21:43:04 2001
@@ -143,6 +143,7 @@
.\" LINE - produce a horizontal line
.\"
.de LINE
+. ti 0
. HTML <hr>
..
.\"
--- groff-cvs/src/devices/grohtml/post-html.cc Fri Mar 16 15:48:31 2001
+++ groff-html/src/devices/grohtml/post-html.cc Thu Mar 15 23:40:20 2001
@@ -961,6 +961,7 @@
char *inside_font_style;
int page_number;
title_desc title;
+ title_desc indent; // use title class to remember $1 of .ip
header_desc header;
int header_indent;
int supress_sub_sup;
@@ -1022,6 +1023,7 @@
void do_pageoffset (char *arg);
void do_indentation (char *arg);
void do_tempindent (char *arg);
+ void do_indentedparagraph (void);
void do_verticalspacing (char *arg);
void do_pointsize (char *arg);
void do_centered_image (void);
@@ -1120,8 +1122,8 @@
#if defined(INDENTATION)
if (in_table) {
stop();
- current_paragraph->do_indent(0, pageoffset, linelength);
- current_paragraph->do_indent(indentation, pageoffset, linelength);
+ current_paragraph->do_indent(NULL, 0, pageoffset, linelength);
+ current_paragraph->do_indent(indent.text, indentation, pageoffset,
linelength);
}
#endif
}
@@ -1432,7 +1434,7 @@
#if defined(INDENTATION)
if (fill_on) {
linelength = atoi(arg);
- current_paragraph->do_indent(indentation, pageoffset, linelength);
+ current_paragraph->do_indent(indent.text, indentation, pageoffset,
linelength);
}
#endif
}
@@ -1446,7 +1448,7 @@
#if defined(INDENTATION)
pageoffset = atoi(arg);
if (fill_on) {
- current_paragraph->do_indent(indentation, pageoffset, linelength);
+ current_paragraph->do_indent(indent.text, indentation, pageoffset,
linelength);
}
#endif
}
@@ -1460,7 +1462,7 @@
#if defined(INDENTATION)
if (fill_on) {
indentation = atoi(arg);
- current_paragraph->do_indent(indentation, pageoffset, linelength);
+ current_paragraph->do_indent(indent.text, indentation, pageoffset,
linelength);
}
#endif
}
@@ -1476,12 +1478,68 @@
end_tempindent = 1;
prev_indent = indentation;
indentation = atoi(arg);
- current_paragraph->do_indent(indentation, pageoffset, linelength);
+ current_paragraph->do_indent(indent.text, indentation, pageoffset,
linelength);
}
#endif
}
/*
+ * do_indentedparagraph - handle the .ip tag, this buffers the next line
+ * and passes this to text-text as the left hand
+ * column table entry.
+ */
+
+void html_printer::do_indentedparagraph (void)
+{
+#if defined(INDENTATION)
+ text_glob *t;
+ int removed_from_head;
+ char buf[MAX_STRING_LENGTH];
+ int found_indent_start = FALSE;
+
+ indent.has_been_found = FALSE;
+ indent.text[0] = (char)0;
+
+ if (! page_contents->glyphs.is_empty()) {
+ page_contents->glyphs.sub_move_right(); /* move onto next word */
+ do {
+ t = page_contents->glyphs.get_data();
+ removed_from_head = FALSE;
+ if (t->is_raw_command) {
+ /* skip raw commands
+ */
+ page_contents->glyphs.sub_move_right(); /* move onto next
word */
+ } else if (t->is_a_tag() && (strncmp(t->text_string, "html-tag:.br", 12)
== 0)) {
+ /* end of indented para found, but move back so that we read this tag
and process it
+ */
+ page_contents->glyphs.move_left(); /* move backwards to last
word */
+ indent.has_been_found = TRUE;
+ return;
+ } else if (t->is_a_tag()) {
+ page_contents->glyphs.sub_move_right(); /* move onto next
word */
+ } else if (found_indent_start) {
+ strcat(indent.text, " ");
+ str_translate_to_html(t->text_style.f, buf, MAX_STRING_LENGTH,
t->text_string, t->text_length, TRUE);
+ strcat(indent.text, buf);
+ page_contents->glyphs.sub_move_right(); /* move onto next
word */
+ removed_from_head = ((!page_contents->glyphs.is_empty()) &&
+ (page_contents->glyphs.is_equal_to_head()));
+ } else {
+ str_translate_to_html(t->text_style.f, buf, MAX_STRING_LENGTH,
t->text_string, t->text_length, TRUE);
+ strcpy((char *)indent.text, buf);
+ found_indent_start = TRUE;
+ indent.has_been_found = TRUE;
+ page_contents->glyphs.sub_move_right(); /* move onto next
word */
+ removed_from_head = ((!page_contents->glyphs.is_empty()) &&
+ (page_contents->glyphs.is_equal_to_head()));
+ }
+ } while ((! page_contents->glyphs.is_equal_to_head()) ||
(removed_from_head));
+ }
+ // page_contents->glyphs.move_left(); /* move backwards to last
word */
+#endif
+}
+
+/*
* do_verticalspacing - handle the .vs command from troff.
*/
@@ -1582,7 +1640,7 @@
end_tempindent--;
if (end_tempindent == 0) {
indentation = prev_indent;
- current_paragraph->do_indent(indentation, pageoffset, linelength);
+ current_paragraph->do_indent(indent.text, indentation, pageoffset,
linelength);
}
}
#endif
@@ -1646,6 +1704,8 @@
} else if (strncmp(t, ".vs", 3) == 0) {
char *a = (char *)t+3;
do_verticalspacing(a);
+ } else if (strncmp(t, ".ip", 3) == 0) {
+ do_indentedparagraph();
} else if (strcmp(t, ".links") == 0) {
do_links();
}
@@ -2585,7 +2645,7 @@
output_vpos_max = -1;
current_paragraph = new html_text(&html);
#if defined(INDENTATION)
- current_paragraph->do_indent(indentation, pageoffset, linelength);
+ current_paragraph->do_indent(indent.text, indentation, pageoffset,
linelength);
#endif
current_paragraph->do_para("");
}
--- groff-cvs/src/devices/grohtml/html-text.cc Fri Mar 16 15:48:31 2001
+++ groff-html/src/devices/grohtml/html-text.cc Fri Mar 16 12:09:57 2001
@@ -142,7 +142,13 @@
if (width > 0) {
out->put_string("<table width=\"100%\" rules=\"none\" frame=\"none\"\n
cols=\"2\" cellspacing=\"0\" cellpadding=\"0\">").nl();
out->put_string("<tr valign=\"top\" align=\"left\">").nl();
- out->put_string("<td
width=\"").put_number(width).put_string("%\"></td>");
+ if ((t->arg1 == 0) || (strcmp(t->arg1, "") == 0))
+ out->put_string("<td
width=\"").put_number(width).put_string("%\"></td>");
+ else {
+ out->put_string("<td
width=\"").put_number(width).put_string("%\">").nl();
+ out->put_string(t->arg1).put_string("</td>");
+ t->arg1[0] = (char)0;
+ }
out->put_string("<td
width=\"").put_number(100-width).put_string("%\">").nl();
}
}
@@ -257,7 +263,7 @@
* then we start a html table to implement the indentation.
*/
-void html_text::do_indent (int indent, int pageoff, int linelen)
+void html_text::do_indent (char *arg, int indent, int pageoff, int linelen)
{
if ((current_indentation != -1) &&
(pageoffset+current_indentation != indent+pageoff)) {
@@ -265,14 +271,14 @@
* actual indentation of text has changed, we need to put
* a table tag onto the stack.
*/
- do_table();
+ do_table(arg);
}
current_indentation = indent;
pageoffset = pageoff;
linelength = linelen;
}
-void html_text::do_table (void)
+void html_text::do_table (char *arg)
{
int in_pre = is_in_pre();
// char *para_type = done_para();
@@ -283,7 +289,7 @@
do_pre();
}
// do_para(para_type);
- push_para(TABLE_TAG, "");
+ push_para(TABLE_TAG, arg);
}
/*
--- groff-cvs/src/devices/grohtml/html-text.h Fri Mar 16 15:48:31 2001
+++ groff-html/src/devices/grohtml/html-text.h Thu Mar 15 23:03:30 2001
@@ -66,7 +66,7 @@
void do_space (void);
void do_break (void);
void do_newline (void);
- void do_table (void);
+ void do_table (char *arg);
void done_bold (void);
void done_italic (void);
char *done_para (void);
@@ -76,7 +76,7 @@
void done_pre (void);
void done_small (void);
void done_big (void);
- void do_indent (int indent, int pageoff, int linelen);
+ void do_indent (char *arg, int indent, int pageoff, int linelen);
int emitted_text (void);
int emit_space (void);
int is_in_pre (void);