From 4aa0130a92819908d9fc99722861f9cd77b9ea20 Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Sun, 11 Dec 2016 15:46:02 -0800 Subject: [PATCH] Use idiomatic markdown output for code blocks (
)

---
 Cakefile                               |  2 +-
 docs/v1/index.html                     | 62 +++++++++++---------------
 documentation/sections/changelog.md    |  7 +--
 documentation/sections/installation.md |  8 ++--
 documentation/sections/introduction.md |  2 +-
 documentation/sections/usage.md        |  9 ++--
 documentation/v1/docs.css              | 14 +++---
 documentation/v1/tomorrow.css          |  6 ---
 8 files changed, 49 insertions(+), 61 deletions(-)

diff --git a/Cakefile b/Cakefile
index 2ff6bb5e..5bcf6230 100644
--- a/Cakefile
+++ b/Cakefile
@@ -184,7 +184,7 @@ task 'doc:site', 'watch and continually rebuild the documentation for the websit
       if code.indexOf('codeFor(') is 0 or code.indexOf('releaseHeader(') is 0
         "<%= #{code} %>"
       else
-        "
\n#{code}\n
" + "
#{code}
" # Default (file, bookmark) -> md = fs.readFileSync "#{sectionsSourceFolder}/#{file}.md", 'utf-8' diff --git a/docs/v1/index.html b/docs/v1/index.html index 78418b7e..fc2ae5d2 100644 --- a/docs/v1/index.html +++ b/docs/v1/index.html @@ -78,7 +78,11 @@ table.definitions { text-align: center; padding: 5px 20px; } -code, pre, textarea { +blockquote { + margin-left: 0; + margin-right: 0; +} +code, pre, pre > code, textarea { font-family: Monaco, Consolas, "Lucida Console", monospace; font-size: 12px; line-height: 18px; @@ -92,16 +96,12 @@ code, pre, textarea { border: 1px solid #dedede; padding: 0px 0.2em; } - pre { + blockquote > pre { + margin: 0; border-left: 5px solid rgba(0,0,0,0.2); padding: 3px 0 3px 12px; font-size: 12px; } - pre.no_bar { - border-left: 0; - margin-left: 0; - padding-left: 0; - } .timestamp { font-size: 11px; font-weight: normal; @@ -496,12 +496,6 @@ pre .class .title { color: #21439C; } -pre code { - display: block; - background: white; - color: #000000; -} - pre .coffeescript .javascript, pre .javascript .xml, pre .tex .formula, @@ -612,9 +606,9 @@ pre .xml .cdata {

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.

The CoffeeScript compiler goes to great lengths to generate output JavaScript that runs in every JavaScript runtime, but there are exceptions. Use generator functions, for…from, or tagged template literals only if you know that your target runtimes can support them. If you use modules, you will need to use an additional tool to resolve them.

Latest Version: 1.12.1

-
-npm install -g coffee-script
-
+
+
npm install -g coffee-script
+

Overview

