Plans to support Markdownit Ruler for BBCode?

My use case is to disable/enable bbcode rules when using the replace rule of bbcode.

replace: function (state, tagInfo, content) {
  const source = state.push("my_token", "div", 0);
  try {
    md.block.bbcode.ruler.disable("ruleName")
    source.children = state.md.parse(content, {});
  } finally {
    md.block.bbcode.ruler.enable("ruleName")
  }
  return true
}

I noticed that the TODO comment here was from a long time ago, any plans to implement it?

I guess my #1 question here is why? what problems would this solve?

1 Like

Would our project interest you instead? We are getting closer to the end:

We determined that using markdownit for any complex bbcode was a pain, so we are inserting bbob into Discourse instead.

Move to markdownit ruler will allow to enable/disable rules when starting a new parse, it makes flexibility and behavior like the native markdownit rules.

For example, I want to push some bbcode rules but not enable them by default, then enable them when I need them (like the example on the OP). Currently, this is not possible with the custom Ruler, maybe can do that with some tricky (through the parse env or modify the rules of ruler manually)?

[foo]
not wrapping inside the bar should not tokenize
[/foo]

[bar]
[foo]
wrap inside the bar should be tokenized
[/foo]
[/bar]

The reason why Iā€™m not creating native markdownit rules other than using the bbcode is implementing rules like bbcode will be difficult and hard to maintain, and bbcode is already here.


Great job, but my use case is something different.

And I like your code here which inspires me on the other concern problems.

1 Like

As in treat all bbcode like [wrap] is treated now? wrap them in in divs?

I would say what you are describing sound like a custom markdownit rule / plugin vs something core needs to implement?