File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed
packages/docusaurus-theme-common/src/utils Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -147,10 +147,6 @@ function getAllMagicCommentDirectiveStyles(
147147 }
148148}
149149
150- function parseCodeBlockTitle ( metastring ?: string ) : string {
151- return metastring ?. match ( codeBlockTitleRegex ) ?. groups ! . title ?? '' ;
152- }
153-
154150function getMetaLineNumbersStart ( metastring ?: string ) : number | undefined {
155151 const showLineNumbersMeta = metastring
156152 ?. split ( ' ' )
@@ -356,12 +352,23 @@ export function parseCodeBlockMetaOptions(
356352 // we keep the old custom logic which was moved from their old spots to here.
357353
358354 // normal codeblock
359- parsedOptions . title = parseCodeBlockTitle ( metastring ) ;
360- parsedOptions . showLineNumbers = getMetaLineNumbersStart ( metastring ) ;
355+ const title = metastring ?. match ( codeBlockTitleRegex ) ?. groups ! . title ;
356+ if ( title !== undefined ) {
357+ parsedOptions . title = title ;
358+ }
359+ const showLineNumbers = getMetaLineNumbersStart ( metastring ) ;
360+ if ( showLineNumbers !== undefined ) {
361+ parsedOptions . showLineNumbers = showLineNumbers ;
362+ }
361363
362364 // interactive code editor (theme-live-codeblock => Playground)
363- parsedOptions . live = metastring ?. split ( ' ' ) . includes ( 'live' ) ;
364- parsedOptions . noInline = metastring ?. includes ( 'noInline' ) ;
365+ if ( metastring ?. split ( ' ' ) . includes ( 'live' ) ) {
366+ parsedOptions . live = true ;
367+ }
368+
369+ if ( metastring ?. includes ( 'noInline' ) ) {
370+ parsedOptions . noInline = true ;
371+ }
365372
366373 return parsedOptions ;
367374}
You can’t perform that action at this time.
0 commit comments