I sometimes want to upload something I developed in pure HTML and have to spend as much as 30 minutes Perlmonking my HTML... it would be nice if there were a rawhtmltag that I could wrap my entire post in.

Replies are listed 'Best First'.
Re: rawhtml tag
by japhy (Canon) on Oct 25, 2001 at 17:29 UTC
    HTML (and PerlMonks.org) supports the <xmp> tag, which displays all text and whitespace as is, up to the closing </xmp> tag. (That means you can't write a closing </xmp> tag in your text without it being caught.)

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Re: rawhtml tag
by footpad (Abbot) on Oct 25, 2001 at 19:37 UTC

    While japhy's idea is a good one, I note that the <xmp> tag is not on the Perl Monks approved HTML tag list. While I'm sure it'll work for now, I'm not sure what (if anything) changes might be planned for that. It's conceiveable, though, that future changes to the handling of the approved tags would break any nodes using that tag.

    Personally, I've not had much trouble formatting my nodes with the approved tags. I'll admit that I try to keep things simple, primarily using few tags. Since many sources tell us to separate content from presentation, this seems a wise course. You might, perhaps, consider creating templates in your editor for nodes you want to post or to define macros to help streamline formatting chores.

    I'd be leery of raw html. After all, there are many "tricks" out there and supporting a limited subset of "valid" HTML strikes me a good way of keeping most of those from being utilized against us. It's not that I distrust any of the regulars, however, I'd be nervous about providing the trollish more opportunities to create havoc.

    My two cents worth...

    --f

    P.S. I note that tachyon's code needs two tweaks. Specifically:

    • s/&/&amp/g; should be s/&/&amp;/g;
    • # s/\n/<br>\n/g; should be # s/\n/<br \/>\n/g;
Re: rawhtml tag
by tachyon (Chancellor) on Oct 25, 2001 at 19:22 UTC

    C'mon this is perl. Text munging is us.

    sub escapeHTML { local $_ = shift; # make the required escapes s/&/&amp/g; s/"/&quot;/g; s/</&lt;/g; s/>/&gt;/g; # change tabs to 4 spaces s/\t/ /g; # make the whitespace escapes - not required within <pre> tags s/( {2,})/"&nbsp;" x length $1/eg; # make the brower bugfix escapes; s/\x8b/&#139;/g; s/\x9b/&#155;/g; # make the PERL MONKS escapes (if desired) s/\[/&#091;/g; s/\]/&#093;/g; # change newlines to <br> if desired - not required with <pre> # s/\n/<br>\n/g; return $_; }

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print