@@ -134,13 +134,11 @@ export async function render_content_markdown(
134
134
return parse ( {
135
135
body : await generate_ts_from_js ( await replace_export_type_placeholders ( body , modules ) ) ,
136
136
type_links,
137
- code : ( source , language , current ) => {
138
- const cached_snippet = SNIPPET_CACHE . get ( source + language + current ) ;
137
+ code : ( raw , language , current ) => {
138
+ const cached_snippet = SNIPPET_CACHE . get ( raw + language + current ) ;
139
139
if ( cached_snippet . code ) return cached_snippet . code ;
140
140
141
- const options : SnippetOptions = { file : null , link : null , copy : true } ;
142
-
143
- source = collect_options ( source , options ) ;
141
+ let { source, options } = parse_options ( raw ) ;
144
142
source = adjust_tab_indentation ( source , language ) ;
145
143
146
144
let version_class : 'ts-version' | 'js-version' | '' = '' ;
@@ -949,9 +947,11 @@ function create_type_links(
949
947
return { type_regex, type_links } ;
950
948
}
951
949
952
- function collect_options ( source : string , options : SnippetOptions ) {
950
+ function parse_options ( source : string ) {
953
951
METADATA_REGEX . lastIndex = 0 ;
954
952
953
+ const options : SnippetOptions = { file : null , link : null , copy : true } ;
954
+
955
955
let copy_value = 'true' ;
956
956
source = source . replace ( METADATA_REGEX , ( _ , key , value ) => {
957
957
if ( key === 'copy' ) {
@@ -964,7 +964,7 @@ function collect_options(source: string, options: SnippetOptions) {
964
964
options . link = options . link === 'true' ;
965
965
options . copy = copy_value === 'true' || ( options . file && copy_value !== 'false' ) ;
966
966
967
- return source ;
967
+ return { source, options } ;
968
968
}
969
969
970
970
/**
0 commit comments