本文整理汇总了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!;
}