mirror of
https://github.com/atom/atom.git
synced 2026-01-24 22:38:20 -05:00
markdownpreview extension. awwww yeah.
This commit is contained in:
1
extensions/markdownpreview/index.coffee
Normal file
1
extensions/markdownpreview/index.coffee
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require 'markdownpreview/markdownpreview'
|
||||
2
extensions/markdownpreview/key-bindings.coffee
Normal file
2
extensions/markdownpreview/key-bindings.coffee
Normal file
@@ -0,0 +1,2 @@
|
||||
editor:
|
||||
'cmd-ctrl-p': (editor) -> window.open "markdown:#{editor.url}"
|
||||
37
extensions/markdownpreview/markdownpreview.coffee
Normal file
37
extensions/markdownpreview/markdownpreview.coffee
Normal file
@@ -0,0 +1,37 @@
|
||||
fs = require 'fs'
|
||||
|
||||
tdoc = require 'docs/tdoc'
|
||||
|
||||
Browser = require 'browser'
|
||||
|
||||
{Showdown} = require './showdown'
|
||||
converter = new Showdown.converter
|
||||
|
||||
module.exports =
|
||||
class Markdownpreview extends Browser
|
||||
window.resourceTypes.push this
|
||||
|
||||
running: true
|
||||
|
||||
constructor: ->
|
||||
atom.keybinder.load require.resolve "markdownpreview/key-bindings.coffee"
|
||||
|
||||
open: (url) ->
|
||||
return false if not url
|
||||
|
||||
if match = url.match /^markdown:(.+)/
|
||||
@url = url
|
||||
|
||||
html = '''
|
||||
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css">
|
||||
<style>
|
||||
body { padding:10px; }
|
||||
code { line-height:16px; }
|
||||
</style>
|
||||
|
||||
'''
|
||||
html += converter.makeHtml fs.read match[1]
|
||||
|
||||
@show html
|
||||
|
||||
true
|
||||
1302
extensions/markdownpreview/showdown.js
Normal file
1302
extensions/markdownpreview/showdown.js
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user