livebs / syntaxhighlighter

Automatically exported from code.google.com/p/syntaxhighlighter
GNU General Public License v3.0
0 stars 0 forks source link

produced html stirct is not valid #25

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. http://validator.w3.org/check
2. fails
3.

What is the expected output? What do you see instead?
validating html strict, a failing error

What version of the product are you using? On what operating system?
1.5.1

Please provide any additional information below.

To write validating html stirct a "name" attribute is not allowed in the
<pre> tag. Therefore this script should not use that attribute to identify
the code to modify. I have solved using just the class attribute, but
perhaps you find a better solution.
I would appreciate it if it could be used in a validating document.
Otherwise it is a good tool. Thank you!

~DR0ID

Original issue reported on code.google.com by dr0iddr0id@gmail.com on 15 Aug 2007 at 7:04

GoogleCodeExporter commented 8 years ago
Yeah, probably something along these lines would be best:

<pre class="shcode php">Code!</pre>

Original comment by viper007...@gmail.com on 6 Sep 2007 at 9:50

GoogleCodeExporter commented 8 years ago
Instead of use the NAME attribute, invalid for HTML and XHTML strict, to 
identify
SyntaxHighlighter tags, plus a class attribute to define its options, I propose 
a
new, unified class attribute format to both identify and define syntax 
highlighting:

<pre class="... syntax-highlight:language:options ..."> ... </pre>

<textarea class="... syntax-highlight:language:options ..."> ... </textarea>

A working proposal was done (uncompressed JavaScript) at:
http://www.mhavila.com/syntax/js/shCode.js

And a simple test can be view and validate at:
http://www.mhavila.com/syntax_test.html

Attached is the modified version of shCore.js.

Original comment by mhav...@gmail.com on 21 Oct 2007 at 9:34

Attachments:

GoogleCodeExporter commented 8 years ago
The name attribute is perfectly valid in a textarea element, just use that 
instead!

Original comment by ccodl...@gmail.com on 14 Feb 2008 at 7:12

GoogleCodeExporter commented 8 years ago
I'd rather propose a convention like this:

<pre class="code">
    <code class="html">
        <!-- code sample goes here -->
    </code>
</pre>

This would create proper namespaces in the HTML/XHTML document straight from 
the beginning both for all 
possible cases of pre instances and code instances.

( Makes at also easier to handle Users, who have Javascript switched off)

Original comment by sundrive...@gmail.com on 25 Feb 2008 at 1:47

GoogleCodeExporter commented 8 years ago
Regarding the name attribute:

What I now did, to have a valid XHTML document is just replace the name 
attribute with a title attribute
(Which is valid)
As a workaround, so to speak.

Original comment by sundrive...@gmail.com on 25 Feb 2008 at 1:49

GoogleCodeExporter commented 8 years ago
I think that semantically, sundrivedesign's first proposal is probably the best,
especially for users without JavaScript and/or screen readers. IMO textarea is a
hack, and doesn't the title attribute get read out by screen readers, which may 
not
be what you want?

Original comment by jammyca...@gmail.com on 22 May 2008 at 2:04

GoogleCodeExporter commented 8 years ago
I think syntaxhighlighter must use the language-* value for the class attribute 
like
this :
<pre><code class="language-javascript"></code></pre>

The class="language-LANGNAME" attribute is a part of (the draft of) the HTML5
specification and is compatible with backward compatible with the currents 
versions
of HTML and XHTML.

Please make syntaxhighlighter as standard compliant as possible :)

See http://code.google.com/p/syntaxhighlighter/issues/detail?id=91 to know why 
use
<code> instead of <pre>.

Original comment by dung...@gmail.com on 23 Jul 2008 at 10:31

GoogleCodeExporter commented 8 years ago
dunglas: That's good to know.  Can you point at the HTML5 draft section about 
this?

Original comment by docw...@gmail.com on 24 Jul 2008 at 3:25

GoogleCodeExporter commented 8 years ago
Would be better to use the 'id' attribute and to change line 618 in shCore.js 
to 

if(tags[i].getAttribute('id') == name)

Original comment by kalek...@googlemail.com on 23 Nov 2008 at 1:07