Fixed BB codes help uses [CODE=js] but should use [CODE=javascript] (or fix [CODE=js])

Steffen

Well-known member
Affected version
2.0.4
There is no syntax highlighting for [CODE=js] on the help page: https://xenforo.com/community/help/bb-codes/

I think the example should either be changed to [CODE=javascript] or XenForo should be fixed to accept [CODE=js], too.

Maybe [CODE=js] worked in XenForo 1.x?

Examples:
Code:
var hello = 'world';

JavaScript:
var hello = 'world';
 
Quick'n'Dirty fix:
Diff:
diff --git a/src/XF/BbCode/Renderer/Html.php b/src/XF/BbCode/Renderer/Html.php
index 3073f19de..335ac8d91 100644
--- a/src/XF/BbCode/Renderer/Html.php
+++ b/src/XF/BbCode/Renderer/Html.php
@@ -430,6 +430,7 @@ class Html extends AbstractRenderer
         $allowedLanguages = $codeLanguages->getSupportedLanguages(true);
 
         $language = strtolower(preg_replace('#[^a-z0-9_-]#i', '-', $option));
+        if ($language === 'js') $language = 'javascript';
         if (isset($allowedLanguages[$language]))
         {
             $config = $allowedLanguages[$language];
 
Only the phrase needs to change. It's incorrect, it should be [code=javascript] and we didn't support that type prior to XF2.
 
Back
Top Bottom