Files
atom/extensions/docs/helpers.coffee
Chris Wanstrath bc6e2597b0 docs extension
Only works for TomDoc'd CoffeeScript right now.

Needs to work for all languages.

I had to modify handlebars to satisfy 'use strict'

Also had to modify the path stuff in tdoc, which works
in node but not atom. We need some way to install npm packages
or something similar maybe?
2011-11-13 22:22:41 -08:00

21 lines
579 B
CoffeeScript

hbar = require './handlebars'
{Showdown} = require './showdown'
converter = new Showdown.converter
hbar.registerHelper 'format', (comment) ->
comment = comment+''
# param - info => <b>param:</b> info
comment = comment.replace /(?:^\s*(\S+?)\s+-\s+(.+)$)+/img,
'<br>**$1:** $2'
comment = comment.replace '<br>**', '<br><br>**'
# markdownize
comment = converter.makeHtml comment
# <pre><code>code</code></pre> => <pre>code</pre>
comment = comment.replace /<pre><code>((?:.|\n)+)<\/code><\/pre>/img,
'<pre>$1</pre>'
new hbar.SafeString comment