How to use the post parser(s) installed as if what you want parsed is a post
Say I want the following text parsed:
Blah blah blah **bold** and stuff Markdown is fun ----------- [link](http://example.com)
And to come out like this:
Blah blah blah bold and stuff
Markdown is fun
How would I do this with the enabled post parser in NodeBB?
I imagine it requires triggering a hook.
@pitaj sometime ago I searched the same, and I found it in @Schamper 's plugin Shoutbox https://github.com/Schamper/nodebb-plugin-shoutbox/blob/master/lib/backend.js#L107-L122
By the way why you all are using
var plugins = module.parent.require('./plugins');
such strange pattern for requiring modules?
In some places of my plugins, I'd have to do
var db = module.parent.parent.parent.parent.parent.require( './database' );
Of course this way works, but personally I prefer the method which looks purer
var db = require.main.require( './src/database' );
@Schamper Majide? O_ O
In a nutshell, inside all plugins, as well as inside all core modules
require.mainis always equals to
modulevariable that live inside
One important question: Is there the same behaviour in cluster-mode?
So it needs a confirmation from core developers.
Keep in mind
require.main's "scope" is
app.js, so you'd have to do
require.main.require('./src/groups.js');if you want access to the groups lib.
require.mainwill always be
app.jsfor plugins, since plugins are only called by NodeBB.