# [PATCH][ZE2] zend_highlight.c <font> change

- Thread: https://externals.io/message/5047
- Original archive: https://news-web.php.net/php.internals/5047
- Started by Lisa Seelye on 2003-10-28T19:39:14+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #5047 — Lisa Seelye — 2003-10-28T19:39:14+00:00

URL: https://externals.io/message/5047#5047

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.
-- 
Regards,
-Lisa
<Vix ulla tam iniqua pax, quin bello vel aequissimo sit potior

---

## #5058 — Greg Beaver — 2003-10-29T05:44:43+00:00

URL: https://externals.io/message/5047#5058 · In reply to: #5047

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:
>   */

---

## #5070 — Curt Zirzow — 2003-10-29T16:14:05+00:00

URL: https://externals.io/message/5047#5070 · In reply to: #5047

* Thus wrote Lisa Seelye (lisa@gentoo.org):
> 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).

Slight problem with:
  zend_printf("<span style=\"color: %s;\">\n", last_color);

Although it is a much more elegant solution. Some people consider
inline style attributes bad.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

---

## #5093 — Greg Beaver — 2003-10-30T03:31:41+00:00

URL: https://externals.io/message/5047#5093 · In reply to: #5047

Lisa,

With my testing, <br />\n causes a double line break in Netscape Mail 
and Internet Explorer 6 on windows.  However, using \n inside <pre> 
instead of <br /> works in both browsers.  For my test, I took the page 
at http://pear.php.net/manual/en/core.pear.pear.seterrorhandling.php and

replaced the <br /> with \n.  I've uploaded a copy to:

http://www.chiaraquartet.net/test_br.html

I would appreciate it if people with older versions of Netscape/IE, any 
version of Mozilla, Opera, Konqueror, etc. would take a look and speak 
up if the example doesn't work correctly.

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:
>   */

---

## #5151 — Lisa Seelye — 2003-10-31T15:42:02+00:00

URL: https://externals.io/message/5047#5151 · In reply to: #5093

> Lisa,
> 
> With my testing, <br />\n causes a double line break in Netscape Mail 
> and Internet Explorer 6 on windows.  However, using \n inside <pre> 
> instead of <br /> works in both browsers.  For my test, I took the page 
> at http://pear.php.net/manual/en/core.pear.pear.seterrorhandling.php and
> 
> replaced the <br /> with \n.  I've uploaded a copy to:
> 
> http://www.chiaraquartet.net/test_br.html
> 
> I would appreciate it if people with older versions of Netscape/IE, any 
> version of Mozilla, Opera, Konqueror, etc. would take a look and speak 
> up if the example doesn't work correctly.

The purpose of the \n (and \t) was to break up the outputted html
source.  During my browser testing, Opera 7.21, Netscape 4.76, Mozilla
1.5, and IE 6 all behaved normally:  Within the pre-formatted <code>
blocks, all of the test browsers did not display any problems.  That is
to say, the existing <br /> put page breaks, and the new \n introduced a
carriage return in the html source.

I would dare say the behavior of Netscape Mail (double line break) is
exclusive to it.  I could not reproduce any double line break in IE 6
(with the requisite service packs and security patches).

With regards to your test page, it looks fine (rendered and source) with
Opera 7.21.

-- 
Regards,
-Lisa
<Vix ulla tam iniqua pax, quin bello vel aequissimo sit potior
