Help with Markdown Previewer[solved]

Help with Markdown Previewer[solved]
0

#1

Hi,

Freecodecamp suggest the use of marked.js for this project so I’ve tried to use it but I’m getting an error.

the code:

var marked = require('marked');
marked.setOptions({
  renderer: new marked.Renderer(),
  gfm: true,
  tables: true,
  breaks: false,
  pedantic: false,
  sanitize: false,
  smartLists: true,
  smartypants: false
});

console.log(marked('I am using __markdown__.'));

the error:

require is not defined

I change the JavaScript Preprocessor to babel and added React and reactDom but nothing changes.

I don’t know if I’m supposed to use react or not.( I have never used react)

Thanks.


#2

You can’t use require inside the browser unless you use something like browserify. Instead you can just import the library with a script tag.

Code example on their GitHub page: https://github.com/chjj/marked#browser