Skip to content

Commit 2e59b0f

Browse files
jhildenbiddleKoooooo-7sy-records
authored
feat: GitHub style callouts (#2487)
Co-authored-by: Koy Zhuang <[email protected]> Co-authored-by: Luffy <[email protected]>
1 parent 9bc58c9 commit 2e59b0f

25 files changed

+324
-96
lines changed

build/emoji.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ function writeEmojiJS(emojiData) {
7575
const isExistingPage = fs.existsSync(filePaths.emojiJS);
7676
const emojiJS = isExistingPage && fs.readFileSync(filePaths.emojiJS, 'utf8');
7777
const newEmojiJS = [
78-
'/* eslint-disable */\n',
7978
'// =============================================================================',
8079
'// DO NOT EDIT: This file is auto-generated by an /build/emoji.js',
8180
'// =============================================================================\n',

docs/adding-pages.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ To create section headers:
6767

6868
You need to create a `.nojekyll` in `./docs` to prevent GitHub Pages from ignoring files that begin with an underscore.
6969

70-
!> Docsify only looks for `_sidebar.md` in the current folder, and uses that, otherwise it falls back to the one configured using `window.$docsify.loadSidebar` config.
70+
> [!IMPORTANT] Docsify only looks for `_sidebar.md` in the current folder, and uses that, otherwise it falls back to the one configured using `window.$docsify.loadSidebar` config.
7171
7272
Example file structure:
7373

@@ -98,7 +98,7 @@ You can specify `alias` to avoid unnecessary fallback.
9898
</script>
9999
```
100100

101-
!> You can create a `README.md` file in a subdirectory to use it as the landing page for the route.
101+
> [!IMPORTANT] You can create a `README.md` file in a subdirectory to use it as the landing page for the route.
102102
103103
## Set Page Titles from Sidebar Selection
104104

docs/cdn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Uncompressed resources are available by omitting the `.min` from the filename.
2929

3030
Specifying the latest major version allows your site to receive all non-breaking enhancements ("minor" updates) and bug fixes ("patch" updates) as they are released. This is good option for those who prefer a zero-maintenance way of keeping their site up to date with minimal risk as new versions are published.
3131

32-
?> When a new major version is released, you will need to manually update the major version number after the `@` symbol in your CDN URLs.
32+
> [!TIP] When a new major version is released, you will need to manually update the major version number after the `@` symbol in your CDN URLs.
3333
3434
<!-- prettier-ignore -->
3535
```html
@@ -44,7 +44,7 @@ Specifying the latest major version allows your site to receive all non-breaking
4444

4545
Specifying an exact version prevents any future updates from affecting your site. This is good option for those who prefer to manually update their resources as new versions are published.
4646

47-
?> When a new version is released, you will need to manually update the version number after the `@` symbol in your CDN URLs.
47+
> [!TIP] When a new version is released, you will need to manually update the version number after the `@` symbol in your CDN URLs.
4848
4949
<!-- prettier-ignore -->
5050
```html

docs/configuration.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ Key `bindings` are defined as case insensitive string values separated by `+`. M
303303

304304
The `callback` function receive a [keydown event](https://developer.mozilla.org/en-US/docs/Web/API/Element/keydown_event) as an argument.
305305

306-
!> Let site visitors know your custom key bindings are available! If a binding is associated with a DOM element, consider inserting a `<kbd>` element as a visual cue (e.g., <kbd>alt</kbd> + <kbd>a</kbd>) or adding [title](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title) and [aria-keyshortcuts](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-keyshortcuts) attributes for hover/focus hints.
306+
> [!IMPORTANT] Let site visitors know your custom key bindings are available! If a binding is associated with a DOM element, consider inserting a `<kbd>` element as a visual cue (e.g., <kbd>alt</kbd> + <kbd>a</kbd>) or adding [title](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title) and [aria-keyshortcuts](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-keyshortcuts) attributes for hover/focus hints.
307307
308308
```js
309309
window.$docsify = {
@@ -378,7 +378,7 @@ window.$docsify = {
378378

379379
Website logo as it appears in the sidebar. You can resize it using CSS.
380380

381-
!> Logo will only be visible if `name` prop is also set. See [name](#name) configuration.
381+
> [!IMPORTANT] Logo will only be visible if `name` prop is also set. See [name](#name) configuration.
382382
383383
```js
384384
window.$docsify = {
@@ -921,7 +921,7 @@ For more details, see [#1131](https://github.com/docsifyjs/docsify/issues/1131).
921921

922922
## themeColor ⚠️ :id=themecolor
923923

924-
!> Deprecated as of v5. Use the `--theme-color` [theme property](themes#theme-properties) to [customize](themes#customization) your theme color.
924+
> [!IMPORTANT] Deprecated as of v5. Use the `--theme-color` [theme property](themes#theme-properties) to [customize](themes#customization) your theme color.
925925
926926
- Type: `String`
927927

@@ -935,7 +935,7 @@ window.$docsify = {
935935

936936
## topMargin ⚠️ :id=topmargin
937937

938-
!> Deprecated as of v5. Use the `--scroll-padding-top` [theme property](themes#theme-properties) to specify a scroll margin when using a sticky navbar.
938+
> [!IMPORTANT] Deprecated as of v5. Use the `--scroll-padding-top` [theme property](themes#theme-properties) to specify a scroll margin when using a sticky navbar.
939939
940940
- Type: `Number|String`
941941
- Default: `0`

docs/custom-navbar.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
If you need custom navigation, you can create a HTML-based navigation bar.
66

7-
!> Note that documentation links begin with `#/`.
7+
> [!IMPORTANT] Note that documentation links begin with `#/`.
88
99
```html
1010
<!-- index.html -->
@@ -51,7 +51,7 @@ To create drop-down menus:
5151
- [chinese](/zh-cn/)
5252
```
5353

54-
!> You need to create a `.nojekyll` in `./docs` to prevent GitHub Pages from ignoring files that begin with an underscore.
54+
> [!IMPORTANT] You need to create a `.nojekyll` in `./docs` to prevent GitHub Pages from ignoring files that begin with an underscore.
5555
5656
`_navbar.md` is loaded from each level directory. If the current directory doesn't have `_navbar.md`, it will fall back to the parent directory. If, for example, the current path is `/guide/quick-start`, the `_navbar.md` will be loaded from `/guide/_navbar.md`.
5757

docs/deploy.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ It is recommended that you save your files to the `./docs` subfolder of the `mai
1414

1515
![GitHub Pages](_images/deploy-github-pages.png)
1616

17-
!> You can also save files in the root directory and select `main branch`.
18-
You'll need to place a `.nojekyll` file in the deploy location (such as `/docs` or the gh-pages branch)
17+
> [!IMPORTANT] You can also save files in the root directory and select `main branch`.
18+
> You'll need to place a `.nojekyll` file in the deploy location (such as `/docs` or the gh-pages branch)
1919
2020
## GitLab Pages
2121

2222
If you are deploying your master branch, create a `.gitlab-ci.yml` with the following script:
2323

24-
?> The `.public` workaround is so `cp` doesn't also copy `public/` to itself in an infinite loop.
24+
> [!TIP] The `.public` workaround is so `cp` doesn't also copy `public/` to itself in an infinite loop.
2525
2626
```YAML
2727
pages:
@@ -37,11 +37,11 @@ pages:
3737
- master
3838
```
3939
40-
!> You can replace script with `- cp -r docs/. public`, if `./docs` is your Docsify subfolder.
40+
> [!IMPORTANT] You can replace script with `- cp -r docs/. public`, if `./docs` is your Docsify subfolder.
4141

4242
## Firebase Hosting
4343

44-
!> You'll need to install the Firebase CLI using `npm i -g firebase-tools` after signing into the [Firebase Console](https://console.firebase.google.com) using a Google Account.
44+
> [!IMPORTANT] You'll need to install the Firebase CLI using `npm i -g firebase-tools` after signing into the [Firebase Console](https://console.firebase.google.com) using a Google Account.
4545

4646
Using a terminal, determine and navigate to the directory for your Firebase Project. This could be `~/Projects/Docs`, etc. From there, run `firebase init` and choose `Hosting` from the menu (use **space** to select, **arrow keys** to change options and **enter** to confirm). Follow the setup instructions.
4747

docs/embed-files.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Example:
7575

7676
If you embed the file as `iframe`, `audio` and `video`, then you may need to set the attributes of these tags.
7777

78-
?> Note, for the `audio` and `video` types, docsify adds the `controls` attribute by default. When you want add more attributes, the `controls` attribute need to be added manually if need be.
78+
> [!TIP] Note, for the `audio` and `video` types, docsify adds the `controls` attribute by default. When you want add more attributes, the `controls` attribute need to be added manually if need be.
7979
8080
```md
8181
[filename](_media/example.mp4 ':include :type=video controls width=100%')
@@ -101,13 +101,13 @@ Embedding any type of source code file, you can specify the highlighted language
101101

102102
[](_media/example.html ':include :type=code text')
103103

104-
?> How to set highlight? You can see [here](language-highlight.md).
104+
> [!TIP] How to set highlight? You can see [here](language-highlight.md).
105105
106106
## Embed a gist
107107

108108
You can embed a gist as markdown content or as a code block - this is based on the approach at the start of [Embed Files](#embed-files) section, but uses a raw gist URL as the target.
109109

110-
?> **No** plugin or app config change is needed here to make this work. In fact, the "Embed" `script` tag that is copied from a gist will _not_ load even if you make plugin or config changes to allow an external script.
110+
> [!TIP] **No** plugin or app config change is needed here to make this work. In fact, the "Embed" `script` tag that is copied from a gist will _not_ load even if you make plugin or config changes to allow an external script.
111111
112112
### Identify the gist's metadata
113113

@@ -132,7 +132,7 @@ Here are two examples based on the sample gist:
132132
- https://gist.githubusercontent.com/anikethsaha/f88893bb563bb7229d6e575db53a8c15/raw/content.md
133133
- https://gist.githubusercontent.com/anikethsaha/f88893bb563bb7229d6e575db53a8c15/raw/script.js
134134

135-
?> Alternatively, you can get a raw URL directly clicking the _Raw_ button on a gist file. But, if you use that approach, just be sure to **remove** the revision number between `raw/` and the filename so that the URL matches the pattern above instead. Otherwise your embedded gist will **not** show the latest content when the gist is updated.
135+
> [!TIP] Alternatively, you can get a raw URL directly clicking the _Raw_ button on a gist file. But, if you use that approach, just be sure to **remove** the revision number between `raw/` and the filename so that the URL matches the pattern above instead. Otherwise your embedded gist will **not** show the latest content when the gist is updated.
136136
137137
Continue with one of the sections below to embed the gist on a Docsify page.
138138

docs/helpers.md

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,72 +6,106 @@ docsify extends Markdown syntax to make your documents more readable.
66
77
## Callouts
88

9-
### Important content
9+
Docsify supports [GitHub style](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts) callouts (also known as "admonitions" or "alerts").
1010

11-
Important content like:
11+
<!-- prettier-ignore -->
12+
> [!CAUTION]
13+
> **Caution** callouts communicate negative potential consequences of an action.
1214
13-
```markdown
14-
!> **Time** is money, my friend!
15-
```
15+
<!-- prettier-ignore -->
16+
> [!IMPORTANT]
17+
> **Important** callouts communicate information necessary for users to succeed.
1618
17-
is rendered as:
19+
<!-- prettier-ignore -->
20+
> [!NOTE]
21+
> **Note** callouts communicate information that users should take into account.
1822
19-
!> **Time** is money, my friend!
23+
<!-- prettier-ignore -->
24+
> [!TIP]
25+
> **Tip** callouts communicate optional information to help a user be more successful.
2026
21-
### Tips
27+
<!-- prettier-ignore -->
28+
> [!WARNING]
29+
> **Warning** callouts communicate potential risks user should be aware of.
2230
23-
General tips like:
31+
**Markdown**
2432

33+
<!-- prettier-ignore -->
2534
```markdown
26-
?> _TODO_ unit test
35+
> [!CAUTION]
36+
> **Caution** callouts communicate negative potential consequences of an action.
37+
38+
> [!IMPORTANT]
39+
> **Important** callouts communicate information necessary for users to succeed.
40+
41+
> [!NOTE]
42+
> **Note** callouts communicate information that users should take into account.
43+
44+
> [!TIP]
45+
> **Tip** callouts communicate optional information to help a user be more successful.
46+
47+
> [!WARNING]
48+
> **Warning** callouts communicate potential risks user should be aware of.
2749
```
2850

29-
are rendered as:
51+
### Legacy Style ⚠️
3052

31-
?> _TODO_ unit test
53+
The following Docsify v4 callout syntax has been deprecated and will be removed in a future version.
54+
55+
!> Legacy **Important** callouts are deprecated.
56+
57+
?> Legacy **Tip** callouts are deprecated.
58+
59+
**Markdown**
60+
61+
```markdown
62+
!> Legacy **Important** callouts are deprecated.
63+
64+
?> Legacy **Tip** callouts are deprecated.
65+
```
3266

3367
## Link attributes
3468

3569
### disabled
3670

37-
```md
71+
```markdown
3872
[link](/demo ':disabled')
3973
```
4074

4175
### href
4276

4377
Sometimes we will use some other relative path for the link, and we have to tell docsify that we don't need to compile this link. For example:
4478

45-
```md
79+
```markdown
4680
[link](/demo/)
4781
```
4882

4983
It will be compiled to `<a href="/#/demo/">link</a>` and will load `/demo/README.md`. Maybe you want to jump to `/demo/index.html`.
5084

5185
Now you can do that
5286

53-
```md
87+
```markdown
5488
[link](/demo/ ':ignore')
5589
```
5690

5791
You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set the title for the link.
5892

59-
```md
93+
```markdown
6094
[link](/demo/ ':ignore title')
6195

6296
<a href="/demo/" title="title">link</a>
6397
```
6498

6599
### target
66100

67-
```md
101+
```markdown
68102
[link](/demo ':target=_blank')
69103
[link](/demo2 ':target=_self')
70104
```
71105

72106
## Task lists
73107

74-
```md
108+
```markdown
75109
- [ ] foo
76110
- bar
77111
- [x] baz
@@ -91,7 +125,7 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set th
91125

92126
### Class names
93127

94-
```md
128+
```markdown
95129
![logo](https://docsify.js.org/_media/icon.svg ':class=someCssClass')
96130

97131
<!-- Multiple class names -->
@@ -101,13 +135,13 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set th
101135

102136
### IDs
103137

104-
```md
138+
```markdown
105139
![logo](https://docsify.js.org/_media/icon.svg ':id=someCssId')
106140
```
107141

108142
### Sizes
109143

110-
```md
144+
```markdown
111145
![logo](https://docsify.js.org/_media/icon.svg ':size=WIDTHxHEIGHT')
112146
![logo](https://docsify.js.org/_media/icon.svg ':size=50x100')
113147
![logo](https://docsify.js.org/_media/icon.svg ':size=100')
@@ -123,7 +157,7 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set th
123157

124158
## Heading IDs
125159

126-
```md
160+
```markdown
127161
### Hello, world! :id=hello-world
128162
```
129163

docs/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
disabled
4848
/>
4949

50+
<!-- Prism Theme -->
51+
<!-- <link
52+
rel="stylesheet"
53+
href="//cdn.jsdelivr.net/npm/[email protected]/themes/prism-twilight.min.css"
54+
/> -->
55+
5056
<!-- Site styles -->
5157
<style>
5258
/* Plugin: Carbon Ads */

docs/language-highlight.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function add(a, b) {
5757

5858
Support for additional [languages](https://prismjs.com/#supported-languages) is available by loading the Prism [grammar files](https://cdn.jsdelivr.net/npm/prismjs@1/components/):
5959

60-
!> Prism grammar files must be loaded after Docsify.
60+
> [!IMPORTANT] Prism grammar files must be loaded after Docsify.
6161
6262
```html
6363
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-bash.min.js"></script>
@@ -79,7 +79,7 @@ Support for additional [languages](https://prismjs.com/#supported-languages) is
7979

8080
Docsify's official [themes](themes) are compatible with Prism syntax highlighting themes.
8181

82-
!> Prism themes must be loaded after Docsify themes.
82+
> [!IMPORTANT] Prism themes must be loaded after Docsify themes.
8383
8484
```html
8585
<!-- Light and dark mode -->

0 commit comments

Comments
 (0)