本文整理匯總了TypeScript中@argdown/node.argdown.runAsync方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript argdown.runAsync方法的具體用法?TypeScript argdown.runAsync怎麽用?TypeScript argdown.runAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@argdown/node.argdown
的用法示例。
在下文中一共展示了argdown.runAsync方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getRangeOfHeading
public async getRangeOfHeading(
doc: vscode.TextDocument,
config: ArgdownPreviewConfiguration,
headingText: string
): Promise<vscode.Range> {
const argdownConfig = config.argdownConfig;
const input = doc.getText();
const request: IArgdownRequest = {
...argdownConfig,
input: input,
process: ["parse-input", "build-model"],
throwExceptions: true
};
const response = await argdown.runAsync(request);
if (!response.sections || response.sections.length == 0) {
return new vscode.Range(0, 0, 0, 0);
}
const section = this.findSection(response.sections, headingText);
if (section) {
return new vscode.Range(
(section.startLine || 1) - 1,
(section.startColumn || 1) - 1,
(section.startLine || 1) - 1,
(section.startColumn || 1) - 1
);
}
return new vscode.Range(0, 0, 0, 0);
}
示例2: exportHtml
public async exportHtml(
doc: vscode.TextDocument,
config: ArgdownPreviewConfiguration
): Promise<string> {
const argdownConfig = config.argdownConfig || {};
const input = doc.getText();
const request: IArgdownRequest = {
...argdownConfig,
input: input,
process: ["parse-input", "build-model", "export-html"],
html: {
...argdownConfig.html,
headless: true
},
throwExceptions: true
};
const response = await argdown.runAsync(request);
return response.html!;
}
示例3: getRangeOfMapNode
public async getRangeOfMapNode(
doc: vscode.TextDocument,
config: ArgdownPreviewConfiguration,
id: string
): Promise<vscode.Range> {
const argdownConfig = config.argdownConfig;
const input = doc.getText();
const request: IArgdownRequest = {
...argdownConfig,
input: input,
process: ["parse-input", "build-model", "build-map", "colorize"],
throwExceptions: true
};
const response = await argdown.runAsync(request);
const node = this.findNodeInMapNodeTree(
response.map!.nodes,
(n: any) => n.id === id
);
if (node && node.type === ArgdownTypes.ARGUMENT_MAP_NODE) {
const argument = response.arguments![node.title!];
const desc = IArgument.getCanonicalMember(argument);
if (desc) {
return new vscode.Range(
(desc.startLine || 1) - 1,
(desc.startColumn || 1) - 1,
(desc.endLine || 1) - 1,
desc.endColumn || 1
);
}
} else if (node && node.type === ArgdownTypes.STATEMENT_MAP_NODE) {
const eqClass = response.statements![node.title!];
const statement = IEquivalenceClass.getCanonicalMember(eqClass);
if (statement) {
return new vscode.Range(
(statement.startLine || 1) - 1,
(statement.startColumn || 1) - 1,
(statement.endLine || 1) - 1,
statement.endColumn || 1
);
}
}
return new vscode.Range(0, 0, 0, 0);
}
示例4: getMapNodeId
public async getMapNodeId(
doc: vscode.TextDocument,
config: ArgdownPreviewConfiguration,
line: number,
character: number
): Promise<string> {
const argdownConfig = config.argdownConfig;
const input = doc.getText();
const request: IArgdownRequest = {
...argdownConfig,
input: input,
findElementAtPosition: {
line: line + 1,
character: character + 1
},
process: [
"parse-input",
"build-model",
"build-map",
"colorize",
"find-element-at-position"
],
throwExceptions: true
};
const response = await argdown.runAsync(request);
if (response.elementAtPosition) {
const title = response.elementAtPosition.title;
let nodeType = ArgdownTypes.ARGUMENT_MAP_NODE;
if (response.elementAtPosition.type === ArgdownTypes.EQUIVALENCE_CLASS) {
nodeType = ArgdownTypes.STATEMENT_MAP_NODE;
}
const node = this.findNodeInMapNodeTree(
response.map!.nodes,
n => n.title === title && n.type === nodeType
);
if (!node) {
return "";
}
return node.id || "";
}
return "";
}
示例5: getMap
public async getMap(
doc: vscode.TextDocument,
config: ArgdownPreviewConfiguration
): Promise<IMap> {
const argdownConfig = config.argdownConfig;
const input = doc.getText();
const request = {
...argdownConfig,
input: input,
process: [
"parse-input",
"build-model",
"build-map",
"transform-closed-groups",
"colorize"
],
throwExceptions: true
};
const response = await argdown.runAsync(request);
return response.map!;
}