@@ -264,6 +264,36 @@ describe('useMarkdown', () => {
264264 expect ( processed . value ) . toBe ( 'A library' )
265265 } )
266266
267+ it ( 'returns empty when a linkless badge strips down to bare brackets' , ( ) => {
268+ // A badge image without an enclosing link loses its image atom but the
269+ // wrapper has no URL to match, leaving a bare "[]" behind
270+ const processed = useMarkdown ( {
271+ text : '[]' ,
272+ } )
273+ expect ( processed . value ) . toBe ( '' )
274+ } )
275+
276+ it ( 'returns empty when linked and linkless badges leave only bare brackets' , ( ) => {
277+ const processed = useMarkdown ( {
278+ text : '[](https://www.npmjs.com/package/jsdoc-type-pratt-parser) []' ,
279+ } )
280+ expect ( processed . value ) . toBe ( '' )
281+ } )
282+
283+ it ( 'returns empty for a literal empty bracket pair' , ( ) => {
284+ expect ( useMarkdown ( { text : '[]' } ) . value ) . toBe ( '' )
285+ expect ( useMarkdown ( { text : ' [] ' } ) . value ) . toBe ( '' )
286+ } )
287+
288+ it ( 'returns empty when multiple linkless badges strip down to bare brackets' , ( ) => {
289+ expect ( useMarkdown ( { text : '[] []' } ) . value ) . toBe ( '' )
290+ expect ( useMarkdown ( { text : '[]\n[]' } ) . value ) . toBe ( '' )
291+ } )
292+
293+ it ( 'preserves brackets that are part of the text' , ( ) => {
294+ expect ( useMarkdown ( { text : 'returns [] when empty' } ) . value ) . toBe ( 'returns [] when empty' )
295+ } )
296+
267297 it ( 'strips reference-style linked image badges (regression #2767)' , ( ) => {
268298 const processed = useMarkdown ( {
269299 text : '[![npm version][npm-v-src]][npm-v-href] [![npm downloads][npm-d-src]][npm-d-href] A library' ,
0 commit comments