File tree Expand file tree Collapse file tree 3 files changed +69
-2
lines changed
packages/docusaurus-utils/src
website/_dogfooding/_docs tests/tests Expand file tree Collapse file tree 3 files changed +69
-2
lines changed Original file line number Diff line number Diff line change @@ -1366,6 +1366,57 @@ before
1366
1366
1367
1367
\t\t:::
1368
1368
1369
+ after
1370
+ ` ) ;
1371
+ } ) ;
1372
+
1373
+ it ( 'transforms directives in quotes' , ( ) => {
1374
+ expect (
1375
+ admonitionTitleToDirectiveLabel (
1376
+ `
1377
+ before
1378
+
1379
+ > :::caution There be dragons
1380
+ >
1381
+ > This is the admonition content
1382
+ >
1383
+ > :::
1384
+ >
1385
+ >> :::caution There be dragons
1386
+ >>
1387
+ >> This is the admonition content
1388
+ >>
1389
+ >> :::
1390
+ > > :::caution There be dragons
1391
+ > >
1392
+ > > This is the admonition content
1393
+ > >
1394
+ > > :::
1395
+
1396
+ after
1397
+ ` ,
1398
+ directives ,
1399
+ ) ,
1400
+ ) . toBe ( `
1401
+ before
1402
+
1403
+ > :::caution[There be dragons]
1404
+ >
1405
+ > This is the admonition content
1406
+ >
1407
+ > :::
1408
+ >
1409
+ >> :::caution[There be dragons]
1410
+ >>
1411
+ >> This is the admonition content
1412
+ >>
1413
+ >> :::
1414
+ > > :::caution[There be dragons]
1415
+ > >
1416
+ > > This is the admonition content
1417
+ > >
1418
+ > > :::
1419
+
1369
1420
after
1370
1421
` ) ;
1371
1422
} ) ;
Original file line number Diff line number Diff line change @@ -97,14 +97,16 @@ export function admonitionTitleToDirectiveLabel(
97
97
98
98
const directiveNameGroup = `(${ admonitionContainerDirectives . join ( '|' ) } )` ;
99
99
const regexp = new RegExp (
100
- `^(?<indentation>( +|\t+))?(?<directive>:{3,}${ directiveNameGroup } ) +(?<title>.*)$` ,
100
+ `^(?<quote>(> ?)*)(?< indentation>( +|\t+))?(?<directive>:{3,}${ directiveNameGroup } ) +(?<title>.*)$` ,
101
101
'gm' ,
102
102
) ;
103
103
104
104
return content . replaceAll ( regexp , ( substring , ...args : any [ ] ) => {
105
105
const groups = args . at ( - 1 ) ;
106
106
107
- return `${ groups . indentation ?? '' } ${ groups . directive } [${ groups . title } ]` ;
107
+ return `${ groups . quote ?? '' } ${ groups . indentation ?? '' } ${
108
+ groups . directive
109
+ } [${ groups . title } ]`;
108
110
} ) ;
109
111
}
110
112
Original file line number Diff line number Diff line change @@ -74,6 +74,20 @@ See admonition title v2 compat syntax bug: https://github.com/facebook/docusauru
74
74
75
75
:::
76
76
77
+ ## Quoted admonitions
78
+
79
+ > :::caution There be dragons
80
+ >
81
+ > This is the admonition content
82
+ >
83
+ > :::
84
+ >
85
+ > > :::caution There be dragons
86
+ > >
87
+ > > This is the admonition content
88
+ > >
89
+ > > :::
90
+
77
91
## Official admonitions
78
92
79
93
Admonitions that are [ officially documented] ( /docs/markdown-features/admonitions )
You can’t perform that action at this time.
0 commit comments