Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Code tags warning

by Roy Johnson (Monsignor)
on Mar 14, 2005 at 15:33 UTC ( #439309=monkdiscuss: print w/ replies, xml ) Need Help??

It seems to me that there are an awful lot of posts that get botched for lack of code tags. Naturally, there are none in Nodes to consider at the moment, but there are always some such posts around.

I thought that a fairly simple heuristic could be added to the posting feature to look for likely code chunks, and if there are no code tags around them, give a "Woah there!" message that suggests maybe they want to wrap code tags around some of their post.

I present the heuristics I thought of in Jeff Foxworthy format. If you have better ideas or reasons these aren't a good idea, discuss.

You might need code tags if...

  • you've got a single digit in square brackets
  • [$ appears in your post
  • you have lines ending in semicolons
  • you have lines beginning with spaces or tabs

Caution: Contents may have been coded under pressure.

Comment on Code tags warning
Download Code
Re: Code tags warning
by ww (Bishop) on Mar 14, 2005 at 15:48 UTC
    And while we're at it, maybe similarly for cases in which <readmore> tags might be appropriate.

    So, in a similar spirit...

    You may need <readmore> tags if...

    • Your post is more than 20 lines long
    ... and maybe make it MANDATORY at something in the vicinity of 40 - 50 lines.
Re: Code tags warning
by Joost (Canon) on Mar 14, 2005 at 16:10 UTC

      Making it more noticable is good -- <h1> is not, as it's not a heading for a section, and would violate the WAI guidelines, as it would use structure tags for sake of presentation, violating WCG2.0 section 1.3 and more specifically WCAG2.0 section 3.2

Re: Code tags warning
by ambrus (Abbot) on Mar 14, 2005 at 17:00 UTC

    The preview page always prints a hint to use code tags around code. Do you think that people who don't read that would read the additional warning?

      That's a good point. However, if we1 can put in heuristics to the PM code to decide when code tags are required (and are not actually present), and we decide these heuristics are accurate (i.e., zero false-positives, few false-negatives), and we decide that this would be beneficial to the community at large, then we could make it mandatory: no "submit" button until all warnings are dealt with.

      I would propose that there also be a way around these heuristics. That is, I like the computer being smart. But not too smart. For example, perhaps if you submit a preview without having changed anything, then you get the submit button on the next preview. Or, perhaps, there is a checkbox saying, "ignore warnings" which, if unset (default) would make the submit button act as the preview button.

      And then, any time warnings are bypassed, perhaps we could automatically consider the node for those warnings? :-)

      1 I'm using a very, very loose definition of "we" here. As in, "we" == "gods".

        I'm very much against making it mandatory. Both with code and readmore tags.

        I can accept a warning, as long as I can turn it off (such as in User Settings), but I don't think there's much point in it.

        If you can get zero false-positives by using automation, then instead of not having no submit button, add the code tags automatically.

        I would propose that there also be a way around these heuristics. That is, I like the computer being smart. But not too smart.

        Ah, so that's in the case that the "zero false positives" is actually for values greater than 0? ;-)

      Frankly, yes. People quickly learn to ignore things that are always there. But when something different pops up, they tend to take notice. It's a little like the difference between what perl does under use warnings, versus how helpful it would be if perl simply told you not to use uninitialized variables every time it ran.

      Caution: Contents may have been coded under pressure.

        People quickly learn to ignore things that are always there.

        One way to deal with this would be to select the wording of the message at random (a la 'fortune'). So, you might forget the code tags on four separate occasions and get a different one of the following each time:

            Code tags in your posts, 
            These are a great goodness, true
            Alas, all unfound
        
                (or the alternate version of the above:)
          
                Code tags in your posts, 
                These are a great goodness, true
                Unlike this haiku
        
        
            Code tags, code tags, wherefore art thou code tags?
        
        
            You know...that looks a lot like a code snippet, 
            but nary a code tag in sight.  You sure you want 
            to post?
        
        
            I'm sorry <username>, I'm afraid I can't do that.
            At least, not until you add some code tags.
        
Re: Code tags warning
by ysth (Canon) on Mar 15, 2005 at 06:43 UTC
      [id://76332]: 2

      Caution: Contents may have been coded under pressure.
Re: Code tags warning
by halley (Prior) on Mar 15, 2005 at 15:09 UTC
    I'd say that with a good heuristic, make codetag checks MANDATORY for Anonymous posters (as they won't be able to edit after they submit), and an OPTIONAL FEATURE for those who have logged in.

    Of course, I've already mentioned that I think this site should use a format that's closer to POD and Wiki writeup, rather than this mis-mash of HTML and Everything2. Stuff that's indented should be code/pre, and maybe a little heuristic to absorb immediately neighboring lines which start with curly braces or known sigils or keywords.

    --
    [ e d @ h a l l e y . c c ]

Re: Code tags warning
by ambrus (Abbot) on Mar 15, 2005 at 17:18 UTC

    Let me add one more comment. I have mentioned that on the preview page, there is a warning about code tags. I wonder, wouldn't it be more efficent if we had the same warning on the new writeup page that shows up first? I'm quite sure it would. Is there some reason it's not like that? Would it be difficult to implement this? What do you think?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://439309]
Approved by Fletch
Front-paged by hsmyers
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2014-09-02 20:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (29 votes), past polls