[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Groff] grohtml patches
From: |
Gaius Mulley |
Subject: |
[Groff] grohtml patches |
Date: |
Sun, 04 Mar 2001 18:04:33 +0000 |
Hi Werner,
here are some patches for grohtml which fix the bug you reported
earlier.
> Then I found out that `\-' isn't translated at all. Any idea why?
> After doing
> \- 24 0 0x002D -
also I've renamed the .html-begin .html-end .html-image as requested.
enjoy,
Gaius
--- groff-cvs/ChangeLog Sat Feb 17 22:25:28 2001
+++ groff-html/ChangeLog Sun Mar 4 17:18:50 2001
@@ -1,3 +1,10 @@
+2001-03-04 Gaius Mulley <address@hidden>
+
+ * 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
+
2001-02-16 Werner LEMBERG <address@hidden>
* src/roff/troff/node.cc (space_node::get_hyphenation_type): New
--- groff-cvs/src/devices/grohtml/post-html.cc Wed Jan 17 14:17:22 2001
+++ groff-html/src/devices/grohtml/post-html.cc Tue Feb 27 10:48:46 2001
@@ -52,6 +52,9 @@
#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 @@
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 @@
* 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 @@
}
/*
+ * 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 @@
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 @@
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 @@
{
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);
--- groff-cvs/src/preproc/html/pre-html.cc Tue Jan 23 22:00:12 2001
+++ groff-html/src/preproc/html/pre-html.cc Tue Feb 27 11:16:18 2001
@@ -258,7 +258,7 @@
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_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) {
--- groff-cvs/src/roff/troff/input.cc Fri Feb 16 22:33:36 2001
+++ groff-html/src/roff/troff/input.cc Tue Feb 27 11:09:54 2001
@@ -111,7 +111,7 @@
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 @@
}
/*
- * 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();
@@ -6270,9 +6270,9 @@
void init_html_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()
--- groff-cvs/src/roff/troff/node.cc Sat Feb 17 22:25:30 2001
+++ groff-html/src/roff/troff/node.cc Fri Mar 2 16:08:22 2001
@@ -3432,16 +3432,7 @@
}
/*
- * 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;
--- groff-cvs/tmac/www.tmac Wed Jan 17 14:17:26 2001
+++ groff-html/tmac/www.tmac Tue Feb 27 11:14:19 2001
@@ -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
. \}
..
- [Groff] grohtml patches,
Gaius Mulley <=