toto icon indicating copy to clipboard operation
toto copied to clipboard

Syntax Highlighting

Open jerodsanto opened this issue 15 years ago • 14 comments

Many hackers of Oz like to share syntax highlighted code snippets via their blog. Perhaps toto could leverage Maker's Mark (or something similar) to add this ability to markdown?

http://github.com/nakajima/makers-mark

jerodsanto avatar Feb 03 '10 18:02 jerodsanto

This is definitely something I'd like to have — I've been looking into javascript solutions though, such as the google syntax highlighter.

Maker's Mark looks pretty cool though, I'll look into it.

cloudhead avatar Feb 03 '10 21:02 cloudhead

Is there a reason to include this as part of toto rather than leaving it up to the user to decide what highlighting script they'd like to use? I think it should be a "bring your own" solution :)

ghost avatar Feb 06 '10 12:02 ghost

If toto gets its own baked-in syntax highlighting that'd be awesome, but I'm fine with using embedded gists in the meantime. Something that works like Maker's Mark but is ruby-only and rack-friendly would be nice.

hyperbolist avatar Feb 06 '10 19:02 hyperbolist

Yah, looks like Maker's Mark is not the best solution since it relies on Pygments to do the actual work. I didn't realize that before.

This looks like a job for a client-side library. Highlight.js seems to play nice with Markdown so I'm going to give it a try.

http://softwaremaniacs.org/soft/highlight/en/

jerodsanto avatar Feb 06 '10 21:02 jerodsanto

There's also http://ultraviolence.heroku.com, by technoweenie

foca avatar Feb 06 '10 23:02 foca

Wow, http://softwaremaniacs.org/soft/highlight/en/ is amazing. I especially like how it doesn't pollute our articles or config.ru or introduce gem dependencies and so on: it's just some js and css, requiring only a few lines in layout.rhtml. Minimal fuss. Nice find sant0sk1!

hyperbolist avatar Feb 07 '10 02:02 hyperbolist

Looks real good. The other alternative is: http://code.google.com/p/syntaxhighlighter/

I'm probably going to add one of these to dorothy, it'll be to the user's discretion whether or not they include it in their html.

cloudhead avatar Feb 07 '10 03:02 cloudhead

I'm using Rack-codehighlighter with ultraviolet. It was only a few llines in config.ru

vertiginous avatar Feb 08 '10 02:02 vertiginous

The rack-codehighlighter + ultraviolet combination produces very nice results. I've forked the dormant ultraviolet in the interest of adding vibrant_ink for myself, pushed a gem and it worked out wonderfully.

hyperbolist avatar Feb 08 '10 16:02 hyperbolist

I did encounter one problem. rack-codehighlighter uses hpricot, and hpricot couldn't parse the html 5 markup. I just ended up switching to old school html.

vertiginous avatar Feb 09 '10 22:02 vertiginous

@vertiginous Nice catch. I've switched rack-codehighlighter from hpricot to nokogiri and pushed a gem to hold us over until it is accepted upstream. It WorksForMe and YMMV.

hyperbolist avatar Feb 10 '10 22:02 hyperbolist

http://wiki.github.com/cloudhead/toto/syntax-highlighting

Made a wiki page, everyone, update it!

nogweii avatar Mar 15 '10 01:03 nogweii

What would be awesome would be to have support for Pygments via albino: https://github.com/github/albino

RobertAudi avatar Mar 19 '11 07:03 RobertAudi

I believe that server side solution is robust, but it looks improper for me. Why we need to highlight code on server side? It's not the part of the content in fact. So propose to use JavaScript based client side syntax highlighters like Hoghlight.JS of Ivan Sgalaev or Syntaxhighlighter of Alex Gorbatchev. Personally I use Ivan's version, you can take a look how I use it here: https://github.com/ixti/blog

ixti avatar Aug 08 '11 13:08 ixti