summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwlemb <wlemb>2001-03-04 22:22:55 +0000
committerwlemb <wlemb>2001-03-04 22:22:55 +0000
commitec341bf13c1244f2578b72d26bf31ede08cf0623 (patch)
tree7acb2f9f2070eee6505a63c80e54514a08175ae2
parent121328a98b70f49934cf1b51b57ee94d786e7ad4 (diff)
downloadgroff-ec341bf13c1244f2578b72d26bf31ede08cf0623.tar.gz
Fixed grohtml handling of any named glyph for glyph indexes < 0x80.
Cosmetic changes to `.html-begin', `.html-end', `.html-image' which are now `.begin', `.end', `.image'. * src/devices/grohtml/post-html.cc: Adding UNICODE_DESC_START. (html_printer::add_to_sbuf): Changing type of `code' parameter. Use add_char_to_sbuf(). (to_unicode): New function. (char_translate_to_html): Changing type of `ch' parameter. Use `to_unicode()'. (html_printer::~html_printer): Comment out doctype string. * src/preproc/html/pre-html.cc (write_end_image): Use `.end' instead of `.html-end'. (write_start_image): Use `.begin' and `.image' instead of `.html-begin' and `.html-image'. * src/roff/troff/input.cc: Rename `html_level' to `begin_level'. (html_begin): Renamed to ... (begin): This. (html_end): Renamed to ... (end): This. (html_image): Renamed to ... (image): This. (init_html_requests): Renamed to ... (init_markup_requests): This. * tmac/www.tmac: Updated.
-rw-r--r--ChangeLog28
-rw-r--r--src/devices/grohtml/post-html.cc35
-rw-r--r--src/preproc/html/pre-html.cc12
-rw-r--r--src/roff/troff/input.cc46
-rw-r--r--src/roff/troff/node.cc11
-rw-r--r--tmac/www.tmac12
6 files changed, 95 insertions, 49 deletions
diff --git a/ChangeLog b/ChangeLog
index 6edcf6b1..575e1e3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2001-03-04 Gaius Mulley <gaius@glam.ac.uk>
+
+ Fixed grohtml handling of any named glyph for glyph indexes < 0x80.
+ Cosmetic changes to `.html-begin', `.html-end', `.html-image' which
+ are now `.begin', `.end', `.image'.
+
+ * src/devices/grohtml/post-html.cc: Adding UNICODE_DESC_START.
+ (html_printer::add_to_sbuf): Changing type of `code' parameter.
+ Use add_char_to_sbuf().
+ (to_unicode): New function.
+ (char_translate_to_html): Changing type of `ch' parameter.
+ Use `to_unicode()'.
+ (html_printer::~html_printer): Comment out doctype string.
+ * src/preproc/html/pre-html.cc (write_end_image): Use `.end'
+ instead of `.html-end'.
+ (write_start_image): Use `.begin' and `.image' instead of
+ `.html-begin' and `.html-image'.
+ * src/roff/troff/input.cc: Rename `html_level' to `begin_level'.
+ (html_begin): Renamed to ...
+ (begin): This.
+ (html_end): Renamed to ...
+ (end): This.
+ (html_image): Renamed to ...
+ (image): This.
+ (init_html_requests): Renamed to ...
+ (init_markup_requests): This.
+ * tmac/www.tmac: Updated.
+
2001-02-28 Bram <bram@avontuur.org>
* src/libs/libgroff/font.cc (font_widths_cache): Fixing syntax of
diff --git a/src/devices/grohtml/post-html.cc b/src/devices/grohtml/post-html.cc
index 7f6490ca..e025cb48 100644
--- a/src/devices/grohtml/post-html.cc
+++ b/src/devices/grohtml/post-html.cc
@@ -52,6 +52,9 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define BASE_POINT_SIZE 10 /* 10 points is the base size ie html size 3 */
#define CENTER_TOLERANCE 2 /* how many pixels off center will we still */
#define ANCHOR_TEMPLATE "heading%d" /* if simple anchor is set we use this */
+#define UNICODE_DESC_START 0x80 /* all character entities above this are */
+ /* either encoded by their glyph names or if */
+ /* there is no name then we use &#nnn; */
typedef enum {CENTERED, LEFT, RIGHT, INLINE} TAG_ALIGNMENT;
@@ -985,7 +988,7 @@ class html_printer : public printer {
void terminate_current_font (void);
void flush_font (void);
void add_char_to_sbuf (unsigned char code);
- void add_to_sbuf (char code, const char *name);
+ void add_to_sbuf (unsigned char code, const char *name);
void write_title (int in_head);
void determine_diacritical_mark (const char *name, const environment *env);
int sbuf_continuation (unsigned char code, const char *name, const environment *env, int w);
@@ -2127,15 +2130,19 @@ void html_printer::add_char_to_sbuf (unsigned char code)
* add_to_sbuf - adds character code or name to the sbuf.
*/
-void html_printer::add_to_sbuf (char code, const char *name)
+void html_printer::add_to_sbuf (unsigned char code, const char *name)
{
+ if (code == 255) stop();
+
if (name == 0) {
add_char_to_sbuf(code);
} else {
if (sbuf_style.f != NULL) {
char *html_glyph = get_html_translation(sbuf_style.f, name);
- if (html_glyph != NULL) {
+ if (html_glyph == NULL) {
+ add_char_to_sbuf(code);
+ } else {
int l = strlen(html_glyph);
int i;
@@ -2300,11 +2307,24 @@ char *get_html_translation (font *f, const char *name)
}
/*
+ * to_unicode - returns a unicode translation of char, ch.
+ */
+
+static char *to_unicode (unsigned char ch)
+{
+ static char buf[20];
+
+ stop();
+ sprintf(buf, "&#%u;", (unsigned int)ch);
+ return( buf );
+}
+
+/*
* char_translate_to_html - convert a single non escaped character
* into the appropriate html character.
*/
-int char_translate_to_html (font *f, char *buf, int buflen, char ch, int b, int and_single)
+int char_translate_to_html (font *f, char *buf, int buflen, unsigned char ch, int b, int and_single)
{
if (and_single) {
int t, l;
@@ -2314,6 +2334,9 @@ int char_translate_to_html (font *f, char *buf, int buflen, char ch, int b, int
name[0] = ch;
name[1] = (char)0;
translation = get_html_translation(f, name);
+ if ((translation == NULL) && (ch >= UNICODE_DESC_START)) {
+ translation = to_unicode(ch);
+ }
if (translation) {
l = strlen(translation);
t = max(0, min(l, buflen-b));
@@ -2461,6 +2484,9 @@ void html_printer::write_title (int in_head)
html.put_string(title.text);
html.put_string("</h1>\n\n");
}
+ } else if (in_head) {
+ // place empty title tags to help conform to `tidy'
+ html.put_string("<title></title>\n");
}
}
@@ -2507,6 +2533,7 @@ html_printer::~html_printer()
{
current_paragraph->done_para();
html.set_file(stdout);
+ // fputs("<!doctype html public \"-//IETF//DTD HTML 4.0//EN\">\n", stdout);
fputs("<html>\n", stdout);
fputs("<head>\n", stdout);
fputs("<meta name=\"generator\" content=\"groff -Thtml, see www.gnu.org\">\n", stdout);
diff --git a/src/preproc/html/pre-html.cc b/src/preproc/html/pre-html.cc
index efd98e4e..2f00f786 100644
--- a/src/preproc/html/pre-html.cc
+++ b/src/preproc/html/pre-html.cc
@@ -258,7 +258,7 @@ void makeFileName ()
static void write_end_image (int is_html)
{
- writeString(".html-end \\{\\\n");
+ writeString(".end \\{\\\n");
if (is_html) {
/*
* emit image name and enable output
@@ -283,21 +283,21 @@ static void write_end_image (int is_html)
static void write_start_image (IMAGE_ALIGNMENT pos, int is_html)
{
- writeString(".html-begin \\{\\\n");
+ writeString(".begin \\{\\\n");
switch (pos) {
case LEFT:
- writeString(". html-image l ");
+ writeString(". image l ");
break;
case RIGHT:
- writeString(". html-image r ");
+ writeString(". image r ");
break;
case INLINE:
- writeString(". html-image i ");
+ writeString(". image i ");
break;
case CENTERED:
default:
- writeString(". html-image c ");
+ writeString(". image c ");
}
writeString(image_template); writeString(".png\n");
if (is_html) {
diff --git a/src/roff/troff/input.cc b/src/roff/troff/input.cc
index 85bf4735..ae864fe0 100644
--- a/src/roff/troff/input.cc
+++ b/src/roff/troff/input.cc
@@ -111,7 +111,7 @@ int compatible_flag = 0;
int ascii_output_flag = 0;
int suppress_output_flag = 0;
int is_html = 0;
-int html_level = 0; // number of nested .html-begin requests
+int begin_level = 0; // number of nested .begin requests
int tcommand_flag = 0;
int safer_flag = 1; // safer by default
@@ -4477,46 +4477,46 @@ void else_request()
}
/*
- * html_begin - if this is the outermost html_begin request then execute the
+ * begin - if this is the outermost html_begin request then execute the
* rest of the line, else skip line
*/
-void html_begin()
+void begin()
{
- html_level++;
- if (html_level == 1)
+ begin_level++;
+ if (begin_level == 1)
begin_alternative();
else
skip_alternative();
}
/*
- * html_end - if this is the outermost html_end request then execute the
- * rest of the line, else skip line
+ * end - if this is the outermost html_end request then execute the
+ * rest of the line, else skip line
*/
-void html_end()
+void end()
{
- html_level--;
- if (html_level == 0)
+ begin_level--;
+ if (begin_level == 0)
begin_alternative();
else
skip_alternative();
- if (html_level < 0)
- html_level = 0;
+ if (begin_level < 0)
+ begin_level = 0;
}
/*
- * html_image - implements the directive `.html_image {l|r|c|i} filename'
- * which places the filename into a node which is later
- * written out
+ * image - implements the directive `.image {l|r|c|i} filename'
+ * which places the filename into a node which is later
+ * written out
*
- * . either as a special in the form of an image tag for -Thtml
- * . or as an image region definition for all other devices
+ * . either as a special in the form of an image tag for -Thtml
+ * . or as an image region definition for all other devices
*
*/
-void html_image()
+void image()
{
if (has_arg()) {
char position = tok.ch();
@@ -6154,7 +6154,7 @@ int main(int argc, char **argv)
init_column_requests();
#endif /* COLUMN */
init_node_requests();
- init_html_requests();
+ init_markup_requests();
number_reg_dictionary.define(".T", new constant_reg(tflag ? "1" : "0"));
init_registers();
init_reg_requests();
@@ -6268,11 +6268,11 @@ void get_output_registers(int *minx, int *miny, int *maxx, int *maxy)
*maxy = output_reg_maxy_contents;
}
-void init_html_requests()
+void init_markup_requests()
{
- init_request("html-begin", html_begin);
- init_request("html-end", html_end);
- init_request("html-image", html_image);
+ init_request("begin", begin);
+ init_request("end", end);
+ init_request("image", image);
}
void init_input_requests()
diff --git a/src/roff/troff/node.cc b/src/roff/troff/node.cc
index 5422e91f..458ed484 100644
--- a/src/roff/troff/node.cc
+++ b/src/roff/troff/node.cc
@@ -3432,16 +3432,7 @@ void suppress_node::put(troff_output_file *out, const char *s)
}
/*
- * We prefer to remember the last position, rather than have a .html-start
- * followed by html-end-center, html-end-left as it is more natural to
- * express an image by:
- *
- * .html-image-left
- *
- * .html-image-end
- *
- * similar to other troff commands, although this method is slightly more
- * messy to implement.
+ * We need to remember the start of the image and its name.
*/
static char last_position = 0;
diff --git a/tmac/www.tmac b/tmac/www.tmac
index 0297a265..fb6e146a 100644
--- a/tmac/www.tmac
+++ b/tmac/www.tmac
@@ -154,14 +154,14 @@
.\" HTML-DO-IMAGE - tells troff to issue an image marker which can be read back by pre-html
.\"
.de HTML-DO-IMAGE
-. if r ps4html .html-begin \{\
-. html-image \\$2 \\$1.png
+. if r ps4html .begin \{\
+. image \\$2 \\$1.png
. bp
. tl '''
\O0\O1
. \}
-. if '\*(.T'html' .html-begin \{
-. html-image \\$2 \\$1.png
+. if '\*(.T'html' .begin \{
+. image \\$2 \\$1.png
\O0
. \}
..
@@ -169,10 +169,10 @@
.\" HTML-IMAGE-END - terminates an image for html
.\"
.de HTML-IMAGE-END
-. if r ps4html .html-end \{\
+. if r ps4html .end \{\
\O2\O1
. \}
-. if '\*(.T'html' .html-end \{
+. if '\*(.T'html' .end \{
\O2\O1
. \}
..