spine / spine.site

Old Spine Site (not active)
41 stars 24 forks source link

Syntax highlight CoffeeScript in docs #51

Closed roryokane closed 10 years ago

roryokane commented 11 years ago

For example, see the Classes and Modules documentation page. This code block is unhighlighted:

class User
  # Class method
  @find: (id) ->
    (@records or= {})[id]

  # called on instantiation
  constructor: (attributes = {}) ->
    @attributes = attributes

  # Instance methods
  save: ->
  destroy: ->

On the site, comments with # and keywords like class are not marked specially, but should be.

This JavaScript later on in the page is correctly highlighted:

Users.extend({
  find: function(id){
    /* ... */         
  }
});

Users.include({
  destroy: function(){
    /* ... */ 
  }
});

As GitHub's highlighter shows, it certainly is possible to highlight CoffeeScript.

Note that the CoffeeScript code block on that page is highlighted, but looking at the source, it is being highlighted as JavaScript, which only looks okay in this case because that snippet doesn't use any CoffeeScript-specific syntax.

roryokane commented 11 years ago

You have the file app/assets/javascripts/highlight.js, which is probably the Highlight.js library. According to that library's demo page, it should already know how to highlight CoffeeScript correctly.

aeischeid commented 10 years ago

looks like I fixed it. thanks for the tip