A Showdown extension for highlight the code blocks.
npm install showdown-highlight 
> A Showdown extension for highlight the code blocks.
This package uses highlight.js to highlight code blocks in Showdown output. :rocket:
``shUsing npm
npm install --save showdown-highlight
:clipboard: Example
`js
const showdown = require('showdown')
, showdownHighlight = require("showdown-highlight")
;// After requiring the module, use it as extension
let converter = new showdown.Converter({
// That's it
extensions: [showdownHighlight({
// Whether to add the classes to the
tag, default is false
pre: true
// Whether to use hljs' auto language detection, default is true
, auto_detection: true
})]
});// Now you can Highlight code blocks
let html = converter.makeHtml(
Below we have a piece of JavaScript code:
\\\js\${who} says: msg\
function sayHello (msg, who) {
return \;\
}
sayHello("Hello World", "Johnny");
\\);
console.log(html);
//
Below we have a piece of JavaScript code:
function sayHello (msg, who) {
// return ${who} says: msg;
// }
// sayHello("Hello World", "Johnny");
// :question: Get Help
There are few ways to get help:
1. Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
2. For bug reports and feature requests, open issues. :bug:
:memo: Documentation
$3
Highlight the code in the showdown input.Examples:
`js
let converter = new showdown.Converter({
extensions: [showdownHighlight]
})
`Enable the classes in the
element:`js`
let converter = new showdown.Converter({
extensions: [showdownHighlight({ pre: true })]
})auto_detectionIf you want to disable language auto detection
feature of hljs, changeflag asfalse. With this optionshowdown-highlight
turned off,will not process any codeblocks with no`
language specified.js`
let converter = new showdown.Converter({
extensions: [showdownHighlight({ auto_detection: false })]
})mdpdf
:yum: How to contribute
Have an idea? Found a bug? See [how to contribute][contributing].
:dizzy: Where is this library used?
If you are using this library in one of your projects, add it in this list. :sparkles:-
bloggify-markdown-highlight
-github-readme-to-html
-md-toy-blog
-@kev_nz/publisher
-@etermind/alex
-@siradoc/siradoc
-@web-native-js/chtml-cli
-swanky
-md-srv
-docset-tools-markdown
-callete
-teroshdl2
-ui_kitchenadmincenter
-trumpdoc
-@peersky/next-web3-chakra
-mdpdf_jm
-textbase
-teroshdl
-showdown-html
-busi-ui
-md-browse
-markdown2dash
-tutors-reader-lib
-tutors-html-beta
-tutors-html
-examma-ray
-steelsky
-chimpsky
-ember-showdown-highlight
-showit
-tutors-html-alpha`
-:scroll: License
[MIT][license] © [Bloggify][website]
[license]: /LICENSE
[website]: https://bloggify.org
[contributing]: /CONTRIBUTING.md
[docs]: /DOCUMENTATION.md