From 76050e36801eb97b725ba65038747e6bc10ecb8e Mon Sep 17 00:00:00 2001 From: Joe Pea Date: Sat, 27 Jun 2020 03:05:16 -0700 Subject: [PATCH 1/3] Update language-highlight.md (#1251) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update language-highlight.md * Update language-highlight.md Co-authored-by: 沈唁 <52o@qq52o.cn> --- docs/language-highlight.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/language-highlight.md b/docs/language-highlight.md index 0d66b55b7..25b5bb5d4 100644 --- a/docs/language-highlight.md +++ b/docs/language-highlight.md @@ -8,4 +8,25 @@ ``` +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: + +```` +```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 +{ + return 123; +} +``` +```` + ?> Check the [component files](https://github.com/PrismJS/prism/tree/gh-pages/components) list for more options. From 88f8a8003ce2bbeadaf8d6599a97155daf31febf Mon Sep 17 00:00:00 2001 From: John Hildenbiddle Date: Thu, 2 Jul 2020 18:20:39 -0500 Subject: [PATCH 2/3] Update language-highlight.md Proposed changes described in comment from #1251 --- docs/language-highlight.md | 45 ++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/docs/language-highlight.md b/docs/language-highlight.md index 25b5bb5d4..1e089c10d 100644 --- a/docs/language-highlight.md +++ b/docs/language-highlight.md @@ -1,32 +1,53 @@ -# 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" ``` + +```php +function getAdder(int $x): int +{ + return 123; +} +``` ```` -?> 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. +The above markdown will be rendered as: -For `prism-php.js`, it would be: +```html +

This is a paragraph

+Docsify +``` + +```bash +echo "hello" +``` -```` ```php function getAdder(int $x): int { return 123; } ``` -```` - -?> Check the [component files](https://github.com/PrismJS/prism/tree/gh-pages/components) list for more options. From cd9df2de51cb7a0ad4252952a4c8ae42b3bd3848 Mon Sep 17 00:00:00 2001 From: John Hildenbiddle Date: Thu, 2 Jul 2020 18:26:05 -0500 Subject: [PATCH 3/3] Update index.html Add PHP grammar file for Prism.js --- docs/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/index.html b/docs/index.html index 050b21dde..f8487ddb3 100644 --- a/docs/index.html +++ b/docs/index.html @@ -98,6 +98,7 @@ +