fix md render
parent
3e540df657
commit
b7027ca779
|
@ -9224,6 +9224,15 @@
|
||||||
"uc.micro": "1.0.3"
|
"uc.micro": "1.0.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"markdown-it-anchor": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-4.0.0.tgz",
|
||||||
|
"integrity": "sha1-6H+1VD4BllrfcVBsa/ewSRhBt+M=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"string": "3.3.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"markdown-table": {
|
"markdown-table": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npm.taobao.org/markdown-table/download/markdown-table-1.1.1.tgz",
|
"resolved": "https://registry.npm.taobao.org/markdown-table/download/markdown-table-1.1.1.tgz",
|
||||||
|
@ -15464,6 +15473,12 @@
|
||||||
"integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=",
|
"integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"string": {
|
||||||
|
"version": "3.3.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/string/-/string-3.3.3.tgz",
|
||||||
|
"integrity": "sha1-XqIRzZLSKOGEKUmQpsyXs2anfLA=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"string-width": {
|
"string-width": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
|
||||||
|
|
|
@ -99,6 +99,7 @@
|
||||||
"less-loader": "^4.0.5",
|
"less-loader": "^4.0.5",
|
||||||
"less-plugin-npm-import": "^2.1.0",
|
"less-plugin-npm-import": "^2.1.0",
|
||||||
"markdown-it": "^8.4.0",
|
"markdown-it": "^8.4.0",
|
||||||
|
"markdown-it-anchor": "^4.0.0",
|
||||||
"marked": "^0.3.7",
|
"marked": "^0.3.7",
|
||||||
"merge2": "^1.2.1",
|
"merge2": "^1.2.1",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class='markdown api-container' id="component-api">
|
<div class='markdown api-container'>
|
||||||
<slot v-if="isZhCN" name="cn"></slot>
|
<slot v-if="isZhCN" name="cn"></slot>
|
||||||
<slot v-else></slot>
|
<slot v-else></slot>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -48,9 +48,9 @@ export default {
|
||||||
{lis}
|
{lis}
|
||||||
<li title='API' key='API'>
|
<li title='API' key='API'>
|
||||||
<a
|
<a
|
||||||
href='#component-api'
|
href='#api'
|
||||||
class={{
|
class={{
|
||||||
current: window.location.hash === '#component-api',
|
current: window.location.hash === '#api',
|
||||||
}}
|
}}
|
||||||
>API</a>
|
>API</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -53,12 +53,11 @@ export default {
|
||||||
`not have usTitle`,
|
`not have usTitle`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const component = this.$slots.component[0]
|
let id = ['components', name.replace('-cn', ''), 'demo', ...usTitle.split(' ')].join('-').toLowerCase()
|
||||||
const fileName = (component.context.$vnode.componentOptions.Ctor.extendOptions.__file.split('/demo/')[1] || '').replace('.md', '')
|
|
||||||
const id = ['components', name.replace('-cn', ''), 'demo', fileName].join('-').toLowerCase()
|
|
||||||
console.log(fileName)
|
|
||||||
if (this._store.store) {
|
if (this._store.store) {
|
||||||
const { currentSubMenu } = this._store.store.getState()
|
const { currentSubMenu } = this._store.store.getState()
|
||||||
|
id = `${id}-${currentSubMenu.length + 1}`
|
||||||
this._store.store.setState({ currentSubMenu: [...currentSubMenu, { cnTitle, usTitle, id }] })
|
this._store.store.setState({ currentSubMenu: [...currentSubMenu, { cnTitle, usTitle, id }] })
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -4,8 +4,20 @@
|
||||||
<script>
|
<script>
|
||||||
import marked from 'marked'
|
import marked from 'marked'
|
||||||
import { isZhCN } from '../util'
|
import { isZhCN } from '../util'
|
||||||
|
var renderer = new marked.Renderer();
|
||||||
|
renderer.heading = function(text, level) {
|
||||||
|
return '<h'
|
||||||
|
+ level
|
||||||
|
+ ' id="'
|
||||||
|
+ text.replace(/[^\w]+/g, '-')
|
||||||
|
+ '">'
|
||||||
|
+ text
|
||||||
|
+ '</h'
|
||||||
|
+ level
|
||||||
|
+ '>\n';
|
||||||
|
};
|
||||||
marked.setOptions({
|
marked.setOptions({
|
||||||
renderer: new marked.Renderer(),
|
renderer,
|
||||||
gfm: true,
|
gfm: true,
|
||||||
tables: true,
|
tables: true,
|
||||||
breaks: true,
|
breaks: true,
|
||||||
|
|
|
@ -45,6 +45,14 @@ const md = require('markdown-it')('default', {
|
||||||
html: true,
|
html: true,
|
||||||
breaks: true,
|
breaks: true,
|
||||||
highlight: renderHighlight,
|
highlight: renderHighlight,
|
||||||
|
}).use(require('markdown-it-anchor'), {
|
||||||
|
level: 2,
|
||||||
|
// slugify: string => string,
|
||||||
|
permalink: true,
|
||||||
|
// renderPermalink: (slug, opts, state, permalink) => {},
|
||||||
|
permalinkClass: 'anchor',
|
||||||
|
permalinkSymbol: '#',
|
||||||
|
permalinkBefore: false,
|
||||||
})
|
})
|
||||||
// md.renderer.rules.fence = wrap(md.renderer.rules.fence)
|
// md.renderer.rules.fence = wrap(md.renderer.rules.fence)
|
||||||
const cnReg = new RegExp('<(cn)(?:[^<]|<)+</\\1>', 'g')
|
const cnReg = new RegExp('<(cn)(?:[^<]|<)+</\\1>', 'g')
|
||||||
|
|
Loading…
Reference in New Issue