diff --git a/.browserslistrc b/.browserslistrc new file mode 100644 index 0000000..d6471a3 --- /dev/null +++ b/.browserslistrc @@ -0,0 +1,2 @@ +> 1% +last 2 versions diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a1879fc --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +[*.{js,jsx,ts,tsx,vue}] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..350ab51 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +*.js +*.vue \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..49c2e6d --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,30 @@ +module.exports = { + root: true, + env: { + node: true + }, + 'extends': [ + 'plugin:vue/essential', + '@vue/standard' + ], + rules: { + 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', + 'camelcase': 'off', + 'eqeqeq': 'off' + }, + parserOptions: { + parser: 'babel-eslint' + }, + overrides: [ + { + files: [ + '**/__tests__/*.{j,t}s?(x)', + '**/tests/unit/**/*.spec.{j,t}s?(x)' + ], + env: { + jest: true + } + } + ] +} diff --git a/.gitignore b/.gitignore index f19d995..38c2810 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,19 @@ yarn-error.log* dist package-lock.json -lib \ No newline at end of file +lib + +node_modules + +# Log files +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Editor directories and files +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? \ No newline at end of file diff --git a/README.md b/README.md index 1c4eb75..18f4f50 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@
扫码关注我的公众号,原创技术文章第一时间推送!
- -扫码关注我的公众号,原创技术文章第一时间推送!
+ +[${x[0]}]
: ${x[1]}[${x[0]}]
${x[1]}: ${x[2]}${footnoteArray.join('\n')}
` + } + + this.buildAddition = () => { + return ` + + ` + } + + this.setOptions = newOpts => { + this.opts = merge(this.opts, newOpts) + } + + this.hasFootnotes = () => footnotes.length !== 0 + + this.getRenderer = (status) => { + footnotes = [] + footnoteIndex = 0 + + styleMapping = this.buildTheme(this.opts.theme) + let renderer = new marked.Renderer() + + renderer.heading = (text, level) => { + switch (level) { + case 1: + return `${text}
` + + renderer.blockquote = text => { + text = text.replace(/`) + return `
${text}` + } + renderer.code = (text, infoString) => { + text = text.replace(//g, '>') + + let lines = text.split('\n') + let codeLines = [] + let numbers = [] + + for (let i = 0; i < lines.length; i++) { + const line = lines[i] + codeLines.push(`
${(line || '
')}
`)
+ numbers.push('')
+ }
+ let lang = infoString || ''
+
+ return `
+ + ${codeLines.join('')} ++
${text}
`
+ renderer.listitem = text => `<%s/>${text}`
+
+ renderer.list = (text, ordered, start) => {
+ text = text.replace(/<\/*p.*?>/g, '')
+ let segments = text.split(`<%s/>`)
+ if (!ordered) {
+ text = segments.join('•')
+ return `${text}
` + } + text = segments[0] + for (let i = 1; i < segments.length; i++) { + text = text + i + '.' + segments[i] + } + return `${text}
` + } + renderer.image = (href, title, text) => { + let subText = '' + if (text) { + subText = `${text}
` + renderer.table = (header, body) => `