It's too dang hard to monkify my code before I post, so I built a system that I'd like to see here so every one can benifit from the time savings.

I built a small client side, javascript engine that will work on 3.0 browsers and up. It finds the special characters and converts them to the HTML Elements they deserve to be.

I know what you're thinking, 'I don't want my whole post to be Monkified, just the code and certain smiley faces.".

Taken care of my friends, just put the tags <monkify>and</monkify> around any text that you want 'interpreted'. Pretty neat huh?

I went with JavaScript becuase I figured the less trips to the server the better, especialy for just formating the message. And it's ease to add a new button to the posting sections. Here's a demo:


<FORM> <TEXTAREA name='node_doctext' cols=50 rows=15> I like to smile... <tt><monkify>;-></monkify> <br> Here's some code <pre><monkify> my $value = [ qw/hey there/ ]; print $value->[1]; </monkify></pre> </TEXTAREA> <P> <SCRIPT LANGUAGE="JavaScript"> <!-- // Activate cloak function monkify(node_doctext) { var monkified = ''; var can_monkify = false; for ( i = 0; i < node_doctext.value.length; i++ ) { if ( node_doctext.value.substring( i, i+9 ) == '<monkify +>' ) { can_monkify = true; i += 9; } else if ( node_doctext.value.substring( i, i+10 ) == ' +</monkify>' ) { can_monkify = false; i += 10; } if ( can_monkify ) { if ( node_doctext.value.charAt( i ) == '[' ) { monkified += '&#091;'; } else if ( node_doctext.value.charAt( i ) == ']' ) { monkified += '&#093;'; } else if ( node_doctext.value.charAt( i ) == '<' ) { monkified += '&lt;'; } else if ( node_doctext.value.charAt( i ) == '>' ) { monkified += '&gt;'; } else { monkified += node_doctext.value.charAt( i ); } } else { monkified += node_doctext.value.charAt( i ); } } node_doctext.value = monkified; } // monkify() // Deactivate cloak --> </SCRIPT> <INPUT Type=Button VALUE="Monkify" OnClick="monkify(this.form.no +de_doctext);return true;"> </FORM>

And if vroom doesn't add it, you can take it and benifit if you like.
--
Casey

In reply to Monkifying posts is too rough (solution, not rant :) by cwest

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.