@@ -474,7 +474,22 @@ export class GettingStartedPage extends EditorPane {
474
474
}
475
475
476
476
private mdCache = new ResourceMap < Promise < string > > ( ) ;
477
- private async readAndCacheStepMarkdown ( path : URI ) : Promise < string > {
477
+ private async readAndCacheStepMarkdown ( path : URI , base : URI ) : Promise < string > {
478
+
479
+ const transformUri = ( src : string ) => {
480
+ const path = joinPath ( base , src ) ;
481
+ return asWebviewUri ( path ) . toString ( ) ;
482
+ } ;
483
+ const transformUris = ( content : string ) : string => content
484
+ . replace ( / s r c = " ( [ ^ " ] * ) " / g, ( _ , src : string ) => {
485
+ if ( src . startsWith ( 'https://' ) ) { return `src="${ src } "` ; }
486
+ return `src="${ transformUri ( src ) } "` ;
487
+ } )
488
+ . replace ( / ! \[ ( [ ^ \] ] * ) \] \( ( [ ^ ) ] * ) \) / g, ( _ , title : string , src : string ) => {
489
+ if ( src . startsWith ( 'https://' ) ) { return `` ; }
490
+ return ` } )` ;
491
+ } ) ;
492
+
478
493
if ( ! this . mdCache . has ( path ) ) {
479
494
this . mdCache . set ( path , ( async ( ) => {
480
495
try {
@@ -483,7 +498,7 @@ export class GettingStartedPage extends EditorPane {
483
498
return new Promise < string > ( resolve => {
484
499
require ( [ moduleId ] , content => {
485
500
const markdown = content . default ( ) ;
486
- resolve ( renderMarkdownDocument ( markdown , this . extensionService , this . languageService , true , true ) ) ;
501
+ resolve ( renderMarkdownDocument ( transformUris ( markdown ) , this . extensionService , this . languageService , true , true ) ) ;
487
502
} ) ;
488
503
} ) ;
489
504
}
@@ -512,7 +527,7 @@ export class GettingStartedPage extends EditorPane {
512
527
: path ) ;
513
528
514
529
const markdown = bytes . value . toString ( ) ;
515
- return renderMarkdownDocument ( markdown , this . extensionService , this . languageService , true , true ) ;
530
+ return renderMarkdownDocument ( transformUris ( markdown ) , this . extensionService , this . languageService , true , true ) ;
516
531
} catch ( e ) {
517
532
this . notificationService . error ( 'Error reading markdown document at `' + path + '`: ' + e ) ;
518
533
return '' ;
@@ -772,18 +787,10 @@ export class GettingStartedPage extends EditorPane {
772
787
}
773
788
774
789
private async renderMarkdown ( path : URI , base : URI ) : Promise < string > {
775
- const content = await this . readAndCacheStepMarkdown ( path ) ;
790
+ const content = await this . readAndCacheStepMarkdown ( path , base ) ;
776
791
const nonce = generateUuid ( ) ;
777
792
const colorMap = TokenizationRegistry . getColorMap ( ) ;
778
793
779
- const uriTranformedContent = content . replace ( / s r c = " ( [ ^ " ] * ) " / g, ( _ , src : string ) => {
780
- if ( src . startsWith ( 'https://' ) ) { return `src="${ src } "` ; }
781
-
782
- const path = joinPath ( base , src ) ;
783
- const transformed = asWebviewUri ( path ) . toString ( ) ;
784
- return `src="${ transformed } "` ;
785
- } ) ;
786
-
787
794
const css = colorMap ? generateTokensCSSForColorMap ( colorMap ) : '' ;
788
795
789
796
const inDev = document . location . protocol === 'http:' ;
@@ -854,7 +861,7 @@ export class GettingStartedPage extends EditorPane {
854
861
</head>
855
862
<body>
856
863
<vertically-centered>
857
- ${ uriTranformedContent }
864
+ ${ content }
858
865
</vertically-centered>
859
866
</body>
860
867
<script nonce="${ nonce } ">
0 commit comments