Re:Ask HN: review my tiny app - code to html converter
by Torn on Monday September 14, 2009 @10:05AM
(#821655)
Nice work.
Quick suggestion though (for ease of copy-pasting by end-users):
From the resulting rendered html with line numbers, the line numbers are also copied into the clipboard, which is undesirable. Suggest you put them in separate elements like dpaste does it, for easy selection without line numbers: http://dpaste.com/hold/93427/
Re:Ask HN: review my tiny app - code to html converter
by profquail on Monday September 14, 2009 @09:55AM
(#821632)
Cool little app. One little improvement I thought of though, is to move the inline styles into the header, even if you're just using class names like "code1", "code2", etc.
It would just make it a bit easier to read the source code or change the code colors if you ever needed to. It should also give you a small decrease in the actual code size, which could matter if you were posting a lot of code on a heavily-visited site.
Re:Ask HN: review my tiny app - code to html converter
by alexkay on Monday September 14, 2009 @09:43AM
(#821612)
GitHub's gists can indeed be embedded to blog posts, but only using an external js script. This won't work with blog hosting providers that don't allow JavaScript (for example wordpress.com).
Also, this method won't work too well when the post is viewed in an rss reader.
Re:Ask HN: review my tiny app - code to html converter
by sant0sk1 on Monday September 14, 2009 @10:07AM
(#821660)
Agreed.
I have waffled back & forth on embedding gists in my blog posts because they don't show up in RSS readers. Also, if you have a long blog post with multiple snippets of code you have to create a new gist for each one. It'd be nice if each 'file' in a gist could be embedded separately.
Re:Ask HN: review my tiny app - code to html converter
by alexkay on Monday September 14, 2009 @08:56PM
(#822990)
Thanks Peter. As I mentioned earlier, javascript solutions work great but have two major limitations: not all hosting providers allow embeddable js; and javascripted highlighting doesn't work too well in rss readers.
Re:Ask HN: review my tiny app - code to html converter
by weaksauce on Monday September 14, 2009 @10:29PM
(#823128)
It might be useful to add a button that copies the resultant code to your clipboard. I don't know how cross browser that is but it could be nice. I don't think that it should be the default action when you generate though because people will not know that it is happening and they might not want the clipboard data to get overwritten.
Re:Ask HN: review my tiny app - code to html converter
by chaosprophet on Monday September 14, 2009 @10:55AM
(#821748)
Though this is a pretty nice and useful piece of code, I will stick to using SyntaxHighlighter for my blog, because it offers me the ability to include a plaintext view function and a print function. The plaintext view removes the linenumbers and all other info apart from the actual code.
Re:Ask HN: review my tiny app - code to html converter
by chaosprophet on Tuesday September 15, 2009 @07:01AM
(#823611)
Hmmmm... I never knew it din't work in RSS readers. But I guess that's not too much of a dealbreaker right now. Perhaps if my feed subscribers increase, I'll switch.
Re:Ask HN: review my tiny app - code to html converter
by raju on Monday September 14, 2009 @12:56PM
(#822034)
Very nice app. Bookmarked. Quick suggestion, and it may not be something used by all users, but I attempted to type code in, and naturally hit a tab after the first line to indent the class declaration (I was trying out some Ruby code). Naturally the tab takes me elsewhere.
Maybe capture a Ctrl-Tab (or similar key-stroke) and insert a tab? [I am not sure how useful this would be for most users copy pasting code in, but it does make it easy to type in code]
Re:Ask HN: review my tiny app - code to html converter
by nirmal on Monday September 14, 2009 @10:25AM
(#821690)
You should register an onChange handler for all of the form elements and update the preview automatically. Specifically, for the drop down box used to pick color themes.
Re:Ask HN: review my tiny app - code to html converter
by alexkay on Monday September 14, 2009 @10:30AM
(#821696)
At first I wanted to update the preview on-the-fly as the input changes, but then I decided to go javascript-free so that the page loads and feels faster. I will probably try it later anyway.
Re:Ask HN: review my tiny app - code to html converter
by frossie on Monday September 14, 2009 @03:13PM
(#822387)
Okay now I am curious which langauge you wanted that wasn't there... there's like a 100 languages on that list, half of which I haven't even heard of ("Brainfuck"???)
Quick suggestion though (for ease of copy-pasting by end-users):
From the resulting rendered html with line numbers, the line numbers are also copied into the clipboard, which is undesirable. Suggest you put them in separate elements like dpaste does it, for easy selection without line numbers: http://dpaste.com/hold/93427/
Great suggestion, I will see what I can do.
I wish this had been around when I was doing my last blog post; would have saved a lot of messing around with TextMate's HTML generation.
Bookmarked!
By the way, the CSS and the style are remembered in the cookies, no need to re-type them on each visit.
Is this intentional for black backgrounds as you mentioned? If so, changing to fruity should change the default CSS.
Changing the default CSS if they are selected is a good idea, thanks!
works well for me. I'd like to see JSON as a data format or better still an API to let you define your own code to convert.
It would just make it a bit easier to read the source code or change the code colors if you ever needed to. It should also give you a small decrease in the actual code size, which could matter if you were posting a lot of code on a heavily-visited site.
There are already quite a few solutions for those who can modify the header, the most famous is http://alexgorbatchev.com/wiki/SyntaxHighlighter
* Always editable in a clean text-area. * Version controlled. * Language detection and syntax highlighting.
Also, this method won't work too well when the post is viewed in an rss reader.
I have waffled back & forth on embedding gists in my blog posts because they don't show up in RSS readers. Also, if you have a long blog post with multiple snippets of code you have to create a new gist for each one. It'd be nice if each 'file' in a gist could be embedded separately.
In future, though, I'll probably move to a JavaScript solution as this hard coding just doesn't feel right anymore.
* It requires to link to a js script which is not always possible.
* It doesn't work in many rss readers.
if you can, could you please use this term in keywords somewhere for older coders like me. Then we can find it via searching on those terms
Excellent app.
http://www.network-science.de/ascii/
if you find yourself popular and wanting to monetize
http://dedasys.com/Interp.java.html
the results of running htmlize-buffer on Hecl's Interp.java.
Maybe capture a Ctrl-Tab (or similar key-stroke) and insert a tab? [I am not sure how useful this would be for most users copy pasting code in, but it does make it easy to type in code]
Again, nice app. Thanks, and good work.
Also, it looks like you're looking for keywords. That doesn't work for class names. Pattern recognition will probably do a lot better.
As for highlighting, I'm using the Pygments library: http://pygments.org/
The first time I tried a PHP snippet I didn't copy the <?php ?> tags and it didn't highlight anything. However, I quickly figured it out.
You might want to add a message or notice about the <?php ?> requirement.
How about feature of automatically detect programming language?
You can even write your own lexer, it will be greatly appreciated by all Pygments users: http://pygments.org/docs/lexerdevelopment/