WordPress.org

Ready to get started?Download WordPress

Forums

SyntaxHighlighter Evolved
HTML validation fails (9 posts)

  1. AlphaK
    Member
    Posted 3 years ago #

    I am using plugin version 3.0.1.
    HTML validation fails because of the tag <meta id="syntaxhighlighteranchor" [...] />

    Validator says that there is no attribute "id".

    The plugin itself works, but having this part of code modified would allow to validate the code.

    Best regards

  2. AlphaK
    Member
    Posted 3 years ago #

    Well, some more info.
    Validation is correct with doctypes XHTML 1.0 Transitional but not with doctypes XHTML 1.1. So basically validation will have a different result depending on the theme used.

    I don't know if WordPress recommends to use a particular doctype in themes. The validation problem occurs with the iNove one.

    Maybe it could be possible to have that tag validated against both doctypes...

  3. Alex Mills (Viper007Bond)
    Moderator
    Plugin Author

    Posted 3 years ago #

    Grr. I guess I'll need to use some other type of anchor.

    What do you think is the best element to use inside of <head> that accepts an ID?

  4. AlphaK
    Member
    Posted 3 years ago #

    I searched the whole XHTML 1.1 DTD and unfortunately, from my understanding there is no child tag of the <head> element that accepts the attribute "id" :(

  5. Alex Mills (Viper007Bond)
    Moderator
    Plugin Author

    Posted 3 years ago #

    What about class then?

    Basically I need an anchor element to use that is after style.css that my Javascript can look for an inject stylesheets after.

  6. AlphaK
    Member
    Posted 3 years ago #

    OK. If my understanding is correct, you use it in the following code :
    document.getElementsByTagName("head")[0].insertBefore( corecss, document.getElementById("syntaxhighlighteranchor") );

    Then why not adding your stylesheets at the end of the head element ? Then there is no need for an id nor a class. This code might do the trick :
    document.getElementsByTagName("head")[0].appendChild(corecss);

  7. Alex Mills (Viper007Bond)
    Moderator
    Plugin Author

    Posted 3 years ago #

    That's the exact code I had been using. The problem with that is that it then becomes impossible for people to override the plugin's CSS unless they create a custom plugin theme or edit the plugin's files.

    The advantage of the current set up is someone can hook into wp_head at priority 20 or whatever and then output a stylesheet with some !important rules.

  8. AlphaK
    Member
    Posted 3 years ago #

    Huge history as I can see.

    Again in XHTML 1.1 none of the mandatory child element of the <head> tag support a class attribute.

    Then I may suggest 2 workarounds :

    First one : to cycle manually through meta tags until the one which attribute name equals syntaxhighlighter-version is found. There we can insert corecss and themecss just before.

    Second one : to do the same but using WordPress's internal jQuery to catch the correct tag using a direct selector, that would look like : $('meta[@name="syntaxhighlighter-version"]')

    Both solutions may imply a loss of performance during the script load, but negligible I assume.

  9. Alex Mills (Viper007Bond)
    Moderator
    Plugin Author

    Posted 3 years ago #

    I don't want to load up jQuery just to do that, as much as I love jQuery. :)

    I like the first solution. My crappy Javascripts skills and I will give that a go. Thanks.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic