Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Suggest adding code tags if perlish text found in post.

by EvdB (Deacon)
on Jun 12, 2003 at 10:52 UTC ( [id://265329]=monkdiscuss: print w/replies, xml ) Need Help??

Quite often posts show up without the code tags, and I think this is probably due to the author not knowing how to use them or that they are available.

The following (very basic) code would check a post for perlisms (charcters common in perl but not in English). If it is above a certain level a warning is printed. Would it be worth including this in the preview stage, and printing a small warning and usage description such as:

Detected code without <code> tags. Please consider adding code tags if there is code in your post - it will look much nicer. See this node for more on posting.

This code does the trick but probably needs tweaking.

use strict; # The variable $post contains the text to check. # $, -> and => are searched for. my $perlisms = 0; my $perlisms_limit = 3; for ( split /\n/, $post ) { $perlisms += s/\$|->|\=>//g; if ( m/<code>/ ) { $perlisms = 0; last; } } print "Warning text goes here." if $perlisms >= $perlisms_limit;

I am not suggesting that the user should be forced to add code tags, just that they should be reminded.

--tidiness is the memory loss of environmental mnemonics

Replies are listed 'Best First'.
(jeffa) Re: Suggest adding code tags if perlish text found in post.
by jeffa (Bishop) on Jun 12, 2003 at 11:25 UTC
    We have been using this disclaimer (located just below the preview/submit buttons) for some time now:

    Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible editor intervention).

    So there, they have been reminded. Of course, it is up to them to know the reminder is there, and that they should not only read it, but abide by it.

    Also, it is this 'editor intervention' that does what your code does. Sure it's not code, but it is robust and also handles title changes, formatting, and typos. Thanks for the code, but i am quite content being a janitor by putting the code away for awhile and picking up my manual mop. Sometimes you just can't escape data entry. :/

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
      And the janitors do a superb job - no complaints there.

      The disclaimer is at the bottom and after a few posts most people will have found it and read it. Maybe the above 'feature' should only apply to the first 5 posts or so.

      I worry about you janitors, I lose sleep, I fear that RSI will creep up on you. Surely if it saves you a few edits a day?

      --tidiness is the memory loss of environmental mnemonics

        As for saving a few edits ... well, there are two kinds of posts that need to be editted. Easy ones and nightmare ones. Simply slapping code tags around a post is a piece of cake, but those nightmare edits require a whole lot more. Many times i will copy the original post to a gvim window so i can apply many search-n-replace edits to it. You might be surprised at the number of newbie posts that use a plethora of <br> tags. I think most of these have been composed in some sort of WYSIWYG editor, because entities such as < and > will be escaped.

        But right now, the biggest chore i have undertaken as an editor has been title changes. Sure it's easy to change one title, but you have to propagate that down and change every title. I have been meaning to write a tool to handle this, but i fear the testing part. ;)

        If you really want to help us editors out ... join us! That way you can see what it is all about and write some tools after a couple of days of editting. Even though i hate data entry chores, i haven't had the need to write code instead hit me, it's really not a big deal. :)

        jeffa

        L-LL-L--L-LL-L--L-LL-L--
        -R--R-RR-R--R-RR-R--R-RR
        B--B--B--B--B--B--B--B--
        H---H---H---H---H---H---
        (the triplet paradiddle with high-hat)
        
      • That disclaimer only appears below the form for posting new nodes, not wen posting comments.
      • That disclaimer does not appear on the "Preview" page itself ... just the " If something looked unlike you expected it to you might need to check out Writeup Formatting Tips" disclaimer.

      Personally, I think having the full version of the disclaimer show up on the "Reply" page, and on the "Preview" age (for both top level nodes, and replies) would reduce a lot of this confusion.

Re: Suggest adding code tags if perlish text found in post. (POD, again)
by tye (Sage) on Jun 12, 2003 at 14:19 UTC

    See Re: Convert Text to HTML Checkbox (POD) from 2 weeks ago for my feelings on this.

    So I'd prefer to make all non-white-space characters that aren't valid and approved HTML show for new users (we are already nearly there) and detect when the white space shouldn't be ignored: blank lines and (paragraphs containing) leading spaces on lines.

    I think that would be quite DWIMy.

                    - tye
Re: Suggest adding code tags if perlish text found in post.
by arthas (Hermit) on Jun 12, 2003 at 12:56 UTC

    Even though your idea is nice, I don't think PM should follow this way... posting suggestions contain information about that, so I think people should learn to post as they should, and not forget about it because the system reminds them what they're doing wrong. ;)

    Michele.

Re: Suggest adding code tags if perlish text found in post.
by CountZero (Bishop) on Jun 12, 2003 at 21:55 UTC

    Wouldn't such checking put additional strain on the server and slow everything down?

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      Yes, but if the strain imposed at the posting reduces later editing then on the whole it would be worth it. In terms of saving te editors time and educating users I wolud prefer the server to do more work and the humans to do less.

      --tidiness is the memory loss of environmental mnemonics

      Please don't be one of the people who invoke this argument for every new suggestion - often (or so is my impression) without even vaguely considering how it would affect the actual infrastructure.

      Makeshifts last the longest.

        I am certainly not against improvements, but now that PM has become much more responsive, I would hate to see it slow down to a crawl again because of "improvements". Of course the Gods or pmdev-people will take good care of that aspect, but still I found it useful to express my concerns.

        Sorry if that came out wrong.

        CountZero

        "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: monkdiscuss [id://265329]
Approved by gmax
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-24 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found