What are the advantages of using a WYSIWYG editor that generates BBCode instead of HTML?

Using a WYSIWYG editor that generates BBCode instead of HTML can be advantageous because BBCode is simpler and more user-friendly for non-technical users. BBCode also helps prevent users from accidentally breaking the layout or structure of the content, as it has predefined tags that limit the available formatting options. Additionally, BBCode can be easily converted to HTML when rendering the content on a webpage.

// Function to convert BBCode to HTML
function bbcode_to_html($bbcode) {
    $bbcodeParser = new \JBBCode\Parser();
    $bbcodeParser->addCodeDefinitionSet(new \JBBCode\DefaultCodeDefinitionSet());
    $bbcodeParser->parse($bbcode);
    return $bbcodeParser->getAsHtml();
}

// Example usage
$bbcode = "[b]Bold text[/b] [url=https://example.com]Link[/url]";
$html = bbcode_to_html($bbcode);
echo $html;