metacpan / js-metacpan-org

Proof of concept search page for using api.metacpan.org
28 stars 6 forks source link

Look into other syntax highlighters #4

Open ioncache opened 13 years ago

ioncache commented 13 years ago

1) Current I'm using: http://softwaremaniacs.org/soft/highlight/en/

This one is nice in that I can make a call to highlight a particular element at will without having to re-highlight the entire page. It also has an auto-detection routine to figure out what highlighter should be used on any particular piece of code.

However it has some issues with Perl, in that if a chunk of code starts with a comment (starting with a # mark) then it doesn't seem to recognize it as Perl. Also it doesn't know what to do with POD.

2) http://alexgorbatchev.com/SyntaxHighlighter/

I've used this one before and it works fairly well. This is probably the highlighter that I'd prefer to use. However I was having issues getting it to highlight code dynamically.

3) http://www.balupton.com/projects/jquery-syntaxhighlighter/

I tried this as well. It uses Google's Prettify as it's highlighting engine and wraps it in jQuery for easier use. This one had some serious issues with Perl code as well. It didn't seem to respect spacing in code properly, and it also seemed to have the issue with code blocks beginning with a comment.

However I might try it again, as I was only using it when I was pulling pod from search.cpan.org directly with YQL instead of using our internal pod. This was causing some nastiness with the pod formatting, so this plugin may now work properly.

monken commented 13 years ago

I can also recommend http://alexgorbatchev.com/SyntaxHighlighter/

The dynamic highlighting works pretty well too:

// ExtJS code
this.body.insertHtml('afterBegin', '<pre class="brush: pl; class-name: \'highlight\'; toolbar: false;">' + Ext.util.Format.htmlEncode(res.source) + '</pre>');
SyntaxHighlighter.highlight();
ioncache commented 13 years ago

I've actually used that one before. We are currently using that on our CPAN Mangler middleware and in our iCPAN app.

Frankly it's probably my first choice to use but I had trouble getting it to work dynamically though. However I may give it another try and see if it was just pebcak or something.

trapd00r commented 13 years ago

Wouldn't pygments be an alternative?

ioncache commented 13 years ago

Pygments is server side only I believe. The current search.metacpan.org has no backend, it's all done in javascript so I need a javascript implementation.

We are probably going to do a version of the search site that does have a back end though (mainly so that search engines can crawl the site) and pygments would be a good choice for that.