vue-md-loader
Advanced tools
Comparing version 1.1.10 to 2.0.0
@@ -5,11 +5,12 @@ { | ||
], | ||
"labels": [ | ||
"dependencies" | ||
], | ||
"assignees": [ | ||
"wxsms" | ||
], | ||
"reviewers": [ | ||
"wxsms" | ||
"packageRules": [ | ||
{ | ||
"matchUpdateTypes": [ | ||
"minor", | ||
"patch" | ||
], | ||
"matchCurrentVersion": "!/^0/", | ||
"automerge": true | ||
} | ||
] | ||
} |
{ | ||
"name": "vue-md-loader", | ||
"version": "1.1.10", | ||
"version": "2.0.0", | ||
"description": "Webpack loader for converting Markdown files to ALIVE Vue components.", | ||
@@ -14,5 +14,6 @@ "main": "index.js", | ||
"scripts": { | ||
"dev:example": "cd example && cross-env NODE_ENV=development webpack-dev-server --hot --inline --port 8888", | ||
"dev:example": "cd example && cross-env NODE_ENV=development webpack-dev-server --hot --port 8888 --static .", | ||
"build:example": "cd example && cross-env NODE_ENV=production webpack", | ||
"lint": "eslint --ext .js,.vue --config .eslintrc.js index.js src example", | ||
"lint:fix": "npm run lint -- --fix", | ||
"test": "nyc mocha", | ||
@@ -42,3 +43,3 @@ "coveralls": "cat test/coverage/lcov.info | ./node_modules/.bin/coveralls" | ||
"devDependencies": { | ||
"@babel/preset-env": "7.14.8", | ||
"@babel/preset-env": "7.15.0", | ||
"babel-core": "6.26.3", | ||
@@ -51,23 +52,24 @@ "babel-eslint": "10.1.0", | ||
"cross-env": "7.0.3", | ||
"css-loader": "5.2.7", | ||
"eslint": "7.31.0", | ||
"eslint-config-standard": "16.0.3", | ||
"css-loader": "6.2.0", | ||
"eslint": "7.32.0", | ||
"eslint-config-prettier": "8.3.0", | ||
"eslint-loader": "4.0.2", | ||
"eslint-plugin-html": "6.1.2", | ||
"eslint-plugin-import": "2.23.4", | ||
"eslint-plugin-import": "2.24.1", | ||
"eslint-plugin-mocha": "9.0.0", | ||
"eslint-plugin-node": "11.1.0", | ||
"eslint-plugin-prettier": "3.4.1", | ||
"eslint-plugin-promise": "5.1.0", | ||
"eslint-plugin-standard": "5.0.0", | ||
"eslint-plugin-vue": "7.14.0", | ||
"eslint-plugin-vue": "7.16.0", | ||
"markdown-it-anchor": "8.1.2", | ||
"mocha": "9.0.3", | ||
"mocha": "9.1.0", | ||
"nyc": "15.1.0", | ||
"style-loader": "2.0.0", | ||
"prettier": "2.3.2", | ||
"style-loader": "3.2.1", | ||
"vue": "2.6.14", | ||
"vue-loader": "15.9.7", | ||
"vue-loader": "15.9.8", | ||
"vue-template-compiler": "2.6.14", | ||
"webpack": "4.46.0", | ||
"webpack-cli": "4.7.2", | ||
"webpack-dev-server": "3.11.2" | ||
"webpack": "5.51.1", | ||
"webpack-cli": "4.8.0", | ||
"webpack-dev-server": "4.0.0" | ||
}, | ||
@@ -74,0 +76,0 @@ "dependencies": { |
@@ -167,3 +167,3 @@ # vue-md-loader | ||
try { | ||
return hljs.highlight(lang, str).value | ||
return hljs.highlight(str, { language: lang }).value | ||
} catch (__) {} | ||
@@ -170,0 +170,0 @@ } |
@@ -10,3 +10,3 @@ const MarkdownIt = require('markdown-it') | ||
try { | ||
return hljs.highlight(lang, str).value | ||
return hljs.highlight(str, { language: lang }).value | ||
} catch (err) { | ||
@@ -17,3 +17,3 @@ // ignore | ||
return '' // use external default escaping | ||
} | ||
}, | ||
} | ||
@@ -31,3 +31,5 @@ | ||
rendererRules[rule] = function () { | ||
return saved.apply(this, arguments).replace(/(<pre|<code)/g, '$1 v-pre') | ||
return saved | ||
.apply(this, arguments) | ||
.replace(/(<pre|<code)/g, '$1 v-pre') | ||
} | ||
@@ -39,3 +41,3 @@ } | ||
function Parser (_options) { | ||
function Parser(_options) { | ||
// default options | ||
@@ -52,3 +54,3 @@ const defaultOptions = { | ||
process: null, | ||
afterProcess: null | ||
afterProcess: null, | ||
} | ||
@@ -75,3 +77,3 @@ // merge user options into defaults | ||
if (this.options.plugins && this.options.plugins.length) { | ||
this.options.plugins.forEach(p => { | ||
this.options.plugins.forEach((p) => { | ||
if (Array.isArray(p)) { | ||
@@ -100,3 +102,3 @@ if (p[0]) { | ||
Parser.prototype.fetchLives = function () { | ||
const PRE_REGEX = /```.*?[\n\r]([\S\s]+?)[\n\r]```/igm | ||
const PRE_REGEX = /```.*?[\n\r]([\S\s]+?)[\n\r]```/gim | ||
this.lives = [] | ||
@@ -120,3 +122,3 @@ let live = null | ||
Parser.prototype.fetchLiveTemplates = function () { | ||
this.lives.forEach(live => { | ||
this.lives.forEach((live) => { | ||
// greedy | ||
@@ -132,3 +134,6 @@ let template = /<template>([\s\S]*)<\/template>/.exec(live[1]) | ||
// Wrap it by options | ||
if (this.options.afterProcessLiveTemplate && typeof this.options.afterProcessLiveTemplate === 'function') { | ||
if ( | ||
this.options.afterProcessLiveTemplate && | ||
typeof this.options.afterProcessLiveTemplate === 'function' | ||
) { | ||
template = this.options.afterProcessLiveTemplate(template) | ||
@@ -142,3 +147,3 @@ } | ||
Parser.prototype.fetchLiveScripts = function () { | ||
this.lives.forEach(live => { | ||
this.lives.forEach((live) => { | ||
// mount script inside live block | ||
@@ -150,3 +155,3 @@ live._script = /<script.*?>([\S\s]+?)<\/script>/.exec(live[1]) | ||
Parser.prototype.fetchLiveStyles = function () { | ||
this.lives.forEach(live => { | ||
this.lives.forEach((live) => { | ||
// mount style inside live block | ||
@@ -165,3 +170,3 @@ live._style = /<style.*?>([\S\s]+?)<\/style>/.exec(live[1]) | ||
style: style, | ||
template: template | ||
template: template, | ||
} | ||
@@ -179,5 +184,7 @@ } | ||
template.slice(0, live.index) + | ||
NEW_LINE + NEW_LINE + | ||
NEW_LINE + | ||
NEW_LINE + | ||
_template + | ||
NEW_LINE + NEW_LINE + | ||
NEW_LINE + | ||
NEW_LINE + | ||
template.slice(live.index) | ||
@@ -190,3 +197,3 @@ } | ||
let style = '' | ||
this.lives.forEach(live => { | ||
this.lives.forEach((live) => { | ||
style += live._style ? live._style[0] : '' | ||
@@ -214,3 +221,5 @@ }) | ||
// Get "template": "......" | ||
const _template = /^{([\s\S]*?)}$/.exec(JSON.stringify({ template: live._template })) | ||
const _template = /^{([\s\S]*?)}$/.exec( | ||
JSON.stringify({ template: live._template }) | ||
) | ||
if (_template) { | ||
@@ -224,3 +233,3 @@ componentOptions = componentOptions ? `,${componentOptions[1]}` : '' | ||
exports = `export default {components:{${exports}}}` | ||
beforeExports.forEach(code => { | ||
beforeExports.forEach((code) => { | ||
script += code + NEW_LINE | ||
@@ -236,3 +245,6 @@ }) | ||
this.source = source | ||
if (this.options.preProcess && typeof this.options.preProcess === 'function') { | ||
if ( | ||
this.options.preProcess && | ||
typeof this.options.preProcess === 'function' | ||
) { | ||
this.source = this.options.preProcess(this.source) | ||
@@ -246,7 +258,12 @@ } | ||
} else { | ||
result = this.options.live ? this.parseLives() : { template: this.source, script: '', style: '' } | ||
result = this.options.live | ||
? this.parseLives() | ||
: { template: this.source, script: '', style: '' } | ||
} | ||
const html = this.markdown.render(result.template) | ||
let vueFile = `<template><${this.options.wrapper}>${html}</${this.options.wrapper}></template>${result.style}${result.script}` | ||
if (this.options.afterProcess && typeof this.options.afterProcess === 'function') { | ||
if ( | ||
this.options.afterProcess && | ||
typeof this.options.afterProcess === 'function' | ||
) { | ||
vueFile = this.options.afterProcess(vueFile) | ||
@@ -253,0 +270,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21023
13
263
30