當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript showdown.Converter類代碼示例

本文整理匯總了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;未經允許,請勿轉載。