diff --git a/src/webview/leetCodeSubmissionProvider.ts b/src/webview/leetCodeSubmissionProvider.ts index f717a38a..f4f18fd4 100644 --- a/src/webview/leetCodeSubmissionProvider.ts +++ b/src/webview/leetCodeSubmissionProvider.ts @@ -9,10 +9,10 @@ import { markdownEngine } from "./markdownEngine"; class LeetCodeSubmissionProvider extends LeetCodeWebview { protected readonly viewType: string = "leetcode.submission"; - private result: string; + private result: IResult; - public show(result: string): void { - this.result = result; + public show(resultString: string): void { + this.result = this.parseResult(resultString); this.showWebviewInternal(); this.showKeybindingsHint(); } @@ -25,18 +25,36 @@ class LeetCodeSubmissionProvider extends LeetCodeWebview { } protected getWebviewContent(): string { - return ` - + const styles: string = markdownEngine.getStyles(); + const title: string = `## ${this.result.messages[0]}`; + const messages: string[] = this.result.messages.slice(1).map((m: string) => `* ${m}`); + const sections: string[] = Object.keys(this.result) + .filter((key: string) => key !== "messages") + .map((key: string) => [ + `### ${key}`, + "```", + this.result[key].join("\n"), + "```", + ].join("\n")); + const body: string = markdownEngine.render([ + title, + ...messages, + ...sections, + ].join("\n")); + return ` + +
- ${markdownEngine.getStyles()} + ${styles} - -${this.result.trim()}
+
+ ${body}
- `;
+
+ `;
}
protected onDidDisposeWebview(): void {
@@ -52,6 +70,38 @@ class LeetCodeSubmissionProvider extends LeetCodeWebview {
(): Promise