title: markdown is not a function
body: <p>markdown is not a function , though i have installed it using <code>npm install marked</code>
  In the app.js i have used app.use in which res.local.filterUserHTML is a function,
  which uses markdown function, But when this is invoked it gives error, stating it doesn't recognize the markdown function.</p>
  <p><strong>app.js</strong></p>
  <pre><code>const sanitizeHTML = require('sanitize-html')
  const markdown = require('marked')
  
  app.use(function(req, res, next) {
    
    res.locals.filterUserHTML = function(content) {
      return sanitizeHTML(markdown(content), {allowedTags: ['bold', 'i'], allowedAttributes: {}})
    }
  }
  </code></pre>
  <p><strong>single-post-screen.ejs</strong></p>
  <pre><code>...
   &lt;div class=&quot;body-content&quot;&gt;
      &lt;%- filterUserHTML(post.body) %&gt;
    &lt;/div&gt;
  ...
  </code></pre>
  <p>Output gives an error</p>
  <pre><code>TypeError: E:\Web Development\Javascript\Javascript Full Stack from Scratch\ComplexApp\views\single-post-screen.ejs:44
      42| 
      43|   &lt;div class=&quot;body-content&quot;&gt;
   &gt;&gt; 44|     &lt;%- filterUserHTML(post.body) %&gt;
      45|   &lt;/div&gt;
      46| 
      47|   
  
  markdown is not a function
      at Object.res.locals.filterUserHTML (E:\Web Development\Javascript\Javascript Full Stack from Scratch\ComplexApp\app.js:41:25)
      at eval (eval at compile (E:\Web Development\Javascript\Javascript Full Stack from Scratch\ComplexApp\node_modules\ejs\lib\ejs.js:662:12), &lt;anonymous&gt;:47:17)
      at single-post-screen (E:\Web Development\Javascript\Javascript Full Stack from Scratch\ComplexApp\node_modules\ejs\lib\ejs.js:692:17)
      at tryHandleCache (E:\Web Development\Javascript\Javascript Full Stack from Scratch\ComplexApp\node_modules\ejs\lib\ejs.js:272:36)
      at View.exports.renderFile [as engine] (E:\Web Development\Javascript\Javascript Full Stack from Scratch\ComplexApp\node_modules\ejs\lib\ejs.js:489:10)
      at View.render (E:\Web Development\Javascript\Javascript Full Stack from Scratch\ComplexApp\node_modules\express\lib\view.js:135:8)
      at tryRender (E:\Web Development\Javascript\Javascript Full Stack from Scratch\ComplexApp\node_modules\express\lib\application.js:640:10)
      at Function.render (E:\Web Development\Javascript\Javascript Full Stack from Scratch\ComplexApp\node_modules\express\lib\application.js:592:3)
      at ServerResponse.render (E:\Web Development\Javascript\Javascript Full Stack from Scratch\ComplexApp\node_modules\express\lib\response.js:1017:7)
      at exports.viewSingle (E:\Web Development\Javascript\Javascript Full Stack from Scratch\ComplexApp\controllers\postController.js:25:9)
  </code></pre>