RpNation / bbcode

RpNation's Official BBCode Implementation for Discourse
GNU General Public License v3.0
1 stars 3 forks source link

Case insensitive tags #6

Closed Alteras1 closed 1 year ago

Alteras1 commented 1 year ago

BBob doesn't seem to support case insensitive tags. Might need to make suggestion/open PR on BBob's repo. Could also consider removing the allowed tags mode and do a custom bbob plugin to walk the tree similar to how we already do with newlines.

Rhababo commented 1 year ago

Could we just .toLowerCase() anything entered in brackets?

Edit: Realized this is more about where to fix this rather than how.

Rhababo commented 1 year ago

So just like you said, the allowed tags mode is what's causing the issue.

 * @private
       * @param {String} value
       * @return {boolean}
       */ const isAllowedTag = (value)=>{
            if (options.onlyAllowTags && options.onlyAllowTags.length) {
                return options.onlyAllowTags.indexOf(value) >= 0;
            }
            return true;
        };

Because the toTagNode() function already has a .toLowerCase in it

toTagNode() {
            return new TagNode(this.tag.toLowerCase(), this.attrs, this.content);
        }

So adding .toLowerCase() here:

  if (options.onlyAllowTags && options.onlyAllowTags.length) {
      return options.onlyAllowTags.indexOf(value.**toLowerCase()**) >= 0;
  }

Gives us the right output.

Screenshot 2023-09-25 at 9 02 21 PM

So we could either, copy the entire parser code from bbob, change this line, and import it as an option during the bbob call. Or we could, as you said, make a suggestion on the bbob repo.

Rhababo commented 1 year ago

I went ahead and opened an issue on the BBob GitHub. https://github.com/JiLiZART/BBob/issues/190#issue-1912564626

Mondrethos commented 1 year ago

I went ahead and opened an issue on the BBob GitHub. JiLiZART/BBob#190 (comment)

It seems like its going to get fixed on BBob, pretty hype.

Mondrethos commented 1 year ago

The fix has been merged into BBob