diff --git a/Cakefile b/Cakefile index 44c37011..8b34403d 100644 --- a/Cakefile +++ b/Cakefile @@ -199,22 +199,36 @@ buildDocs = (watch = no) -> codeFor = require "./documentation/v#{majorVersion}/code.coffee" htmlFor = -> - marked = require 'marked' - markdownRenderer = new marked.Renderer() - markdownRenderer.heading = (text, level) -> - "#{text}" # Don’t let marked add an id - markdownRenderer.code = (code) -> + hljs = require 'highlight.js' + hljs.configure classPrefix: '' + markdownRenderer = require('markdown-it') + html: yes + typographer: yes + highlight: (str, lang) -> + # From https://github.com/markdown-it/markdown-it#syntax-highlighting + if lang and hljs.getLanguage(lang) + try + return hljs.highlight(lang, str).value + catch ex + return '' # No syntax highlighting + + + # Add some custom overrides to Markdown-It’s rendering, per + # https://github.com/markdown-it/markdown-it/blob/master/docs/architecture.md#renderer + defaultFence = markdownRenderer.renderer.rules.fence + markdownRenderer.renderer.rules.fence = (tokens, idx, options, env, slf) -> + code = tokens[idx].content if code.indexOf('codeFor(') is 0 or code.indexOf('releaseHeader(') is 0 "<%= #{code} %>" else - "
#{code}
" # Default + "
#{defaultFence.apply @, arguments}
" (file, bookmark) -> md = fs.readFileSync "#{sectionsSourceFolder}/#{file}.md", 'utf-8' md = md.replace /<%= releaseHeader %>/g, releaseHeader md = md.replace /<%= majorVersion %>/g, majorVersion md = md.replace /<%= fullVersion %>/g, CoffeeScript.VERSION - html = marked md, renderer: markdownRenderer + html = markdownRenderer.render md html = _.template(html) codeFor: codeFor() releaseHeader: releaseHeader diff --git a/docs/v2/index.html b/docs/v2/index.html index 76e5d7e7..41e82b65 100644 --- a/docs/v2/index.html +++ b/docs/v2/index.html @@ -15,7 +15,7 @@ - + @@ -612,9 +651,6 @@ textarea { - @@ -653,6 +689,9 @@ textarea { + @@ -676,10 +715,11 @@ textarea {

CoffeeScript is a little language that compiles into JavaScript. Underneath that awkward Java-esque patina, JavaScript has always had a gorgeous heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.

The golden rule of CoffeeScript is: “It’s just JavaScript.” The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime. You can use any existing JavaScript library seamlessly from CoffeeScript (and vice-versa). The compiled output is readable, pretty-printed, and tends to run as fast or faster than the equivalent handwritten JavaScript.

Latest Version: 2.0.0-alpha1

-
-
npm install -g coffeescript@next
- -

Overview

CoffeeScript on the topleft, compiled JavaScript output on the bottomright. The CoffeeScript is editable!

+
npm install -g coffeescript@next
+
+
+

Overview

+

CoffeeScript on the topleft, compiled JavaScript output on the bottomright. The CoffeeScript is editable!

All together now:

- - - - +
+ - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - + - - - - - - - - - - - - - -
CoffeeScriptJavaScript
is===
isnt!==
not!
and&&
or||
true, yes, ontrue
false, no, offfalse, no, off false
@, thisthis
ofin
inno JS equivalentno JS equivalent
a ** bMath.pow(a, b)
a // bMath.floor(a / b)
a %% b(a % b + b) % b
-