News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Tab in php code block cause more w3c issue?

Started by L'AltroWeb, November 01, 2010, 12:08:21 AM

Previous topic - Next topic

L'AltroWeb

Hi! This post contain php code and it is valid w3c: *.darkwolf.it/php-html-css/calcolatrice-in-php/

This other also contain php code but has many w3c error: *.darkwolf.it/cms-forum-e-portali/smf-1-1-11-come-aggiungere-pulsante-home-e-rimuovere-stampa-ai-visitatori/
document type does not allow element "pre" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag

...#0000BB"><pre style="display: inline;"> </pre></span><span style="color: #DD00...

The problem is cause by "tab" in code (pre inside span).

Is there any way to fix?

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

L'AltroWeb

If i remove tab all results w3c valid but when i copy a long php code block is more complicated to remove manually all tab and add space to maintain code indent :/

MrPhil

<pre> is a "block level" element, isn't it? It would not be allowed inside an "inline" element such as <span>. If you want a fixed pitch font inside the span, you could specify that in CSS (font selection). Or, if all you're using the span for is color, put that setting in the pre (style attribute) or put the span inside the pre.

L'AltroWeb

Quote from: MrPhil on November 01, 2010, 02:18:01 PM
<pre> is a "block level" element, isn't it? It would not be allowed inside an "inline" element such as <span>. If you want a fixed pitch font inside the span, you could specify that in CSS (font selection). Or, if all you're using the span for is color, put that setting in the pre (style attribute) or put the span inside the pre.
Yes, i know, for this reason, to resolve this bug, i need a code fix (is with smf 1.1.11 - maybe it can be put in bugtracker?)

Kindred

what file is that code in?

as for maintaining the spacing/indents... most good text editors have an option "replace tabs with spaces"
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Oya

try looking in parse_bbc for where it replaces tabs ;)

L'AltroWeb

#7
Quote from: Kindred on November 01, 2010, 02:59:46 PM
what file is that code in?
I think is related to Subs.php (maybe i can test to replace tab with some &*nbsp;) :)
Quote from: Kindred on November 01, 2010, 02:59:46 PM
as for maintaining the spacing/indents... most good text editors have an option "replace tabs with spaces"
Yes but i can't convert for all old code and for every user than insert phpcode with tab.
Quote from: Oya on November 01, 2010, 03:01:17 PM
try looking in parse_bbc for where it replaces tabs ;)
I've opened now Subs.php
Maybe the problem is caused by this line: // Yes, I know this is kludging it, but this is the best way to preserve tabs from PHP :P.
$buffer = preg_replace('~SMF_TAB(</(font|span)><(font color|span style)="[^"]*?">)?\(\);~', "<pre style=\"display: inline;\">\t</pre>", $buffer);
Now i try to change with 4 &*nbsp; and i try it ;)




Edit:
Ok, i don't know if is the best fix but seems to work fine:
	
// Yes, I know this is kludging it, but this is the best way to preserve tabs from PHP :P.
	
//$buffer = preg_replace('~SMF_TAB(</(font|span)><(font color|span style)="[^"]*?">)?\(\);~', "<pre style=\"display: inline;\">\t</pre>", $buffer);
	
$buffer preg_replace('~SMF_TAB(</(font|span)><(font color|span style)="[^"]*?">)?\(\);~'"&nbsp;&nbsp;&nbsp;&nbsp;"$buffer);


Now is w3c valid: http://validator.w3.org/check?uri=http%3A%2F%2Fwww.darkwolf.it%2Fcms-forum-e-portali%2Fsmf-1-1-11-come-aggiungere-pulsante-home-e-rimuovere-stampa-ai-visitatori%2F
And code seems to look fine ;)
http://www.darkwolf.it/cms-forum-e-portali/smf-1-1-11-come-aggiungere-pulsante-home-e-rimuovere-stampa-ai-visitatori/msg4436/#msg4436

Anyway, now i can't copy code and put to search in notepad++ (tab results different from space).




New Edit:
Same bug is present in this forum: http://validator.w3.org/check?uri=http%3A%2F%2Fwww.simplemachines.org%2Fcommunity%2Findex.php%3Ftopic%3D407169.msg2835955
Caused by precedent php_code block.

Aleksi "Lex" Kilpinen

Hi Dark-Wolf, is there something you need assistance with still, related to this? :)
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

L'AltroWeb

@LexArma: i've fixed atm with precedent code but this bug is already present in this page (smf 2 RC4).
I think is best to report before to release smf 2 final. Anyway, for me is solved now ;)

Aleksi "Lex" Kilpinen

It can be on this site only, this site is not completely same as the default installation - does someone have an idea if that is around in a default installation? If it is, then perhaps this should be in bug reports...
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

L'AltroWeb

I've try also in my local machine (with clean installation) and is present ;)

MrPhil

Quote from: Dark-Wolf on November 16, 2010, 07:45:13 AM
i've fixed atm with precedent code
What is "precedent code"? Are you referring to <pre>? That's "preformatted" code.

Quotebut this bug is already present in this page (smf 2 RC4).
Yes, it's certainly present on this page (I don't have SMF 2 installed to check a vanilla version). W3C complains about <pre> (a block level tag) being inside a <span> (inline level tag). From how it's being used, perhaps it should be <tt> (TeleType = fixed pitch code) instead of <pre>, or another <span> with styling?

L'AltroWeb

MrPhil: i've fixed with this patch in subs.php
	
// Yes, I know this is kludging it, but this is the best way to preserve tabs from PHP :P.
	
//$buffer = preg_replace('~SMF_TAB(</(font|span)><(font color|span style)="[^"]*?">)?\(\);~', "<pre style=\"display: inline;\">\t</pre>", $buffer);
	
$buffer preg_replace('~SMF_TAB(</(font|span)><(font color|span style)="[^"]*?">)?\(\);~'"&nbsp;&nbsp;&nbsp;&nbsp;"$buffer);
(i've changed \t with 4 &*nbsp;).
Obviously this cause a problem (not found) when you copy code block and search in text editor (but also vbulletin editor change tab with spaces).

Advertisement: