Friday (03/24/06)
Allow me to introduce you to my new little app, Postable 8:31 pm
I absolutely hate having to switch all the “< " and ">” signs in my code to “<” and “>”, respectively. I also hate having to write “&” anytime I want to include an ampersand. This makes including code snippets on my blog and whatnot extremely annoying, and today I finally got fed up.
So, I threw together Postable, a little app that will do all that for you. Just paste your code in there, hit the button…and walla. Post-friendly code.
So try it out, let me know what you think, bookmark it, send it to all your friends, send me money… You get the picture. (Just kidding about that last one, by the way…Well, sort of.) 
I eat food. I listen to music. I sleep. Sometimes. I drink lots of coffee. I make pretty pictures. I talk to people. I believe in things. I write stuff. I take photographs. I have a laughing addiction. I am human. 
Thank god somebody finally made this, I had even considered making my own for a while, as this is a problem that thoroughly annows me, but you beat me to it. anyway, thanks for a fine tool. btw, nice web 2.0 layout ;-P
I couldn’t believe that nobody had done it before, or at least that I hadn’t seen it. I did some googling, but couldn’t find anything.
And yeah, I’ll admit, I did sort of do the whole “web 2.0 design,” though I wasn’t really going to say that…
Very handy! Instant bookmark.
I used to open up a WYSIWYG editor, pasting the code, then copying the HTML, which includes the HTML entities already. But this definitely beats that. Very nice job.
Bug #1
Well what kind of app would it be if it didn’t have it’s share of bugs?
I’ll have to look into this…
OK, an update on that…
It will only accept a little over 5000 characters at once, but seriously, who the heck blogs over 5000 characters of code? If you’ve got that much, give them a zip file or something…
Um, why isn’t this AJAX-powered?
Good stuff - thanks!
By the by, does this script just run the form submission through PHP’s htmlentities() function and return it, or are you also parsing out something else it doesn’t handle well?
Nathan,
It runs it through htmlentities() then runs it through a str_replace() to again change ampersands to &, that way all the entities will show in the textbox rather than just execute.
Good job, man. I’ll bookmark it.
Just got around to using this app. Very Nice! I’ve bookmarked it and expect it to be getting a lot of use in the very near future. Great work!
If you ajax the form to server via POST instead of GET, I believe you will not encounter this error.
My 2 ¢
Aplicación para “formatear” el código para incluirlo en una página web…
Elliot Swan ha aprovechado bien su tiempo, y nos lo puede ahorrar a los demás, con una sencilla pero muy útil herramienta: postable.
¿Y cuál es el objetivo de esta herramienta? Facilitarnos la tarea de insertar código XHTML de ejemplo en una pág……
It can’t handle
php info();
or at least not when i type it in
That’s because there’s nothing in “php info();” that needs to be converted.
Now if you did “<?php info(); ?>” it would do some converting.
well i know that i was just testing out your app, trying the
when typing the php info(); in 1 word the postable makes an error and so does this blog so i guess it’s something to do with your host or something.
What’s the error that you get?
When I type in “<?php info(); ?>” I get “<?php info(); ?>”–Which is exactly what should happen.
well write:
the command “php info();” this should be in 1 word like phpinfo
wrap some php tags around it if you want to.
look it up on php.net can’t seem to post the right commant get some weird error, think it’s because of your host at it is also preventing me from writing it on this site too.
Ah, I see what you mean now. Yeah, it’s probably a dreamhost thing, trying to keep the server secure I’m guessing.
You know what would be cool? To find a javascript equivalent of htmlentities() and roll this little app into a Konfabulator/OSX compatible widget. I would love to give it a shot, let me know if you are interested.
I think this can be achieved using javascript alone. I’m building a javascript version of Postable. I’ll add another comment when done.
It could probably be done with a series of reg expressions, but you’ll have to go through and find all the HTML entities for everything you’re going to want to transform–I just used htmlentities() then a quick str_replace() to fix ampersands. When you do it that way, all the html entities will be replaced without tons and tons of code.
Is there really any reason to have a pure JavaScript version?
There’s no good reason to have a pure Javascript version on the web, but it could be good for making a desktop widget. I was actually thinking of making something similar for just that reason, but never got around to it.
Yeah, that’s true. From his comment, it sounded like it was for online use…maybe I read it wrong.
I made one. I haven’t tested Safari.
HTML Escaper and Javascript String Escaper
I have no exprience with desktop widget programming. But if somebody want to make a widget, she or he can copy and modify existing code if its license allows.
I wanted to write a javascript function that could take as input an element’s id and spit out a code block below the element automatically, so it would make my documentation easier, anyone seen something like it I can use?
IE innerHTML looks like hell (ruins my beautiful XHTML!)
Firefox innerHTML looks great, but I want a cross-browser solution
Elliot,
I have used this many times before. just recently I have found it again, and writing some code I’m doing it’s been invaluable.
Many thanks.
-Alan
“but you’ll have to go through and find all the HTML entities for everything you’re going to want to transform”
php.net: get_html_translation_table
get_html_translation_table() will return the translation table that is used internally for htmlspecialchars() and htmlentities().
rockin’ stuff!
thnx
Great !! Thanks!
Nice idea mate, I have my own version of this up and running too. ( HTML Friendly )
—
Dale Hay
Write a comment here.
Write a comment here. Thank you
[…] The developer of the tool, Elliot Swan, has spelt out everything in his announcement post. The name, “Postable”, is written in large letters (sans reflection). There is a code box, and a simple button named “make it friendly” below. It is AJAXed, which saves you a reload of the page. I tested it on a slow connection, and it managed to load quite fast. The scripts working behind the screen are Prototype and Scriptaculous JS library, along with a custom script. […]
[…] The purpose behind Postable is to help you when you are posting code either on your blog or in a comments field. […]
[…] Have you ever wanted to put code into a post without it being interpreted as code? A while ago I was trying to write a page to include code for buttons for my blog. After much struggling with the WYSIWYG editor I eventually managed to write it. If only I had seen this post from Elliot Swan ‘Allow me to introduce you to my new little app Postable’ then it would have been much easier! […]
Hey, it’s this post’s two year anniversary! Anyway, I’m not sure if you’re still updating Postable or not, but I’ve noticed it seems to strip out the ‘+’ symbol. Other than that, I love it and use it often!
Great little app - saves so much time and there is no need for installing any of the various plug ins available. I do tutorials from time to time on My Site and this is going to help me do things a lot lot quicker! Thanks!
John
Hey all - I just went live with yet another one. The major differences are that mine is implemented completely with regex on the client side (and therefore super fast) and it also provides several different options to customize the output. I’ve been using Postable for awhile, and it’s great - but I ultimately needed a little more flexibility. Let me know what you think!
Asciible
Elliot, very good tool! Thanks