开发者

Objective-c code formatter site to create html that can be embedded into a blog

I'm looking for site simil开发者_运维问答ar to http://www.manoli.net/csharpformat/ that allows one to put in c# code snippet and it formats the html to post into your blog with a CSS file.

I need one that actually does this for Objective-C.


You want the GeSHi (Generic Syntax Highlighter) library. It's is excellent, has dozens of languages (including Objective-C, with the ability to automatically linkify classes/protocols to the documentation), and support for many popular CMSs (Django, WordPress, Drupal, Joomla, Mambo, etc).

If you'd like to see it in action, you can check out nearly any wiki page on our local CocoaHeads website. For example: http://cocoaheads.byu.edu/wiki/different-nslog


Assuming you're on a Mac, copying code from Xcode will keep the syntax coloring. Any WYSIWYG blog editor should support that.

In case your blog software isn't WYSIWYG, you can paste into TextEdit and save as HTML. It outputs pretty crappy HTML considering it's just highlighted source code, but it's nonetheless compliant HTML.

Other than that, I don't know of an online service for that.


I use pygments (python) to generate syntax highlight for source code examples embedded in blog.

If your entry text is just the source code it will work the same for what you are after, I tested it to highlight Objective-C as well.

I actually use markdown syntax to type plain text blog post in a file and I copy plain text code examples. Then I run the file via markdown processor, which includes pygments for highlight and store it into a file.

It's as simple as:

include markdown
html = markdown.markdown(text,['codehilite'])

See simple script at the link which just takes file name of your plain text file and creates html file.

Then I can copy/paste the code.

You have to include link or copy the css as well to get the syntax highligh but it's easy.

I do this for blogger, see example how to use markdown with pygments to do syntax highlight.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