File tree 2 files changed +12
-9
lines changed
docusaurus-theme-classic/src/theme/CodeBlock/Content
docusaurus-theme-common/src/utils
2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ export default function CodeBlockString({
70
70
} ) ;
71
71
const lineNumbersStart = getLineNumbersStart ( {
72
72
showLineNumbers : showLineNumbersProp ,
73
- metastring ,
73
+ metaOptions ,
74
74
} ) ;
75
75
76
76
return (
Original file line number Diff line number Diff line change @@ -183,19 +183,22 @@ export function getCodeBlockTitle({
183
183
184
184
export function getLineNumbersStart ( {
185
185
showLineNumbers,
186
- metastring ,
186
+ metaOptions ,
187
187
} : {
188
188
showLineNumbers : boolean | number | undefined ;
189
- metastring : string | undefined ;
189
+ metaOptions : CodeBlockMetaOptions ;
190
190
} ) : number | undefined {
191
+ const showLineNumbersValue = showLineNumbers ?? metaOptions . showLineNumbers ;
192
+
191
193
const defaultStart = 1 ;
192
- if ( typeof showLineNumbers === 'boolean' ) {
193
- return showLineNumbers ? defaultStart : undefined ;
194
+ if ( typeof showLineNumbersValue === 'boolean' ) {
195
+ return showLineNumbersValue ? defaultStart : undefined ;
194
196
}
195
- if ( typeof showLineNumbers === 'number' ) {
196
- return showLineNumbers ;
197
+ if ( typeof showLineNumbersValue === 'number' ) {
198
+ return showLineNumbersValue ;
197
199
}
198
- return getMetaLineNumbersStart ( metastring ) ;
200
+
201
+ return undefined ;
199
202
}
200
203
201
204
/**
@@ -429,7 +432,7 @@ export function parseCodeBlockMetaOptions(
429
432
430
433
// normal codeblock
431
434
parsedOptions . title = parseCodeBlockTitle ( metastring ) ;
432
- // parsedOptions.showLineNumbers = TODO ;
435
+ parsedOptions . showLineNumbers = getMetaLineNumbersStart ( metastring ) ;
433
436
434
437
// interactive code editor (theme-live-codeblock => Playground)
435
438
parsedOptions . live = metastring ?. split ( ' ' ) . includes ( 'live' ) ;
You can’t perform that action at this time.
0 commit comments