# Help with BBCode Plugin

**URL:** https://meta.discourse.org/t/help-with-bbcode-plugin/56884
**Category:** Development
**Created:** [February 4, 2017, 12:10am UTC](https://meta.discourse.org/t/help-with-bbcode-plugin/56884 "2017-02-04T00:10:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![XieLong](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xielong/32/67063_2.png) [@XieLong](https://meta.discourse.org/u/XieLong)
#### Post date: [February 4, 2017, 12:10am UTC](https://meta.discourse.org/t/help-with-bbcode-plugin/56884/1 "2017-02-04T00:10:54Z")

</div>

Hi there,

I’m about to develop a plugin for some RPG related BBCodes.

Raw Code:

```bbcode
[rule=Category]
    ... Rule Text ...
    [value=Cost]200 XP[/value]
    [value=Some other Value]Text of the value.[/value]
[/rule]

```

Cooked code:

```html
<dl class="bbcode-rule category">
    <dt class="bbcode-rule">Category</dt>
    <dd class="bbcode-rule">... Rule Text ...</dd>
    <dt class="bbcode-value cost">Cost:</dt>
    <dd class="bbcode-value cost">200 XP</dd>
    <dt class="bbcode-value some-other-value">Some other Value:</dt>
    <dd class="bbcode-value some-other-value">Text of the value.</dd>
</dl>

```

My Problem is: I’m not able to create a block bbcode with processed contents. I feel that I’m kinda close, but lost.

This is my plugin code so far:

```javascript
  const { register } = builders(helper);

  register("value", {noWrap: true}, (contents, param) => {
    let className = 'bbcode-value';
    if (param) {
      className += ' ';
      className += generateCssClass(param);
    }
    return [ 'dt', {'class': className, 'data-bbcode': true}, param,
             ['dd', {'class': className, 'data-bbcode': true}].concat(contents)
           ];
  });
  register("rule", (contents, param) => ['div', {
    'class': 'bbcode-rule' + (param ? ' ' + generateCssClass(param) : ''),
    'data-bbcode': true},
    ['dt', {'class': 'bbcode-rule'}, param],
    ['dd', {'class': 'bbcode-rule'}, ???]].concat(contents));

```

And this is how it currently looks:

 ![](https://global.discourse-cdn.com/meta/original/3X/8/a/8a0aba3c9f65c2eb6e16df0fa9dba3c91852bc37.png)

But with a line break after the opening rule-tag:

 ![](https://global.discourse-cdn.com/meta/original/3X/7/4/7494b36499a386768fccd70a6dd7f3a7f89d7c69.png)

But still the second (and all following) [value] are not translated.

---

<div class="post-metadata">

### Author: ![XieLong](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xielong/32/67063_2.png) [@XieLong](https://meta.discourse.org/u/XieLong)
#### Post date: [February 7, 2017, 3:39pm UTC](https://meta.discourse.org/t/help-with-bbcode-plugin/56884/2 "2017-02-07T15:39:13Z")

</div>

Can’t anybody help me with the BBCode API or at least point me to some kind of documentation/tutorial other than the source comments?  
I’d highly appreciate every bit of help :slight_smile:

---

<div class="post-metadata">

### Author: ![Tien\_Huynh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tien_huynh/32/152822_2.png) [@Tien\_Huynh](https://meta.discourse.org/u/Tien_Huynh)
#### Post date: [January 31, 2020, 4:37pm UTC](https://meta.discourse.org/t/help-with-bbcode-plugin/56884/3 "2020-01-31T16:37:37Z")

</div>

> [@Developer's guide to Markdown extensions](https://meta.discourse.org/t/developers-guide-to-markdown-extensions/66023):
>
> Discourse uses a Markdown engine called [Markdown-it](https://github.com/markdown-it/markdown-it). Here are some dev notes that will help you either fix bugs in core or create your new plugins. The Basics Discourse only contains a few helpers on top of the engine, so the vast majority of learning that needs to be done, is understanding Markdown It. The [docs directory](https://github.com/markdown-it/markdown-it/tree/master/docs) contains the current documentation. I strongly recommend reading: The [architecture document](https://github.com/markdown-it/markdown-it/blob/master/docs/architecture.md) to understand at a top level how the engine works. [Development](https://github.com/markdown-it/markdown-it/blob/master/docs/development.md) for basic d…
