Custom Markdown Content Missing

I’m trying to create a [fieldset=] bbcode where you can enter a title as the = option and the content inside the tag.
So far, my rule creates the html tags properly, but the content and option are missing.

This is the tag structure that looks correct:

<fieldset class="bbcode-fieldset">
<legend></legend>
<span></span>
</fieldset>

And this is the rule I have added:

md.block.bbcode.ruler.push("fieldset", {
    tag: "fieldset",
    replace: function(state, tagInfo, content) {
      let token = state.push("fieldset_open", "fieldset", 1);
      token.attrs = [["class", "bbcode-fieldset"]];

      token = state.push("legend_open", "legend", 1);
      token.content = tagInfo.attrs['_default'];
      token = state.push("legend_close", "legend", -1);

      token = state.push("span_open", "span", 1);
      token.content = content;

      token = state.push("span_close", "span", -1);
      token = state.push("fieldset_close", "fieldset", -1);

      return true;
    }
  });

Is there something I’m missing regarding adding the content and the _default attribute? I want it to look like this:

<fieldset class="bbcode-fieldset">
<legend>{option}</legend>
<span>{text}</span>
</fieldset>
2 Likes