Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't throw an exception for unknown code block languages #810

Closed
aaronpk opened this issue Sep 18, 2016 · 3 comments
Closed

Don't throw an exception for unknown code block languages #810

aaronpk opened this issue Sep 18, 2016 · 3 comments

Comments

@aaronpk
Copy link

aaronpk commented Sep 18, 2016

In my source content, I have:

```HTTP
stuff
```

This results in a Javascript error:

example.html:28 Uncaught Error: Unknown language: "HTTP"
Please report this to https://github.com/chjj/marked.

If an unknown language is encountered, it should be treated as plain text rather than throwing an exception.

@Feder1co5oave
Copy link
Contributor

I'm pretty sure this is highlight.js throwing the exception, and marked just reports it. What options are you using?

@acorbel
Copy link

acorbel commented Oct 22, 2016

To prevent this exception, I did:

markedProvider.setOptions({
            gfm: true,
            tables: true,
            breaks: false,
            pedantic: false,
            sanitize: true, // if false -> allow plain old HTML ;)
            smartLists: true,
            smartypants: false,
            highlight: function (code, lang) {
              if (lang && hljs.getLanguage(lang)) {
                return hljs.highlight(lang, code, true).value;
              } else {
                return hljs.highlightAuto(code).value;
              }
            }
          });

Hope it helps.

@joshbruce
Copy link
Member

#983

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants