Re: [PATCH][ZE2] zend_highlight.c <font> change

From: Date: Wed, 29 Oct 2003 05:44:43 +0000
Subject: Re: [PATCH][ZE2] zend_highlight.c <font> change
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-5058@lists.php.net to get a copy of this message
Hi, At the very least, the portion that adds in \n to <br \> is necessary to fix a bug in Internet Explorer experienced by PEAR documentation users. The source code examples in the manual at pear.php.net are highlighted with highlight_string(), and the lack of \n causes the rendered page examples (not HTML source - viewable graphical text) to cut-and-paste as a single line, something very annoying to deal with. Regards, Greg Lisa Seelye wrote:
Attached is a patch to change the behavior of source highlighting functions to use <span style="color"> instead of <font color="color">. This patch also introduces \n and \t when the parser encounters one (this change is mainly for readability). The reasoning is: the <font> tag is depreciated[1], and \n and \t should be preserved, and not just translated into <br /> and &nbsp;'s (respectively). [1]: http://www.w3.org/TR/html4/present/graphics.html#edef-FONT Please CC me on replies. ------------------------------------------------------------------------ --- cvs/ZendEngine2/zend_highlight.c 2003-08-11 01:24:41.000000000 -0400 +++ cvs-diff/ZendEngine2/zend_highlight.c 2003-10-28 14:05:59.000000000 -0500 @@ -30,7 +30,7 @@ { switch (c) { case '\n': - ZEND_PUTS("<br />"); + ZEND_PUTS("<br />\n"); break; case '<': ZEND_PUTS("&lt;"); @@ -45,7 +45,7 @@ ZEND_PUTS("&nbsp;"); break; case '\t': - ZEND_PUTS("&nbsp;&nbsp;&nbsp;&nbsp;"); + ZEND_PUTS("&nbsp;&nbsp;&nbsp;&nbsp;\t"); break; default: ZEND_PUTC(c); @@ -104,8 +104,8 @@ char *next_color; int in_string=0; - zend_printf("<code>"); - zend_printf("<font color=\"%s\">\n", last_color); + zend_printf("<code>\n"); + zend_printf("<span style=\"color: %s\";>\n", last_color); /* highlight stuff coming back from zendlex() */ token.type = 0; while ((token_type=lex_scan(&token TSRMLS_CC))) { @@ -151,11 +151,11 @@ if (last_color != next_color) { if (last_color != syntax_highlighter_ini->highlight_html) { - zend_printf("</font>"); + zend_printf("</span>"); } last_color = next_color; if (last_color != syntax_highlighter_ini->highlight_html) { - zend_printf("<font color=\"%s\">", last_color); + zend_printf("<span style=\"color: %s\">", last_color); } } switch (token_type) { @@ -192,10 +192,10 @@ token.type = 0; } if (last_color != syntax_highlighter_ini->highlight_html) { - zend_printf("</font>\n"); + zend_printf("</span>\n"); } - zend_printf("</font>\n"); - zend_printf("</code>"); + zend_printf("</span>\n"); + zend_printf("</code>\n"); } @@ -264,4 +264,3 @@ * indent-tabs-mode: t * End: */ -


« previous php.internals (#5058) next »