本文整理汇总了TypeScript中marked类的典型用法代码示例。如果您正苦于以下问题:TypeScript marked类的具体用法?TypeScript marked怎么用?TypeScript marked使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了marked类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: transform
transform(markdown: string): string {
return marked(markdown || "", {
highlight: function (code: string, lang: string): string {
return hljs.highlightAuto(code).value;
}
});
}
开发者ID:g0tsimid,项目名称:cross-point,代码行数:7,代码来源:markdown.pipe.ts
示例2: parseRaw
const parseEntry = (
entryDir: string,
entryId: EntryId,
parseRaw: (entryDir: string, entryId: EntryId) => RawEntry,
options: { noIds: boolean; }
): Entry => {
const { meta, data } = parseRaw(entryDir, entryId);
if (typeof meta.minutes === 'undefined') {
throw new Error('minutes is not defined');
}
if (typeof meta.pubdate === 'undefined') {
throw new Error('pubdate is not defined');
}
if (typeof meta.title === 'undefined') {
throw new Error('title is not defined');
}
const minutes = meta.minutes as number;
const pubdate = meta.pubdate as string;
const tags = (typeof meta.tags === 'undefined' ? [] : meta.tags) as string[];
const title = meta.title as string;
const date = toISOString(inTimeZone(parseISOString(pubdate), '+09:00'))
.substring(0, '2006-01-02'.length);
const renderer = new marked.Renderer();
if (options.noIds) {
renderer.heading = (text, level) => `<h${level}>${text}</h${level}>\n`;
}
const html = marked(data, { renderer });
const entry = {
id: entryId, data, date, html, minutes, pubdate, tags, title
};
return entry;
};
开发者ID:bouzuya,项目名称:kraken,代码行数:32,代码来源:base.ts
示例3: createData
export async function createData(
projectPackage: any,
graphdocPackage: any,
plugins: PluginInterface[],
type?: TypeRef
): Promise<TemplateData> {
const name = type && type.name;
const [headers, navigations, documents]: [Headers, Navs, Docs] = await Promise.all([
Plugin.collectHeaders(plugins, name),
Plugin.collectNavigations(plugins, name),
Plugin.collectDocuments(plugins, name),
]);
const title = name ||
projectPackage.graphdoc.title ||
'Graphql schema documentation';
const description = type ?
marked(type.description || '') :
projectPackage.description;
return {
title,
type,
description,
headers: headers.join(''),
navigations,
documents,
projectPackage,
graphdocPackage,
slug: slugTemplate
};
}
开发者ID:2fd,项目名称:graphdoc,代码行数:34,代码来源:template.ts
示例4: renderViewerContent
function renderViewerContent(files, selectedFile) {
const bodyMarkdown = marked(commit.body, { gfm: true, breaks: true });
$viewer.append(Mustache.render(historyViewerTemplate, {
commit,
bodyMarkdown,
usePicture: avatarType === "PICTURE",
useIdenticon: avatarType === "IDENTICON",
useBwAvatar: avatarType === "AVATAR_BW",
useColoredAvatar: avatarType === "AVATAR_COLOR",
Strings,
enableAdvancedFeatures
}));
renderFiles(files);
if (selectedFile) {
const $fileEntry = $viewer.find(".commit-files li[x-file='" + selectedFile + "'] a").first();
if ($fileEntry.length) {
toggleDiff($fileEntry);
window.setTimeout(() => {
$viewer.find(".body").animate({ scrollTop: $fileEntry.position().top - 10 });
}, 80);
}
}
attachEvents();
}
开发者ID:MarcelGerber,项目名称:brackets-git,代码行数:28,代码来源:HistoryViewer.ts
示例5: packages
export default function packages(state = initialState["packages"], action) {
switch (action.type) {
case actionTypes.CLEAR_PACKAGES:
return state.set("current", Package()).
set("nextRange", 0).
set("visible", List()).
set("totalCount", 0).
setIn(["ui", "current", "loading"], true).
setIn(["ui", "current", "exists"], false).
setIn(["ui", "visible", "loading"], true).
setIn(["ui", "visible", "exists"], false);
case actionTypes.POPULATE_EXPLORE:
return state.setIn(["explore"], List(action.payload));
case actionTypes.SET_CURRENT_PACKAGE:
if (action.error) {
return state.set("current", Package()).
setIn(["ui", "current", "errorMessage"],
action.error.message).
setIn(["ui", "current", "loading"], false).
setIn(["ui", "current", "exists"], false);
} else {
let p = Object.assign({}, action.payload);
p.manifest = marked(p.manifest);
return state.set("current", Package(p)).
setIn(["ui", "current", "errorMessage"], undefined).
setIn(["ui", "current", "exists"], true).
setIn(["ui", "current", "loading"], false);
}
case actionTypes.SET_PACKAGES_NEXT_RANGE:
return state.set("nextRange", action.payload);
case actionTypes.SET_PACKAGES_SEARCH_QUERY:
return state.set("searchQuery", action.payload);
case actionTypes.SET_PACKAGES_TOTAL_COUNT:
return state.set("totalCount", action.payload);
case actionTypes.SET_VISIBLE_PACKAGES:
if (action.error) {
return state.set("visible", List()).
setIn(["ui", "visible", "errorMessage"],
action.error.message).
setIn(["ui", "visible", "exists"], false).
setIn(["ui", "visible", "loading"], false);
} else {
return state.set("visible",
state.get("visible").concat(List(action.payload))).
setIn(["ui", "visible", "errorMessage"], undefined).
setIn(["ui", "visible", "exists"], true).
setIn(["ui", "visible", "loading"], false);
}
default:
return state;
}
}
开发者ID:MikeTLive,项目名称:habitat,代码行数:59,代码来源:packages.ts
示例6: it
it('should handle escaping', () => {
const source = 'I\'ve used to use "Š" charachters';
const expected = marked(source, {
smartypants: true
}).trim();
const html = renderToStaticMarkup(source);
expect(html).toContain(expected);
});
开发者ID:valotas,项目名称:valotas.com,代码行数:8,代码来源:createComponentTree.spec.ts
示例7: markdown
function markdown(input: Buffer, options: MarkdownOptions, callback: TransformCallback) {
const input_string = input.toString('utf8');
marked(input_string, options, (error: Error, output_string: string) => {
if (error) return callback(error);
const output = new Buffer(output_string, 'utf8');
callback(null, output);
});
}
开发者ID:chbrown,项目名称:fapply,代码行数:8,代码来源:applicators.ts
注:本文中的marked类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论