build: release v1.3.6

* 微信代码块CSS样式美化调整
* JavaScript代码优化
This commit is contained in:
yanglbme 2020-07-29 22:37:44 +08:00
parent 27b8fe99b0
commit 7eb8e99be5
2 changed files with 12 additions and 27 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "vue-md", "name": "vue-md",
"version": "1.3.5", "version": "1.3.6",
"private": true, "private": true,
"homepage": "https://doocs.gitee.io/md", "homepage": "https://doocs.gitee.io/md",
"scripts": { "scripts": {

View File

@ -123,30 +123,19 @@ const WxRenderer = function (opts) {
text = text.replace(/<p.*?>/g, `<p ${getStyles('blockquote_p')}>`) text = text.replace(/<p.*?>/g, `<p ${getStyles('blockquote_p')}>`)
return `<blockquote ${getStyles('blockquote')}>${text}</blockquote>` return `<blockquote ${getStyles('blockquote')}>${text}</blockquote>`
} }
renderer.code = (text, infoString) => { renderer.code = (text, lang) => {
text = text.replace(/</g, '&lt;') text = text.replace(/</g, '&lt;').replace(/>/g, '&gt;')
text = text.replace(/>/g, '&gt;') const codeLines = text.split('\n').map(line => `<code class="prettyprint"><span class="code-snippet_outer">${(line || '<br>')}</span></code>`)
const codeTheme = 'github'
let lines = text.split('\n')
let codeLines = []
let numbers = []
for (let i = 0; i < lines.length; i++) {
const line = lines[i]
codeLines.push(`<code class="prettyprint"><span class="code-snippet_outer">${(line || '<br>')}</span></code>`)
numbers.push('<li></li>')
}
const lang = infoString || '';
const codeTheme = 'github';
return ` return `
<section class="code-snippet__${codeTheme}"> <section class="code-snippet__${codeTheme}">
<pre class="code__pre" data-lang="${lang}"> <pre class="code__pre" data-lang="${lang}">
${codeLines.join('')} ${codeLines.join('')}
</pre> </pre>
</section> </section>
`; `
} }
renderer.codespan = (text, infoString) => `<code ${getStyles('codespan')}>${text}</code>` renderer.codespan = (text, lang) => `<code ${getStyles('codespan')}>${text}</code>`
renderer.listitem = text => `<span ${getStyles('listitem')}><span style="margin-right: 10px;"><%s/></span>${text}</span>` renderer.listitem = text => `<span ${getStyles('listitem')}><span style="margin-right: 10px;"><%s/></span>${text}</span>`
renderer.list = (text, ordered, start) => { renderer.list = (text, ordered, start) => {
@ -174,16 +163,12 @@ const WxRenderer = function (opts) {
renderer.link = (href, title, text) => { renderer.link = (href, title, text) => {
if (href.indexOf('https://mp.weixin.qq.com') === 0) { if (href.indexOf('https://mp.weixin.qq.com') === 0) {
return `<a href="${href}" title="${(title || text)}" ${getStyles('wx_link')}>${text}</a>` return `<a href="${href}" title="${(title || text)}" ${getStyles('wx_link')}>${text}</a>`
} else if (href === text) { }
if (href === text || !status) {
return text return text
} else { }
if (status) {
let ref = addFootnote(title || text, href) let ref = addFootnote(title || text, href)
return `<span ${getStyles('link')}>${text}<sup>[${ref}]</sup></span>` return `<span ${getStyles('link')}>${text}<sup>[${ref}]</sup></span>`
} else {
return text
}
}
} }
renderer.strong = text => `<strong ${getStyles('strong')}>${text}</strong>` renderer.strong = text => `<strong ${getStyles('strong')}>${text}</strong>`
renderer.em = text => `<span style="font-style: italic;">${text}</span>` renderer.em = text => `<span style="font-style: italic;">${text}</span>`