本文整理汇总了TypeScript中remark.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript remark.default方法的具体用法?TypeScript remark.default怎么用?TypeScript remark.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类remark
的用法示例。
在下文中一共展示了remark.default方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: remark
indexArray.forEach(element => {
let tutData = { link: element["file"] };
let tutFile = path.resolve(tutFolder, element["file"]);
let tutFileText = fs.readFileSync(tutFile, "utf8");
let tutMD = remark().use(frontMatter, ["yaml"]).parse(tutFileText);
let metadata = getDocMetadata(tutMD);
if (metadata["Level"]){
tutData["level"] = metadata["Level"];
} else {
tutData["level"] = "";
}
let briefDesc = getFirstParagraph(tutMD);
let briefDescText = remark()
.use(frontMatter, {type: 'yaml', fence: '---'})
.data("settings", {paddedTable: false, gfm: false})
.stringify(briefDesc);
tutData["briefDesc"] = briefDescText;
let title = getFirstHeading(tutMD);
let titleText = remark()
.use(frontMatter, {type: 'yaml', fence: '---'})
.data("settings", {paddedTable: false, gfm: false})
.stringify(title.children[0]);
tutData["title"] = titleText;
result.tuts.push(tutData);
});
示例2: remark
.then((response) => {
if (!response['data']) {
console.log(JSON.stringify(response));
} else {
//console.log(template(response['data']));
let newSection = remark().parse(template(response['data'])).children;
replaceZone(indexMD, libName, (start, _oldZone, end) => {
newSection.unshift(start);
newSection.push(end);
return newSection;
});
let outText = remark()
.use(frontMatter, {type: 'yaml', fence: '---'})
.data("settings", {paddedTable: false, gfm: false})
.stringify(indexMD);
fs.writeFileSync(indexFilePath, outText);
}
});
示例3: updateFile
function updateFile(tree, pathname, aggData, errorMessages) {
/*
let compName = angNameToClassName(path.basename(pathname, ".md"));
let classRef = aggData.projData.findReflectionByName(compName);
if (!classRef) {
// A doc file with no corresponding class (eg, Document Library Model).
return false;
}
let compData = new ComponentInfo(classRef);
*/
let className = ngNameToClassName(path.basename(pathname, ".md"), nameExceptions);
let classTypeMatch = className.match(/component|directive|service/i);
let compData = aggData.classInfo[className];
if (classTypeMatch && compData) {
let classType = classTypeMatch[0].toLowerCase();
// Copy docs back from the .md file when the JSDocs are empty.
let inputMD = getPropDocsFromMD(tree, "Properties", 3);
let outputMD = getPropDocsFromMD(tree, "Events", 2);
updatePropDocsFromMD(compData, inputMD, outputMD, errorMessages);
if (classType === "service") {
let methodMD = getMethodDocsFromMD(tree);
updateMethodDocsFromMD(compData, methodMD, errorMessages);
}
let templateName = path.resolve(templateFolder, classType + ".ejs");
let templateSource = fs.readFileSync(templateName, "utf8");
let template = ejs.compile(templateSource);
let mdText = template(compData);
mdText = mdText.replace(/^ +\|/mg, "|");
let newSection = remark().parse(mdText.trim()).children;
replaceSection(tree, "Class members", (before, section, after) => {
newSection.unshift(before);
newSection.push(after);
return newSection;
});
compData.errors.forEach(err => {
errorMessages.push(err);
})
}
return true;
}
示例4: aggPhase
function aggPhase(aggData) {
let indexDocData = getIndexDocData();
let templateName = path.resolve(templateFolder, "tutIndex.ejs");
let templateSource = fs.readFileSync(templateName, "utf8");
let template = ejs.compile(templateSource);
let mdText = template(indexDocData);
mdText = mdText.replace(/^ +\|/mg, "|");
let newSection = remark().use(frontMatter, ["yaml"]).data("settings", {paddedTable: false, gfm: false}).parse(mdText.trim()).children;
let tutIndexFile = path.resolve(tutFolder, "README.md");
let tutIndexText = fs.readFileSync(tutIndexFile, "utf8");
let tutIndexMD = remark().use(frontMatter, ["yaml"]).data("settings", {paddedTable: false, gfm: false}).parse(tutIndexText);
replaceSection(tutIndexMD, "Tutorials", (before, section, after) => {
newSection.unshift(before);
newSection.push(after);
return newSection;
});
fs.writeFileSync(tutIndexFile, remark().use(frontMatter, {type: 'yaml', fence: '---'}).data("settings", {paddedTable: false, gfm: false}).stringify(tutIndexMD));
}
示例5: getDocReviewDate
function getDocReviewDate(docFileName) {
let mdFilePath = path.resolve(docsFolderPath, docFileName);
let mdText = fs.readFileSync(mdFilePath);
let tree = remark().use(frontMatter, ["yaml"]).parse(mdText);
let lastReviewDate = moment(adf20StartDate);
if (tree.children[0].type == "yaml") {
let metadata = yaml.load(tree.children[0].value);
if (metadata["Last reviewed"])
lastReviewDate = moment(metadata["Last reviewed"]);
}
return lastReviewDate;
}
示例6: processDocs
export function processDocs(mdCache, aggData, _errorMessages) {
let docset: MQ.Docset = new MQ.Docset(mdCache);
let templateFilePath = path.resolve(__dirname, '..', 'templates', 'gqIndex.ejs');
let templateSource = fs.readFileSync(templateFilePath, 'utf8');
let template = ejs.compile(templateSource);
let indexFilePath = path.resolve(aggData['rootFolder'], 'docs', 'README.md');
let indexFileText = fs.readFileSync(indexFilePath, 'utf8');
let indexMD = remark()
.use(frontMatter, ["yaml"])
.parse(indexFileText);
let schema = buildSchema(MQ.schema);
libNamesList.forEach(libName => {
graphql(schema, query, docset, null, {'libName': libName})
.then((response) => {
if (!response['data']) {
console.log(JSON.stringify(response));
} else {
//console.log(template(response['data']));
let newSection = remark().parse(template(response['data'])).children;
replaceZone(indexMD, libName, (start, _oldZone, end) => {
newSection.unshift(start);
newSection.push(end);
return newSection;
});
let outText = remark()
.use(frontMatter, {type: 'yaml', fence: '---'})
.data("settings", {paddedTable: false, gfm: false})
.stringify(indexMD);
fs.writeFileSync(indexFilePath, outText);
}
});
});
}
示例7: remark
import * as fs from 'fs';
import * as path from 'path';
import { graphql, buildSchema } from 'graphql';
import * as remark from 'remark';
import * as frontMatter from 'remark-frontmatter';
import { MDAST } from 'mdast';
import * as removePosInfo from 'unist-util-remove-position';
import * as MQ from './mqDefs';
let docFilePath = path.resolve('..', '..', 'docs', 'core', 'about.component.md');
let docSrc = fs.readFileSync(docFilePath, 'utf8');
let tree: MDAST.Root = remark()
.use(frontMatter, ["yaml"])
.parse(docSrc);
tree = removePosInfo(tree);
//console.log(JSON.stringify(tree));
let schema = buildSchema(MQ.schema);
let root = {
document: () => new MQ.Root(tree)
};
let query = `