Hi there,
I’m about to develop a plugin for some RPG related BBCodes.
Raw Code:
[rule=Category]
... Rule Text ...
[value=Cost]200 XP[/value]
[value=Some other Value]Text of the value.[/value]
[/rule]
Cooked code:
<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:
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:
But with a line break after the opening rule-tag:
But still the second (and all following) [value] are not translated.