Add support for Literate CoffeeScript #408

Merged
merged 2 commits into from Feb 27, 2013

Projects

None yet

8 participants

@soimort
Contributor
soimort commented Feb 26, 2013

As of 1.5.0, CoffeeScript supports code to be written in "literate" mode (as a Markdown document).
http://coffeescript.org/#literate

Just trying to add Literate CoffeeScript to the language list, in the same way Literate Haskell does.

@tnm
Contributor
tnm commented Feb 26, 2013

@soimort — Cool. Would you be great you can add an example file the samples directory also.

@benatkin

I'm excited about .litcoffee and I hope that github will implement this. They are one of the biggest and earliest proponents of CoffeeScript! I'd like to see them shown as if it's Markdown with CoffeeScript fenced in code blocks. I guess that would make this a markup issue. In the near future I hope @github adds support for showing the same file with either Markup (if available) or Linguist. I've had to play the game of clicking raw or blame on an .md file that uses a nonstandard dialect plenty of times, so I hope this gets solved whether or not Literate CoffeeScript support is added to Markup. It would be a nice side effect of making it selectable, though, to see more things added to Markup! https://github.com/github/markup

Note that there isn't an issue on https://github.com/github/markup just yet. I'm not going to add one but if someone else wants to, I'll add my support. :)

@soimort
Contributor
soimort commented Feb 27, 2013

@tnm Sure. Here it is.

@tnm tnm merged commit cf6eeec into github:master Feb 27, 2013

1 check passed

default The Travis build passed
Details
@benatkin

☕️

@jashkenas

Eh? Don't we need a highlighter for this? Or has someone already got a new one merged into Pygments HEAD?

@soimort
Contributor
soimort commented Mar 1, 2013

@jashkenas

IMHO, it should be another issue on github/markup.

Not only the whole .litcoffee file should be rendered as a Markdown document, but also the inside code blocks should be highlighted properly as if they were in CoffeeScript fences, e.g.,

Initialize a scope with its parent, for lookups up the chain,
as well as a reference to the **Block** node it belongs to, which is
where it should declare its variables, and a reference to the function that
it belongs to.

      constructor: (@parent, @expressions, @method) ->
        @variables = [{name: 'arguments', type: 'arguments'}]
        @positions = {}
        Scope.root = this unless @parent

could be rendered exactly the same way as:

Initialize a scope with its parent, for lookups up the chain,
as well as a reference to the **Block** node it belongs to, which is
where it should declare its variables, and a reference to the function that
it belongs to.
```coffeescript
constructor: (@parent, @expressions, @method) ->
  @variables = [{name: 'arguments', type: 'arguments'}]
  @positions = {}
  Scope.root = this unless @parent
```

and render into:


Initialize a scope with its parent, for lookups up the chain, as well as a reference to the Block node it belongs to, which is where it should declare its variables, and a reference to the function that it belongs to.

constructor: (@parent, @expressions, @method) ->
  @variables = [{name: 'arguments', type: 'arguments'}]
  @positions = {}
  Scope.root = this unless @parent

Obviously another pull request should be sent to github/markup, so that GitHub can support this.
Not quite sure if I can also contribute to this, but I'll take a look when I get a minute. 😎

@benatkin
benatkin commented Mar 1, 2013

I agree with both of you, in a sense. If we can only have one, which is the
case now, it should be treated as a markup generating document. In the
future I hope @github adds a way for the viewer to choose between markup
and syntax highlighting for a file. This should be in the url, perhaps
adding "Source" alongside Raw for markup-generating documents would be a
good way to do it.

But if we have a generator for github/markup, even now we should also have
syntax support, for blame, and for ace editor.

This is exciting. I'm confident we can get a good set of tools for this.

On 1 March 2013 07:11, Mort Yao notifications@github.com wrote:

@jashkenas https://github.com/jashkenas

IMHO, it should be another issue on github/markuphttps://github.com/github/markup
.

Not only the whole .litcoffee file should be rendered as a Markdown
document, but also the inside code blocks should be highlighted properly as
if they were in CoffeeScript fences, e.g.,

Initialize a scope with its parent, for lookups up the chain,
as well as a reference to the Block node it belongs to, which is
where it should declare its variables, and a reference to the function that
it belongs to.

  constructor: (@parent, @expressions, @method) ->
    @variables = [{name: 'arguments', type: 'arguments'}]
    @positions = {}
    Scope.root = this unless @parent

could be rendered exactly the same way as:

Initialize a scope with its parent, for lookups up the chain,
as well as a reference to the Block node it belongs to, which is
where it should declare its variables, and a reference to the function that
it belongs to.

constructor: (@parent, @expressions, @method) ->
  @variables = [{name: 'arguments', type: 'arguments'}]
  @positions = {}
  Scope.root = this unless @parent

and render into:

Initialize a scope with its parent, for lookups up the chain, as well as a
reference to the Block node it belongs to, which is where it should
declare its variables, and a reference to the function that it belongs to.

constructor: (@parent, @expressions, @method) ->
@variables = [{name: 'arguments', type: 'arguments'}]
@positions = {}
Scope.root = this unless @parent


Obviously another pull request should be sent to github/markuphttps://github.com/github/markup,
so that GitHub can support this.
Not quite sure if I can also contribute to this, but I'll take a look when
I get a minute. [image: 😎]


Reply to this email directly or view it on GitHubhttps://github.com/github/linguist/pull/408#issuecomment-14290850
.

@DavidPesta

This blows my mind. GitHub, please add this! :)

@soimort
Contributor
soimort commented Mar 4, 2013

Just took a look at github/markup#162 and found it turns out to be using jm/literati for doing the same thing in Literate Haskell:

# Fence it and add it to the output
markdown << "```haskell\n#{current_line}\n```\n"

Think Literate CoffeeScript could be very similar, but I can't do that (security needs);
Someone from @github be cool enough to create a renderer for this?

@jashkenas

Awesome -- that's exactly what my hacky .litcoffee -> README.md converter does at the moment as well.

https://github.com/jashkenas/journo/blob/master/Cakefile#L9-L15

A quick and dirty version along those lines would be perfect.

@jamiter
jamiter commented Mar 4, 2013

+1 - I'm using .litcoffee for a project and love it. I only miss the correct markup in github.

@soimort soimort deleted the unknown repository branch Mar 24, 2013
@sukima
sukima commented Jul 18, 2013

Literate Coffee uses both .litcoffee and .coffee.md Can the later be supported as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment