本文整理汇总了TypeScript中showdown.Converter类的典型用法代码示例。如果您正苦于以下问题:TypeScript Converter类的具体用法?TypeScript Converter怎么用?TypeScript Converter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Converter类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: async
const upload = async (ctx) => {
try {
const { path, originalname } = ctx.req.file;
let name = originalname.split('.');
let blog = await Blog.repositry.findOne({ url: name[0] });
if (blog) {
throw { message: "Blog Existed" };
}
let data = await getFileData(path);
let markdown = data.toString()
let converter = new showdown.Converter();
converter.setOption('noHeaderId', 'true');
await fs.unlinkSync(path);
ctx.body = {
success: true,
data: {
name: name[0],
html: converter.makeHtml(markdown),
markdown: markdown
}
}
} catch (error) {
ctx.status = 500;
ctx.body = error.message;
}
}
开发者ID:Bill0106,项目名称:MySite,代码行数:27,代码来源:blog.controller.ts
示例2: genVars
router.get('/*/*', async ctx => {
const lang = ctx.params[0];
const doc = ctx.params[1];
showdown.extension('urlExtension', () => ({
type: 'output',
regex: /%URL%/g,
replace: config.url
}));
showdown.extension('apiUrlExtension', () => ({
type: 'output',
regex: /%API_URL%/g,
replace: config.api_url
}));
const conv = new showdown.Converter({
tables: true,
extensions: ['urlExtension', 'apiUrlExtension', 'highlightjs']
});
const md = fs.readFileSync(`${__dirname}/../../../src/docs/${doc}.${lang}.md`, 'utf8');
await ctx.render('../../../../src/docs/article', Object.assign({
id: doc,
html: conv.makeHtml(md),
title: md.match(/^# (.+?)\r?\n/)[1],
src: `https://github.com/syuilo/misskey/tree/master/src/docs/${doc}.${lang}.md`
}, await genVars(lang)));
});
开发者ID:ha-dai,项目名称:Misskey,代码行数:29,代码来源:docs.ts
示例3: getMarkdownConverter
static getMarkdownConverter(): Converter {
let c = new Converter();
c.setOption('openLinksInNewWindow', 'true');
c.setOption('simplifiedAutoLink', 'true');
c.setOption('excludeTrailingPunctuationFromURLs ', 'true');
return c;
}
开发者ID:ShauvonM,项目名称:improvdatabase,代码行数:9,代码来源:text.util.ts
示例4: getHtml
export function getHtml(markdownFilePath: string): string {
var showdown = require('showdown'),
converter = new showdown.Converter()
//let markdownFilePath = Path.join(IntoCpsApp.getInstance().getActiveProject().getRootFilePath(), "Readme.md");
if (fs.existsSync(markdownFilePath)) {
var text = "" + fs.readFileSync(markdownFilePath);
text = text.split("](").join("](" + IntoCpsApp.getInstance().getActiveProject().getRootFilePath() + "/")
let html = converter.makeHtml(text);
return html;
}
return null;
}
开发者ID:into-cps,项目名称:intocps-ui,代码行数:14,代码来源:showdownHelper.ts
示例5: transform
transform(markup: string) {
let converter = new showdown.Converter();
return converter.makeHtml(markup);
}
开发者ID:akotsar,项目名称:buggy,代码行数:4,代码来源:showdown.pipe.ts
示例6: async
const getPost = async (posts: any[], slug: string): Promise<any> => {
const postData = posts.find((post) => post.slug === slug);
if (!postData) {
return {
error: true,
};
}
try {
const articlePath: string = path.resolve(POSTS_DIR, postData.path, "article.md");
const entry: string = await fs.readFile(articlePath, "utf-8");
return {
...postData,
entry: converter.makeHtml(entry),
};
} catch (error) {
if (postData.url) {
return {
redirect: postData.url,
};
}
}
};
开发者ID:drublic,项目名称:vc,代码行数:25,代码来源:getPost.ts
示例7:
textChanged(newValue: string) {
if (newValue) {
this.element.innerHTML = this.converter.makeHtml(newValue);
PR.prettyPrint();
} else {
this.element.innerHTML = "";
}
}
开发者ID:HIRANO-Satoshi,项目名称:demo-materialize,代码行数:8,代码来源:au-markdown.ts
示例8: async
const getPost = async (postPath: string): Promise<any> => {
const postDataPath: string = path.resolve(POSTS_DIR, postPath, "data.json");
try {
const postData: string = await fs.readFile(postDataPath, "utf-8");
const post = JSON.parse(postData);
return {
...post,
abstract: converter.makeHtml(post.abstract),
slug: postPath.split("-").splice(1).join("-"),
path: postPath,
};
} catch (error) {
console.error(error);
}
return null;
};
开发者ID:drublic,项目名称:vc,代码行数:19,代码来源:getPosts.ts
示例9: convertAndSanitizeMarkdown
export function convertAndSanitizeMarkdown(markdown: string) {
const html = converter.makeHtml(markdown);
const sanitized = DOMPurify.sanitize(html);
return sanitized;
}
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:6,代码来源:utils.ts
注:本文中的showdown.Converter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论