Any code format plugin?

NodeBB Plugins
  • Similar to markdown code block ``` but with additional of line numbers, is such plugin available?

    Please advise, thanks.

  • Put this in your custom header (ACP -> Appearance -> Custom HTML & CSS -> Custom Header):

    <script>
    require(['highlight'], function (hljs) {
      require([
        'https://cdnjs.cloudflare.com/ajax/libs/highlightjs-line-numbers.js/1.1.0/highlightjs-line-numbers.min.js'
      ], function () {
        $(window).on('load action:ajaxify.end', function () {
          setTimeout(function () {
            hljs.initLineNumbersOnLoad();
          }, 100);
        });
      });
    });
    </script>
    
  • @PitaJ said in Any code format plugin?:

    <script>
    require(['highlight'], function (hljs) {
    require([
    'https://cdnjs.cloudflare.com/ajax/libs/highlightjs-line-numbers.js/1.1.0/highlightjs-line-numbers.min.js'
    ], function () {
    $(window).on('load action:ajaxify.end', function () {
    setTimeout(function () {
    hljs.initLineNumbersOnLoad();
    }, 100);
    });
    });
    });
    </script>

    Perfect! 👍

  • @PitaJ

    This doesn't work for me (NodeBB v1.12.1). My plugins as below. Any ideas?

    nodebb-plugin-composer-default
    Default composer for NodeBB
    
    Installed 6.2.11 | Latest 6.2.11
    For more information: https://github.com/NodeBB/nodebb-plugin-composer-default#readme
    
    nodebb-plugin-dbsearch
    A Plugin that lets users search posts and topics
    
    Installed 3.0.6 | Latest 3.0.6
    For more information: https://github.com/barisusakli/nodebb-plugin-dbsearch#readme
    
    nodebb-plugin-emoji
    Adds extensible emoji functionality to NodeBB
    
     Installed 2.2.6 | Latest 3.2.0 
    For more information: https://github.com/NodeBB/nodebb-plugin-emoji#readme
    
    nodebb-plugin-emoji-android
    The Android blob emoji-set for NodeBB (requires nodebb-plugin-emoji)
    
    Installed 2.0.0 | Latest 2.0.0
    For more information: https://github.com/NodeBB-Community/nodebb-plugin-emoji-android#readme
    
    nodebb-plugin-extended-markdown
    A NodeBB plugin to add some bb code, as tooltip, anchor, custom text header with background, etc.
    
    Installed 1.4.0 | Latest 1.4.0
    For more information: https://github.com/MinecraftForgeFrance/nodebb-plugin-extended-markdown#readme
    
    nodebb-plugin-forms
    NodeBB plugin for form management
    
    Installed 0.0.1 | Latest 0.0.1
    For more information: https://github.com/NodeBB-Community/nodebb-plugin-forms
    
    nodebb-plugin-markdown
    A Markdown parser for NodeBB
    
    Installed 8.9.2 | Latest 8.9.2
    For more information: https://github.com/julianlam/nodebb-plugin-markdown#readme
    
    nodebb-plugin-mentions
    NodeBB Plugin that allows users to mention other users by prepending an '@' sign to their username
    
    Installed 2.5.2 | Latest 2.5.2
    For more information: https://github.com/julianlam/nodebb-plugin-mentions#readme
    
    nodebb-plugin-node-ldap
    Node LDAP Login
    
    Installed 1.0.0 | Latest 1.0.0
    For more information: https://github.com/ink-blot/nodebb-plugin-node-ldap
    
    nodebb-plugin-session-sharing
    Allows login sessions from your app to persist in NodeBB
    
    Installed 4.6.2 | Latest 4.6.2
    For more information: https://github.com/julianlam/nodebb-plugin-session-sharing#readme
    
    nodebb-plugin-soundpack-default
    Default Sound Pack
    
    Installed 1.0.0 | Latest 1.0.0
    For more information: https://github.com/julianlam/nodebb-plugin-soundpack-default
    
    nodebb-plugin-spam-be-gone
    anti spam using both Google Recaptcha, Akismet.com, StopForumSpam.com & ProjectHoneyPot.com
    
    Installed 0.6.1 | Latest 0.6.1
    For more information: https://github.com/akhoury/nodebb-plugin-spam-be-gone#readme
    
    nodebb-rewards-essentials
    Essential Rewards Starter Pack for NodeBB
    
    Installed 0.0.13 | Latest 0.0.13
    For more information: https://github.com/NodeBB/nodebb-rewards-essentials
    
    nodebb-theme-lavender
    Lavender Theme for NodeBB
    
    Installed 5.0.9 | Latest 5.0.9
    For more information: https://github.com/NodeBB/nodebb-theme-lavender#readme
    
    nodebb-theme-persona
    Persona theme for NodeBB
    
    Installed 9.1.29 | Latest 9.1.29
    For more information: https://github.com/psychobunny/nodebb-theme-persona#readme
    
    nodebb-theme-slick
    Slick theme for NodeBB
    
    Installed 1.2.23 | Latest 1.2.23
    For more information: https://github.com/pichalite/nodebb-theme-slick#readme
    
    nodebb-theme-vanilla
    Vanilla theme for NodeBB
    
    Installed 10.1.25 | Latest 10.1.25
    For more information: https://github.com/NodeBB/nodebb-theme-vanilla#readme
    
    nodebb-widget-essentials
    NodeBB Essential Widgets
    
    Installed 4.0.17 | Latest 4.0.17
    For more information: https://github.com/psychobunny/nodebb-widget-essentials#readme
    
  • Hmm. I tried pasting your script (without the script tags) into:
    ACP -> Appearance -> Custom HTML & CSS -> Custom Javascript

    and I got the following result:

    code_numbering.jpg

    Not usable, but a clue...

  • @quokka if you want line numbering in code blocks just go to admin/plugins/markdown and select it in CODE FORMATTING settings. You can even choose what languages will it apply to.

  • @oplik0

    Awesome. Legend. Thanks for that!


Suggested Topics


  • 0 Votes
    5 Posts
    423 Views

    RESOLVED

    If anyone else sees this thread... Don't be the american who thinks the default should be en-US....

    It appears that the nodeBB default language was set for en-GB

    If you need to adjust the language default setting:

    Go to your NodeBB ACP (admin control panel) => General => Languages

  • Resize Image Plugin

    Locked NodeBB Plugins
    0 Votes
    3 Posts
    2k Views

    Locking to limit discussion 😄

  • 1 Votes
    3 Posts
    3k Views

    Is it even possible to integrate a plug in that posts to a 'group'

    I'm sure FB only allows posting to fan pages and walls.

    That being said, I know you can do 'Canvas' app for NodeBB on FB, but this only integrates with FB notifiactions
    On the Browser, where as you'll find most of the time they check FB via mobile. And FB mobile is not compatible with
    Canvas or any external FB notifications.

    So you are probably going to be disappointed with it's results.

    Also, on that note. I've found it susccefull for mobile users, using a push notification app. That notifies users on events.
    And when they are notified, it refers them back to your forum. via a webui Browser in the app.
    This works great with a Responsive design or a dedicated mobile browser.

  • 2 Votes
    38 Posts
    15k Views

    I just updated to 0.7.2 and this plugin is throwing errors at me:

    4/8 06:06 [1752] - error: TypeError: undefined is not a function at Object.TopicBadges.addThreadTools [as method] (/opt/nodebb/node_modules/nodebb-plugin-topic-badges/library.js:29:15) at /opt/nodebb/src/plugins/hooks.js:89:12 at /opt/nodebb/node_modules/async/lib/async.js:269:13 at iterate (/opt/nodebb/node_modules/async/lib/async.js:146:13) at Object.async.eachSeries (/opt/nodebb/node_modules/async/lib/async.js:162:9) at Object.async.reduce (/opt/nodebb/node_modules/async/lib/async.js:268:15) at fireFilterHook (/opt/nodebb/src/plugins/hooks.js:81:9) at Plugins.fireHook (/opt/nodebb/src/plugins/hooks.js:62:5) at Object.threadTools (/opt/nodebb/node_modules/async/lib/async.js:653:23) at /opt/nodebb/node_modules/async/lib/async.js:580:25

    This happens when any topic is loaded with the addon enabled. Control panel reports 0.1.1 installed.

  • 1 Votes
    24 Posts
    9k Views

    awesome !!!