Marked throwing errors (Markdown) - Meteor

624 Views Asked by At

So I've been trying to get some type of markdown plugin for converting the markdown syntax into html but I am having lots of trouble. I am using meteor, however, I am not sure if that's really an issue.

I've tried the following plugin called: Marked (https://github.com/chjj/marked)

And I get these errors with it

Uncaught ReferenceError: Markdown is not defined Markdown.Editor.js?e08938e553cc97311ffd455d7241f8fc57c82b64:52
(anonymous function) Markdown.Editor.js?e08938e553cc97311ffd455d7241f8fc57c82b64:52
(anonymous function) Markdown.Editor.js?e08938e553cc97311ffd455d7241f8fc57c82b64:2120
(anonymous function) Markdown.Editor.js?e08938e553cc97311ffd455d7241f8fc57c82b64:2122
Uncaught TypeError: Cannot read property 'Converter' of undefined Markdown.Sanitizer.js?95ec2c6ab6938e5f2fb3d6cc600e6f43c2c3f13a:8
(anonymous function) Markdown.Sanitizer.js?95ec2c6ab6938e5f2fb3d6cc600e6f43c2c3f13a:8
(anonymous function) Markdown.Sanitizer.js?95ec2c6ab6938e5f2fb3d6cc600e6f43c2c3f13a:111
(anonymous function) Markdown.Sanitizer.js?95ec2c6ab6938e5f2fb3d6cc600e6f43c2c3f13a:113

I've tried other plugins like pagedown-bootstrap and other versions of the same plugin and I get similar errors with them too.

Is there something specific I am missing?

1

There are 1 best solutions below

1
On

I had this same error when using Pagedown. I think my problem was that Markdown.Sanitizer.js was being loaded too early, so window.Markdown didn't exist yet for it.

I fixed it by moving everything from Markdown.Sanitizer.js into Markdown.Converter.js. The end result can be seen on my Github (search for "Markdown.getSanitizingConverter" to see the Sanitizer.js content down near the end).

Then I don't load Markdown.Sanitizer.js, only the above Markdown.Converter.js and the usual Markdown.Editor.js. This seems to have fixed it for me.

If anyone with some more knowledge would like to weigh in on this it would be much appreciated.