mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 10:16:26 +00:00
Markdown内のコードにSyntax highlightenをいれる
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
<link rel="stylesheet" href="../../node_modules/font-awesome/css/font-awesome.min.css" media="screen" charset="utf-8">
|
<link rel="stylesheet" href="../../node_modules/font-awesome/css/font-awesome.min.css" media="screen" charset="utf-8">
|
||||||
<link rel="stylesheet" href="../../node_modules/devicon/devicon.min.css">
|
<link rel="stylesheet" href="../../node_modules/devicon/devicon.min.css">
|
||||||
|
<link rel="stylesheet" href="../../node_modules/highlight.js/styles/xcode.css">
|
||||||
<link rel="shortcut icon" href="favicon.ico">
|
<link rel="shortcut icon" href="favicon.ico">
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
<link rel="stylesheet" href="../../node_modules/font-awesome/css/font-awesome.min.css" media="screen" charset="utf-8">
|
<link rel="stylesheet" href="../../node_modules/font-awesome/css/font-awesome.min.css" media="screen" charset="utf-8">
|
||||||
<link rel="stylesheet" href="../../node_modules/devicon/devicon.min.css">
|
<link rel="stylesheet" href="../../node_modules/devicon/devicon.min.css">
|
||||||
|
<link rel="stylesheet" href="../../node_modules/highlight.js/styles/xcode.css">
|
||||||
<link rel="shortcut icon" href="favicon.ico">
|
<link rel="shortcut icon" href="favicon.ico">
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ marked()
|
|||||||
display list-item
|
display list-item
|
||||||
line-height 1.8em
|
line-height 1.8em
|
||||||
code
|
code
|
||||||
font-family monospace
|
font-family Monaco, Menlo, 'Ubuntu Mono', Consolas, source-code-pro, monospace;
|
||||||
padding 2px 4px
|
padding 2px 4px
|
||||||
border solid 1px borderColor
|
border solid 1px borderColor
|
||||||
border-radius 4px
|
border-radius 4px
|
||||||
|
|||||||
@@ -1,8 +1,22 @@
|
|||||||
import markdownit from 'markdown-it'
|
import markdownit from 'markdown-it'
|
||||||
|
import hljs from 'highlight.js'
|
||||||
|
|
||||||
var md = markdownit({
|
var md = markdownit({
|
||||||
typographer: true,
|
typographer: true,
|
||||||
linkify: true
|
linkify: true,
|
||||||
|
highlight: function (str, lang) {
|
||||||
|
if (lang && hljs.getLanguage(lang)) {
|
||||||
|
try {
|
||||||
|
return hljs.highlight(lang, str).value;
|
||||||
|
} catch (__) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return hljs.highlightAuto(str).value;
|
||||||
|
} catch (__) {}
|
||||||
|
|
||||||
|
return ''; // use external default escaping
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
export default function markdown (content) {
|
export default function markdown (content) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "boost",
|
"name": "boost",
|
||||||
"version": "0.4.1-beta.3",
|
"version": "0.4.1-beta.4",
|
||||||
"description": "Boost App",
|
"description": "Boost App",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -40,6 +40,7 @@
|
|||||||
"devicon": "^2.0.0",
|
"devicon": "^2.0.0",
|
||||||
"font-awesome": "^4.3.0",
|
"font-awesome": "^4.3.0",
|
||||||
"fs-jetpack": "^0.7.0",
|
"fs-jetpack": "^0.7.0",
|
||||||
|
"highlight.js": "^8.9.1",
|
||||||
"lodash": "^3.10.1",
|
"lodash": "^3.10.1",
|
||||||
"markdown-it": "^4.3.1",
|
"markdown-it": "^4.3.1",
|
||||||
"md5": "^2.0.0",
|
"md5": "^2.0.0",
|
||||||
@@ -59,10 +60,9 @@
|
|||||||
"react-dom": "^0.14.0",
|
"react-dom": "^0.14.0",
|
||||||
"react-redux": "^4.0.0",
|
"react-redux": "^4.0.0",
|
||||||
"react-router": "^1.0.0-rc1",
|
"react-router": "^1.0.0-rc1",
|
||||||
"react-select": "^0.8.1",
|
|
||||||
"react-transform-catch-errors": "^1.0.0",
|
"react-transform-catch-errors": "^1.0.0",
|
||||||
"react-transform-hmr": "^1.0.1",
|
"react-transform-hmr": "^1.0.1",
|
||||||
"redbox-react": "^1.1.1",
|
"redbox-react": "^1.2.0",
|
||||||
"redux": "^3.0.2",
|
"redux": "^3.0.2",
|
||||||
"standard": "^5.3.1",
|
"standard": "^5.3.1",
|
||||||
"style-loader": "^0.12.4",
|
"style-loader": "^0.12.4",
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ var config = {
|
|||||||
'lodash',
|
'lodash',
|
||||||
'markdown-it',
|
'markdown-it',
|
||||||
'moment',
|
'moment',
|
||||||
'node-notifier'
|
'highlight.js'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ module.exports = {
|
|||||||
'lodash',
|
'lodash',
|
||||||
'markdown-it',
|
'markdown-it',
|
||||||
'moment',
|
'moment',
|
||||||
'node-notifier'
|
'highlight.js'
|
||||||
],
|
],
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['', '.js', '.jsx', 'styl']
|
extensions: ['', '.js', '.jsx', 'styl']
|
||||||
|
|||||||
Reference in New Issue
Block a user