-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
8,431 additions
and
1,391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/*! | ||
* nodeclub - common/render_helpers.js | ||
* Copyright(c) 2013 fengmk2 <fengmk2@gmail.com> | ||
* MIT Licensed | ||
*/ | ||
|
||
"use strict"; | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var Remarkable = require('remarkable'); | ||
var _ = require('lodash'); | ||
var config = require('../config'); | ||
var validator = require('validator'); | ||
var multiline = require('multiline'); | ||
|
||
// Set default options | ||
var md = new Remarkable(); | ||
|
||
md.set({ | ||
html: false, // Enable HTML tags in source | ||
xhtmlOut: false, // Use '/' to close single tags (<br />) | ||
breaks: true, // Convert '\n' in paragraphs into <br> | ||
linkify: false, // Autoconvert URL-like text to links | ||
typographer: false, // Enable smartypants and other sweet transforms | ||
}); | ||
|
||
md.renderer.rules.fence = function (tokens, idx) { | ||
var token = tokens[idx]; | ||
var language = token.params && ('language-' + token.params) || ''; | ||
language = validator.escape(language); | ||
return '<pre class="prettyprint ' + language + '">' | ||
+ '<code>' + validator.escape(token.content) + '</code>' | ||
+ '</pre>'; | ||
}; | ||
|
||
|
||
// renderer.code = function (code, lang) { | ||
// var language = lang && ('language-' + lang) || ''; | ||
// language = validator.escape(language); | ||
// return '<pre class="prettyprint ' + language + '">' | ||
// + '<code>' + validator.escape(code) + '</code>' | ||
// + '</pre>'; | ||
// }; | ||
|
||
// marked.setOptions({ | ||
// renderer: renderer, | ||
// gfm: true, | ||
// tables: true, | ||
// breaks: true, | ||
// pedantic: false, | ||
// sanitize: true, | ||
// smartLists: true, | ||
// smartypants: false, | ||
// }); | ||
|
||
exports.markdown = function (text) { | ||
return '<div class="markdown-text">' + md.render(text || '') + '</div>'; | ||
}; | ||
|
||
exports.multiline = multiline; | ||
|
||
exports.escapeSignature = function (signature) { | ||
return signature.split('\n').map(function (p) { | ||
return _.escape(p); | ||
}).join('<br>'); | ||
}; | ||
|
||
exports.staticFile = function (filePath) { | ||
return config.site_static_host + filePath; | ||
}; | ||
|
||
exports.tabName = function (tab) { | ||
var pair = _.find(config.tabs, function (pair) { | ||
return pair[0] === tab; | ||
}); | ||
if (pair) { | ||
return pair[1]; | ||
} | ||
}; | ||
|
||
exports._ = _; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.