sinedied / hads

:books: Markdown superpowered documentation for Node.js
MIT License
167 stars 28 forks source link

Fix crashing on highlighting an unsupported language #43

Closed igorskh closed 5 years ago

igorskh commented 5 years ago

Issue There is a block of code in the markdown document for example:

```[language]

Some text here

```

If the [language] is not supported by highlight.js, the highlight.highlight() throws an exception and the rendering crashes. The browser gets an error Cannot GET with the code 404 Not Found.

Suggested fix Add a try-catch block when calling highlight method. Render a plain text and throw an error log instead of interrupting a renderer.

sinedied commented 5 years ago

Looks good, thanks for the fix! 👍