# Estensione Markdown: le funzioni di wrap inline non riconoscono più i tag BBCode con contenuto vuoto

**URL:** https://meta.discourse.org/t/markdown-extension-inline-wrap-functions-doesnt-recognize-bbcode-tags-with-empty-content-anymore/238894
**Category:** Bug
**Tags:** development
**Created:** [13 Settembre 2022, 4:25pm UTC](https://meta.discourse.org/t/markdown-extension-inline-wrap-functions-doesnt-recognize-bbcode-tags-with-empty-content-anymore/238894 "2022-09-13T16:25:12Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![syl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/syl/32/98883_2.png) [@syl](https://meta.discourse.org/u/syl)
#### Post date: [13 Settembre 2022, 4:25pm UTC](https://meta.discourse.org/t/markdown-extension-inline-wrap-functions-doesnt-recognize-bbcode-tags-with-empty-content-anymore/238894/1 "2022-09-13T16:25:12Z")

</div>

Sto usando questo codice nel mio plugin:

```javascript
helper.allowList(['span.dpg-balloon-text'])

helper.registerPlugin(md => {
  md.inline.bbcode.ruler.push('dpgb', {
    tag: 'dpgb',
    wrap: function (startToken, endToken, tagInfo) {
      startToken.tag = endToken.tag = 'span'
      startToken.content = endToken.content = ''
      startToken.type = "span_open";
      endToken.type = "span_close";    
      startToken.nesting = 1;
      endToken.nesting = -1;    
      startToken.attrs = [['class', 'dpg-balloon-text']].concat(
        Object.keys(tagInfo.attrs).map(key => [
          `data-dpg-${key}`,
          tagInfo.attrs[key]
        ])
      )
    }
  })
})

```

Quanto sopra funzionava sia con i tag BBCode vuoti che non vuoti. Ma ho scoperto oggi che ora si attiva solo quando il tag BBCode ha contenuto (come `[dpgb]Alcuni contenuti[/dpgb]`) e non si attiva quando il tag BBCode non ha contenuto (come `[dpgb][/dpgb]`). È una nuova scelta di progettazione?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [14 Settembre 2022, 2:04am UTC](https://meta.discourse.org/t/markdown-extension-inline-wrap-functions-doesnt-recognize-bbcode-tags-with-empty-content-anymore/238894/2 "2022-09-14T02:04:44Z")

</div>

Non sono sicuro, puoi analizzare il codice sorgente per vedere il commit che ha modificato il comportamento?

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [19 Settembre 2022, 1:26pm UTC](https://meta.discourse.org/t/markdown-extension-inline-wrap-functions-doesnt-recognize-bbcode-tags-with-empty-content-anymore/238894/3 "2022-09-19T13:26:10Z")

</div>

L’aggiornamento a Markdown.it v13 ha interrotto gli inline BBCode vuoti Il comportamento della funzione [processDelimiters](https://github.com/markdown-it/markdown-it/blob/2b6cac25823af011ff3bc7628bc9b06e483c5a08/lib/rules_inline/balance_pairs.js#L6-L115) è cambiato. Non aggiorna più l’attributo `end` dei nostri delimitatori BBCode quando il BBCode non ha contenuto.

Ho creato una PR che ripristina il comportamento precedente e aggiunge un test.

> <https://github.com/discourse/discourse/pull/18276>
>
> Upgrading to Markdown.it v13 broke empty inline BBCodes. This works around the p…roblem by adding an empty token before a closing token if the previous token was a BBCode token.
> 
> It also removes the unused \`jump\` attribute which was removed in Markdown.it v12.3

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [19 Settembre 2022, 11:50pm UTC](https://meta.discourse.org/t/markdown-extension-inline-wrap-functions-doesnt-recognize-bbcode-tags-with-empty-content-anymore/238894/4 "2022-09-19T23:50:41Z")

</div>


