diff --git a/src/app/hf-markdown/hf-markdown.component.ts b/src/app/hf-markdown/hf-markdown.component.ts index 3928bdee..8702964d 100644 --- a/src/app/hf-markdown/hf-markdown.component.ts +++ b/src/app/hf-markdown/hf-markdown.component.ts @@ -246,7 +246,7 @@ ${token}`; ngOnChanges() { const contentWithReplacedTokens = this.replaceSessionToken( - this.replaceVmInfoTokens(this.content), + this.replaceVmInfoTokens(this.replaceSharedVmInfoTokens(this.content)), ); // the parse method internally uses the Angular Dom Sanitizer and is therefore safe to use this.processedContent = this.markdownService.parse( @@ -256,10 +256,24 @@ ${token}`; private replaceVmInfoTokens(content: string) { return content.replace( - /\$\{vmInfo:([^:]*):([^}]*)\}/g, + /\$\{vminfo:([^:]*):([^}]*)\}/g, (match, vmName, propName) => { const vm = this.context.vmInfo?.[vmName.toLowerCase()]; - return String(vm?.[propName as keyof VM] ?? match); + return String( + vm?.vm_type != 'SHARED' ? vm?.[propName as keyof VM] : match, + ); + }, + ); + } + + private replaceSharedVmInfoTokens(content: string) { + return content.replace( + /\$\{shared:([^:]*):([^}]*)\}/g, + (match, vmName, propName) => { + const vm = this.context.vmInfo?.[vmName.toLowerCase()]; + return String( + vm?.vm_type == 'SHARED' ? vm?.[propName as keyof VM] : match, + ); }, ); }