@@ -741,18 +735,18 @@ cubes = (function() {

Installation

The CoffeeScript compiler is itself written in CoffeeScript, using the Jison parser generator. The command-line version of coffee is available as a Node.js utility. The core compiler however, does not depend on Node, and can be run in any JavaScript environment, or in the browser (see “Try CoffeeScript”, above).

To install, first make sure you have a working copy of the latest stable version of Node.js. You can then install CoffeeScript globally with npm:

-
-npm install -g coffee-script
-

When you need CoffeeScript as a dependency, install it locally:

-
-npm install --save coffee-script
-

If you’d prefer to install the latest master version of CoffeeScript, you can clone the CoffeeScript source repository from GitHub, or download the source directly. To install the latest master CoffeeScript compiler with npm:

-
-npm install -g jashkenas/coffeescript
-

Or, if you want to install to /usr/local, and don’t want to use npm to manage it, open the coffee-script directory and run:

-
-sudo bin/cake install
-
+
+
npm install -g coffee-script
+

When you need CoffeeScript as a dependency, install it locally:

+
+
npm install --save coffee-script
+

If you’d prefer to install the latest master version of CoffeeScript, you can clone the CoffeeScript source repository from GitHub, or download the source directly. To install the latest master CoffeeScript compiler with npm:

+
+
npm install -g jashkenas/coffeescript
+

Or, if you want to install to /usr/local, and don’t want to use npm to manage it, open the coffee-script directory and run:

+
+
sudo bin/cake install
+

Usage

@@ -880,9 +874,9 @@ sudo bin/cake install -n, --nodes -Instead of compiling the CoffeeScript, just lex and parse it, and print out the parse tree: +Instead of compiling the CoffeeScript, just lex and parse it, and print out the parse tree:
-
Block
+Block
   Assign
     Value IdentifierLiteral: square
     Code
@@ -890,8 +884,7 @@ sudo bin/cake install
       Block
         Op *
           Value IdentifierLiteral: x
-          Value IdentifierLiteral: x
- + Value IdentifierLiteral: x @@ -2737,13 +2730,12 @@ The CoffeeScript logo is available in SVG for use in presentations.
  • yield return can no longer mistakenly be used as an expression.
  • yield now mirrors return in that it can be used stand-alone as well as with expressions. Where you previously wrote yield undefined, you may now write simply yield. However, this means also inheriting the same syntax limitations that return has, so these examples no longer compile:

    -
    doubles = ->
    +
    doubles = ->
       yield for i in [1..3]
         i * 2
     six = ->
       yield
    -    2 * 3
    -
  • + 2 * 3
  • The JavaScript output is a bit nicer, with unnecessary parentheses and spaces, double indentation and double semicolons around yield no longer present.

  • diff --git a/documentation/sections/changelog.md b/documentation/sections/changelog.md index b47d75c4..dcdf648a 100644 --- a/documentation/sections/changelog.md +++ b/documentation/sections/changelog.md @@ -39,13 +39,14 @@ releaseHeader('2016-09-24', '1.11.0', '1.10.0') * `yield return` can no longer mistakenly be used as an expression. * `yield` now mirrors `return` in that it can be used stand-alone as well as with expressions. Where you previously wrote `yield undefined`, you may now write simply `yield`. However, this means also inheriting the same syntax limitations that `return` has, so these examples no longer compile: - -
    doubles = ->
    +        ```
    +        doubles = ->
               yield for i in [1..3]
                 i * 2
             six = ->
               yield
    -            2 * 3
    + 2 * 3 + ``` * The JavaScript output is a bit nicer, with unnecessary parentheses and spaces, double indentation and double semicolons around `yield` no longer present. * `&&=`, `||=`, `and=` and `or=` no longer accidentally allow a space before the equals sign. diff --git a/documentation/sections/installation.md b/documentation/sections/installation.md index cba6ad8c..e44852f4 100644 --- a/documentation/sections/installation.md +++ b/documentation/sections/installation.md @@ -4,24 +4,24 @@ The CoffeeScript compiler is itself [written in CoffeeScript](v<%= majorVersion To install, first make sure you have a working copy of the latest stable version of [Node.js](http://nodejs.org/). You can then install CoffeeScript globally with [npm](http://npmjs.org): -``` +> ``` npm install -g coffee-script ``` When you need CoffeeScript as a dependency, install it locally: -``` +> ``` npm install --save coffee-script ``` If you’d prefer to install the latest **master** version of CoffeeScript, you can clone the CoffeeScript [source repository](http://github.com/jashkenas/coffeescript) from GitHub, or download [the source](http://github.com/jashkenas/coffeescript/tarball/master) directly. To install the latest master CoffeeScript compiler with npm: -``` +> ``` npm install -g jashkenas/coffeescript ``` Or, if you want to install to `/usr/local`, and don’t want to use npm to manage it, open the `coffee-script` directory and run: -``` +> ``` sudo bin/cake install ``` diff --git a/documentation/sections/introduction.md b/documentation/sections/introduction.md index f4e08db8..0f460cf2 100644 --- a/documentation/sections/introduction.md +++ b/documentation/sections/introduction.md @@ -6,6 +6,6 @@ The CoffeeScript compiler goes to great lengths to generate output JavaScript th **Latest Version:** [<%= fullVersion %>](http://github.com/jashkenas/coffeescript/tarball/<%= fullVersion %>) -``` +> ``` npm install -g coffee-script ``` diff --git a/documentation/sections/usage.md b/documentation/sections/usage.md index 80f6913f..ab513667 100644 --- a/documentation/sections/usage.md +++ b/documentation/sections/usage.md @@ -125,9 +125,10 @@ Once installed, you should have access to the `coffee` command, which can execut `-n, --nodes` -Instead of compiling the CoffeeScript, just lex and parse it, and print out the parse tree: +Instead of compiling the CoffeeScript, just lex and parse it, and print out the parse tree:
    -
    Block
    +```
    +Block
       Assign
         Value IdentifierLiteral: square
         Code
    @@ -135,8 +136,8 @@ Once installed, you should have access to the `coffee` command, which can execut
           Block
             Op *
               Value IdentifierLiteral: x
    -          Value IdentifierLiteral: x
    - + Value IdentifierLiteral: x +``` diff --git a/documentation/v1/docs.css b/documentation/v1/docs.css index e0cc0050..9384983e 100644 --- a/documentation/v1/docs.css +++ b/documentation/v1/docs.css @@ -62,7 +62,11 @@ table.definitions { text-align: center; padding: 5px 20px; } -code, pre, textarea { +blockquote { + margin-left: 0; + margin-right: 0; +} +code, pre, pre > code, textarea { font-family: Monaco, Consolas, "Lucida Console", monospace; font-size: 12px; line-height: 18px; @@ -76,16 +80,12 @@ code, pre, textarea { border: 1px solid #dedede; padding: 0px 0.2em; } - pre { + blockquote > pre { + margin: 0; border-left: 5px solid rgba(0,0,0,0.2); padding: 3px 0 3px 12px; font-size: 12px; } - pre.no_bar { - border-left: 0; - margin-left: 0; - padding-left: 0; - } .timestamp { font-size: 11px; font-weight: normal; diff --git a/documentation/v1/tomorrow.css b/documentation/v1/tomorrow.css index 0833216c..e0048cd6 100644 --- a/documentation/v1/tomorrow.css +++ b/documentation/v1/tomorrow.css @@ -49,12 +49,6 @@ pre .class .title { color: #21439C; } -pre code { - display: block; - background: white; - color: #000000; -} - pre .coffeescript .javascript, pre .javascript .xml, pre .tex .formula,