mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-11-29 18:48:32 +08:00
doc: update md plugin
This commit is contained in:
parent
b07882d92f
commit
3a141b2e9b
@ -13,7 +13,6 @@ title:
|
||||
## en-US
|
||||
|
||||
Read only, can't use mouse to interact.
|
||||
|
||||
</docs>
|
||||
<template>
|
||||
<a-rate :value="2" disabled />
|
||||
|
@ -19,10 +19,10 @@ Using this component, you can smoothly scroll through 100,000 rows and 100,000 c
|
||||
</docs>
|
||||
|
||||
<template>
|
||||
<iframe src="https://www.surely.cool/for-ant-demo" height="400" />
|
||||
<iframe src="https://www.surely.cool/for-ant-demo" height="400"></iframe>
|
||||
<div v-if="false">
|
||||
you can visit
|
||||
<a href="https://www.surely.cool" />
|
||||
<a href="https://www.surely.cool"></a>
|
||||
get more info
|
||||
</div>
|
||||
</template>
|
||||
|
@ -30,7 +30,7 @@ function createContainer(klass: string, defaultTitle: string): ContainerArgs {
|
||||
{
|
||||
render(tokens, idx) {
|
||||
const token = tokens[idx];
|
||||
const info = token.info.trim().slice(klass.length)?.trim();
|
||||
const info = token.info?.trim().slice(klass.length)?.trim();
|
||||
if (token.nesting === 1) {
|
||||
return `<div class="${klass} custom-block"><p class="custom-block-title">${
|
||||
info || defaultTitle
|
||||
|
@ -7,7 +7,7 @@ export const hoistPlugin = (md: MarkdownIt) => {
|
||||
const RE = /^<(script|style)(?=(\s|>|$))/i;
|
||||
|
||||
md.renderer.rules.html_block = (tokens, idx) => {
|
||||
const content = tokens[idx].content;
|
||||
const content = tokens[idx].content || '';
|
||||
const data = (md as any).__data as MarkdownParsedData;
|
||||
const hoistedTags = data.hoistedTags || (data.hoistedTags = []);
|
||||
if (RE.test(content.trim())) {
|
||||
|
@ -16,10 +16,13 @@ export const preWrapperPlugin = (md: MarkdownIt) => {
|
||||
const [tokens, idx] = args;
|
||||
const token = tokens[idx];
|
||||
const data = (md as any).__data as MarkdownParsedData;
|
||||
if (token.info.trim() === 'vue') {
|
||||
if (token.info?.trim() === 'vue') {
|
||||
data.vueCode = token.content;
|
||||
}
|
||||
const rawCode = fence(...args).replace(/<pre /g, `<pre class="language-${token.info.trim()}" `);
|
||||
const rawCode = fence(...args).replace(
|
||||
/<pre /g,
|
||||
`<pre class="language-${token.info?.trim()}" `,
|
||||
);
|
||||
return rawCode; //`<div class="language-${token.info.trim()}">${rawCode}</div>`;
|
||||
};
|
||||
};
|
||||
|
@ -25,7 +25,7 @@ export const snippetPlugin = (md: MarkdownIt, root: string) => {
|
||||
const start = pos + 3;
|
||||
const end = state.skipSpacesBack(max, pos);
|
||||
const rawPath = state.src.slice(start, end)?.trim().replace(/^@/, root);
|
||||
const filename = rawPath.split(/{/).shift()!.trim();
|
||||
const filename = rawPath.split(/{/).shift()?.trim();
|
||||
const content = fs.existsSync(filename)
|
||||
? fs.readFileSync(filename).toString()
|
||||
: 'Not found: ' + filename;
|
||||
|
@ -69,7 +69,7 @@ ${fetchCode(content, 'style')}
|
||||
|
||||
debug(`[render] ${file} in ${Date.now() - start}ms.`);
|
||||
const result = {
|
||||
vueSrc: newContent.trim(),
|
||||
vueSrc: newContent?.trim(),
|
||||
pageData,
|
||||
};
|
||||
cache.set(src, result);
|
||||
@ -91,7 +91,7 @@ ${vueCode?.trim()}
|
||||
const script = fetchCode(vueCode, 'script');
|
||||
const style = fetchCode(vueCode, 'style');
|
||||
const scriptContent = fetchCode(vueCode, 'scriptContent');
|
||||
let jsCode = (await tsToJs(scriptContent)).trim();
|
||||
let jsCode = (await tsToJs(scriptContent))?.trim();
|
||||
jsCode = jsCode
|
||||
? `<script>
|
||||
${jsCode}
|
||||
@ -146,7 +146,7 @@ const inferTitle = (frontmatter: any, content: string) => {
|
||||
}
|
||||
const match = content.match(/^\s*#+\s+(.*)/m);
|
||||
if (match) {
|
||||
return deeplyParseHeader(match[1].trim());
|
||||
return deeplyParseHeader(match[1]?.trim());
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
@ -31,7 +31,7 @@ const removeMarkdownTokens = (str: string) =>
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
.replace(/(\\)(\*|_|`|\!|<|\$)/g, '$2'); // remove escape char '\'
|
||||
|
||||
const trim = (str: string) => str.trim();
|
||||
const trim = (str = '') => str?.trim();
|
||||
|
||||
// This method remove the raw HTML but reserve the HTML wrapped by `<code>`.
|
||||
// e.g.
|
||||
|
Loading…
Reference in New Issue
Block a user