')
.replace('', '')
}
};
const md = require('markdown-it')('default', {
html: true,
breaks: true,
highlight: renderHighlight,
})
md.use(require('markdown-it-anchor'), {
level: 2,
slugify: slugify,
permalink: true,
permalinkBefore: true,
}).use(require('markdown-it-container'), 'demo', {
validate: function (params) {
return params.trim().match(/^demo\s*(.*)$/)
},
render: function (tokens, idx) {
if (tokens[idx].nesting === 1) {
const summaryContent = tokens[idx + 1].content
const summary = fetch(summaryContent, 'summary')
const summaryHTML = summary ? md.render(summary) : ''
const content = tokens[idx + 2].content
const html = fetch(content, 'template')
const script = fetch(content, 'script') || ''
const style = fetch(content, 'style') || ''
const code = tokens[idx + 2].markup + tokens[idx + 2].info + '\n' + content + tokens[idx + 2].markup
const codeHtml = code ? md.render(code) : ''
let jsfiddle = { html: html, script: script, style: style }
jsfiddle = md.utils.escapeHtml(JSON.stringify(jsfiddle))
// opening tag
return `
${html}
${summaryHTML}
${codeHtml}
`
} else {
return '\n'
}
},
})
md.renderer.rules.table_open = function () {
return '
'
}
md.renderer.rules.fence = wrap(md.renderer.rules.fence)
module.exports = {
entry: {
index: [
'./examples/index.js',
],
},
module: {
rules: [
{
test: /\.md/,
use: [
{
loader: 'vue-markdown-loader',
options: Object.assign(md, { wrapper: 'section', preventExtract: true }),
},
],
},
{
test: /\.vue$/,
loader: 'vue-loader',
},
{
test: /\.js$/,
loader: 'babel-loader', exclude: /node_modules/,
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]',
},
},
],
},
resolve: {
extensions: ['.js', '.vue'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'antd': path.join(__dirname, 'components'),
},
},
}