Small markdown code cleanup

This commit is contained in:
Matt Bierner
2017-02-15 14:49:12 -08:00
parent 5b6c98c4ee
commit 7a82ac3ff9

View File

@@ -20,14 +20,12 @@ export function getMarkdownUri(uri: vscode.Uri) {
export class MDDocumentContentProvider implements vscode.TextDocumentContentProvider {
private _onDidChange = new vscode.EventEmitter<vscode.Uri>();
private _waiting: boolean;
private _waiting: boolean = false;
constructor(
private engine: MarkdownEngine,
private context: vscode.ExtensionContext
) {
this._waiting = false;
}
) { }
private getMediaPath(mediaFile: string): string {
return vscode.Uri.file(this.context.asAbsolutePath(path.join('media', mediaFile))).toString();
@@ -38,27 +36,28 @@ export class MDDocumentContentProvider implements vscode.TextDocumentContentProv
}
private fixHref(resource: vscode.Uri, href: string): string {
if (href) {
// Use href if it is already an URL
if (vscode.Uri.parse(href).scheme) {
return href;
}
// Use href as file URI if it is absolute
if (this.isAbsolute(href)) {
return vscode.Uri.file(href).toString();
}
// use a workspace relative path if there is a workspace
let rootPath = vscode.workspace.rootPath;
if (rootPath) {
return vscode.Uri.file(path.join(rootPath, href)).toString();
}
// otherwise look relative to the markdown file
return vscode.Uri.file(path.join(path.dirname(resource.fsPath), href)).toString();
if (!href) {
return href;
}
return href;
// Use href if it is already an URL
if (vscode.Uri.parse(href).scheme) {
return href;
}
// Use href as file URI if it is absolute
if (this.isAbsolute(href)) {
return vscode.Uri.file(href).toString();
}
// use a workspace relative path if there is a workspace
let rootPath = vscode.workspace.rootPath;
if (rootPath) {
return vscode.Uri.file(path.join(rootPath, href)).toString();
}
// otherwise look relative to the markdown file
return vscode.Uri.file(path.join(path.dirname(resource.fsPath), href)).toString();
}
private computeCustomStyleSheetIncludes(uri: vscode.Uri): string {