Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I've made several minor improvements to the HTML nesting enforcement code based on the testing done so far. Thanks go to the few who I saw "complain," especially ysth. (:

First, note that P is no longer a block tag as far as PerlMonks html nesting is concerned (because people often don't close a P tag and that shouldn't prevent earlier tags from being closed).

The other improvements mostly have to do with how corrections are displayed. Below is my attempt at documenting the htmlerror reporting levels. With luck, the SiteDocClan will improve these into a PM doc node (along with the previous announcement).

So there are two new settings in User Settings. And pretty soon the htmlnest option will go away (it will become the default behavior that can only be disabled by adding ;htmlnest=0 to a URL).

I also took the opportunity to move all of the Nodelet Settings out of the over-full User Settings and clean it up slightly.

HTML error reporting levels

Reporting levels summary

  • Level 0 shows invalid/unapproved HTML tags as plain text.
  • Level 1 also shows non-trivial closing HTML tags that had to be inserted (as grey text).
  • Level 2 also shows invalid/unapproved attributes of approved HTML tags (enclosed in the approved tag; all as grey text).
  • Level 3 also shows non-</p> closing HTML tags that were ignored (as grey text with a line drawn through it).
  • Level 4 also shows trivial closing HTML tags that were ignored or inserted (as grey text; ignored tags have a line drawn through them). Trivial tags are </p> and non-nesting tags inserted other than at the endof the HTML being filtered.

Reporting levels details

No matter what htmlerror reporting is set to, any unrecognized, invalid, or unapproved tags simply have their opening < changed to &lt; so that the tag becomes visible as text (see the More HTML escaping announcement).

When you have htmlerror reporting set to 4 (the maximum), nearly all other corrections made to the HTML will also be made visible, but in a grey font:

  • Any approved closing tags that get ignored in order to enforce proper nesting of tags will be made visible inside of <font color="#808080" class="htmlignored"> tags.

    The default PerlMonks CSS includes font.htmlignored { text-decoration: line-through; } which means the grey text will have a line drawn through it as if <strike> tags had been used (unless your browser does not support CSS). The strike-out allows you to distinguish them from inserted closing tags (and you can use CSS to customize their appearance).

  • Any closing tags that have to be inserted in order to enforce proper nesting of tags will also be displayed, but inside of <font color="#808080" class="htmlinserted"> tags.
  • Any unrecognized, invalid, or unapproved attributes in an approved tag will be displayed inside angle brackets with the tag name. All of this will be inside of <font color="#808080" class="htmlattrib"> tags.

    For example, if IMG is an approved tag with approved attributes of ALT, HEIGHT, and WIDTH, then HTML of <Img ALT=purdy align="top" oops> will be changed to <img alt='purdy' /><font color="#808080" class="htmlattrib">&lt;img align="top" oops></font> so you'll see "<img align="top" oops>" displayed after the image. These are the only non-closing tags that will be displayed in grey.

This level (4) of htmlerror reporting is rather obnoxious and is reserved for when you are composing your own nodes or temporarily request it by adding ;htmlerror=4 to a PerlMonks URL.

If you lower the htmlerror reporting level to 3, then inserted and ignored </p> tags are not displayed. Neither are closing tags that were inserted to close a non-nesting tag other than at the end of the HTML being filtered.

For example, if you have an HTML table that is missing all of its </tr>, </th>, and </td> tags, then these will be inserted but not be displayed (as long as the </table> is not missing).

Level 3 omits showing these most common lapses (that are harmless unless you consider strict compliance to newer HTML standards as a goal in itself) but shows nearly all other mistakes.

Level 2 omits showing ignored closing tags. So it shows non-trivial inserted closing tags (descibed in the next paragraph) and ignored attributes.

Level 1 omits showing ignored attributes. This means that it only shows when tags had to be inserted to close an unclosed or misnested tag (but never shows non-nesting tags unless they were inserted at the end of the filtered HTML, and never shows </p>).

Level 0 (the default) just fixes nesting errors but doesn't display any of them.

User settings

In user settings, you can select between htmlerror reporting levels of 0, 1, 2, or 3 to be used when you view nodes at PerlMonks. You can temporarily select any reporting level (including 4) by appending ;htmlerror=4 (for example) to any PerlMonks URL.1

Note that using an error reporting level of 3 will show you harmless "errors" so you shouldn't select this unless you can deal with seeing a lot of "mistakes" without becoming obnoxious in pointing them out to others.

When you start composing a new node, for thefirst preview you can select between htmlerror reporting levels 3 and 4 (the default choice is also controlled in user settings and defaults to 3). For previews after the first, you can pick any reporting level via a form element on the preview page.

[ The patches to Preview are a bit complicated and haven't been finished. At the time of this writing, the first preview uses your 'preview' level of error reporting and there is no form element for adjusting the level while previewing. ]

1 You can't select 4 as your default error reporting level (except for when previewing your own nodes) because it reports harmless "errors" that we expect to be made often by many members and we don't want to hear complaints about such.

- tye        


In reply to Site HTML filtering, Phase II by tye

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (15)
    As of 2014-12-22 20:46 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (130 votes), past polls