Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
Markdown no es una función

markdown no es una función, aunque lo instalé usando npm install marked En app.js he usado app.use en el que res.local.filterUserHTML es una función, que usa la función de descuento, pero cuando se invoca esto da error , indicando que no reconoce la función de descuento.

aplicación.js

 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: {}}) } }

sola-post-pantalla.ejs

 ... <div class="body-content"> <%- filterUserHTML(post.body) %> </div> ...

La salida da un error

 TypeError: E:\Web Development\Javascript\Javascript Full Stack from Scratch\ComplexApp\views\single-post-screen.ejs:44 42| 43| <div class="body-content"> >> 44| <%- filterUserHTML(post.body) %> 45| </div> 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), <anonymous>: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)
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

De los documentos :

 import { marked } from 'marked'; // or const { marked } = require('marked'); const html = marked.parse('# Marked in Node.js\n\nRendered by **marked**.');

Entonces, en lugar de usar markdown() , intente usar markdown.parse() .

about 4 years ago · Juan Pablo Isaza Report

0

Me encuentro con el problema cuando ejecuto observablehq/runtime.js en un entorno local. No sé por qué no funciona en mi computadora pero funcionó en otra. Tengo que modificar el runtime.js como sugirió @VaiTon.

 r.innerHTML = t.parse(n, { langPrefix: "" }).trim(); // call parse method of object t ie marked
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!