diff --git a/docs/language-highlight.md b/docs/language-highlight.md index 25b5bb5d..1e089c10 100644 --- a/docs/language-highlight.md +++ b/docs/language-highlight.md @@ -1,26 +1,31 @@ -# language highlight +# Language highlighting -**docsify** uses [Prism](https://github.com/PrismJS/prism) to highlight code blocks in your pages. By default it only supports CSS, JavaScript and HTML. You can make **Prism** load additional languages: +Docsify uses [Prism](https://prismjs.com) to highlight code blocks in your pages. Prism supports the following languages by default: + +* Markup - `markup`, `html`, `xml`, `svg`, `mathml`, `ssml`, `atom`, `rss` +* CSS - `css` +* C-like - `clike` +* JavaScript - `javascript`, `js` + +Support for [additional languages](https://prismjs.com/#supported-languages) is available by loading the language-specific [grammar files](https://cdn.jsdelivr.net/npm/prismjs@1/components/) via CDN: ```html - - - + + ``` -To use the new languages, make sure the code block label matches the part after `prism-` in the file name. FOr example, for `prism-bash.js` write a code block labeled with `bash` like this: +To enable syntax highlighting, wrap each code block in triple backticks with the [language](https://prismjs.com/#supported-languages) specified on the first line: ```` +```html +
This is a paragraph
+Docsify +``` + ```bash echo "hello" ``` -```` -?> Note that with GitHub-flavored markdown, `sh` and `bash` are effectively aliases of each other, but this is not the case with Prism. So using `sh` will not enable `bash` syntax in this case. - -For `prism-php.js`, it would be: - -```` ```php function getAdder(int $x): int { @@ -29,4 +34,20 @@ function getAdder(int $x): int ``` ```` -?> Check the [component files](https://github.com/PrismJS/prism/tree/gh-pages/components) list for more options. +The above markdown will be rendered as: + +```html +This is a paragraph
+Docsify +``` + +```bash +echo "hello" +``` + +```php +function getAdder(int $x): int +{ + return 123; +} +```