mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-03 23:06:49 +01:00
Small markdown code cleanup
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user