@@ -17,27 +17,18 @@ export function appendEmptyLine(text: string) {
17
17
}
18
18
19
19
export function replaceFilename (
20
- renderer : ( code : string , directiveRef : string ) => string ,
20
+ renderer : ( code : string ) => string ,
21
21
text : string ,
22
22
filenameKey : string ,
23
23
filenameIndex : number ,
24
24
) {
25
25
const startIndex = filenameIndex + filenameKey . length ;
26
26
const endIndex = text . indexOf ( ')' ) ;
27
- const directiveRef = `app` + crypto . randomBytes ( 20 ) . toString ( 'hex' ) ;
28
27
const filename = text . slice ( startIndex + 1 , endIndex ) ;
29
- return (
30
- `
31
- <span class="filename">` +
32
- ( filename . length > 0
33
- ? `
34
- {{ '${ filename } ' | extension: ${ directiveRef } .isJsActive }}`
35
- : '' ) +
36
- `
37
- <app-tabs #${ directiveRef } ></app-tabs>
38
- </span>` +
39
- renderer ( text . slice ( endIndex + 1 ) , directiveRef ) . trim ( )
40
- ) ;
28
+ return `
29
+ <code-element ${ filename . length ? `filename="${ filename } "` : '' } >
30
+ ${ renderer ( text . slice ( endIndex + 1 ) ) . trim ( ) }
31
+ </code-element>` ;
41
32
}
42
33
43
34
export function parseSwitcher (
@@ -49,12 +40,14 @@ export function parseSwitcher(
49
40
) {
50
41
const tsCode = text . slice ( 0 , switchIndex ) . trim ( ) ;
51
42
const jsCode = text . slice ( switchIndex + switchKey . length , text . length ) . trim ( ) ;
52
- const wrapCondition = ( snippet : string , lang : 'ts' | 'js' ) =>
53
- elementKey
54
- ? snippet . slice ( 0 , 4 ) +
55
- ` [class.hide]="${ lang === 'js' ? '!' : '' } ${ elementKey } .isJsActive"` +
56
- snippet . slice ( 4 , snippet . length )
57
- : snippet ;
43
+
44
+ const wrapCondition = ( htmlSnippet : string , lang : 'ts' | 'js' ) : string => {
45
+ // The beginning of the pre-Tag (<pre)
46
+ const beginPreTag = htmlSnippet . slice ( 0 , 4 ) ;
47
+ const endPreTag = htmlSnippet . slice ( 4 , htmlSnippet . length ) ;
48
+ return `${ beginPreTag } slot=${ lang } ${ endPreTag } ` ;
49
+ } ;
50
+
58
51
return (
59
52
wrapCondition ( renderer ( tsCode , 'typescript' ) , 'ts' ) +
60
53
wrapCondition ( renderer ( jsCode , 'typescript' ) , 'js' )
0 commit comments