From 7bbf13d9bd48883ddf69f12e69d5d38e2b543856 Mon Sep 17 00:00:00 2001
From: Joe Pea
Date: Wed, 9 Aug 2023 02:53:30 -0700
Subject: [PATCH] Ensure code format (#2138)
* chore: add missing Vue support for Vercel builds
* refactor: move some functions and module-level state into classes as private methods and properties to start to encapsulate Docsify
Also some small tweaks:
- move initGlobalAPI out of Docsify.js to start to encapsulate Docsify
- move ajax to utils folder
- fix some type definitions and improve content in some JSDoc comments
- use concise class field syntax
- consolidate duplicate docsify-ignore comment removal code
This handles a task in [Simplify and modernize Docsify](https://github.com/docsifyjs/docsify/issues/2104), as well as works towards [Encapsulating Docsify](https://github.com/docsifyjs/docsify/issues/2135).
* chore: add prettier code format check to our lint script, and add a prettier script for manually formatting the whole code base
* chore: update issue/pr templates
* chore: apply our format to the whole code base
---------
Co-authored-by: Koy
Co-authored-by: i544693 <369491420@qq.com>
---
.github/ISSUE_TEMPLATE/bug_report.md | 55 +--
.github/ISSUE_TEMPLATE/config.yml | 4 +-
.github/ISSUE_TEMPLATE/feature_request.md | 31 +-
.github/PULL_REQUEST_TEMPLATE.md | 54 ++-
.github/dependabot.yml | 8 +-
.gitpod.yml | 2 +-
.prettierignore | 6 +
HISTORY.md | 1 +
README.md | 10 +-
SECURITY.md | 2 +-
build/build.js | 134 +++---
build/css.js | 77 ++--
build/mincss.js | 25 +-
docs/_media/example.html | 2 +-
docs/cdn.md | 17 +-
docs/cover.md | 10 +-
docs/custom-navbar.md | 36 +-
docs/deploy.md | 29 +-
docs/embed-files.md | 21 +-
docs/language-highlight.md | 17 +-
docs/markdown.md | 29 +-
docs/more-pages.md | 23 +-
docs/pwa.md | 57 +--
index.html | 7 +-
package.json | 3 +-
src/core/Docsify.js | 10 +-
src/core/config.js | 2 +-
src/core/event/index.js | 291 ++++++++++++-
src/core/event/scroll.js | 163 --------
src/core/event/sidebar.js | 106 -----
src/core/fetch/index.js | 125 +++---
src/core/global-api.js | 6 +-
src/core/index.js | 13 +-
src/core/init/lifecycle.js | 8 +-
src/core/render/compiler.js | 4 +-
src/core/render/compiler/headline.js | 4 +-
src/core/render/embed.js | 2 +-
src/core/render/index.js | 476 +++++++++++-----------
src/core/render/utils.js | 10 +-
src/core/router/history/base.js | 51 +--
src/core/router/history/hash.js | 6 +-
src/core/router/history/html5.js | 5 +-
src/core/router/index.js | 9 +-
src/core/{fetch => util}/ajax.js | 2 +-
src/core/util/str.js | 8 -
src/core/virtual-routes/index.js | 20 +-
src/core/virtual-routes/next.js | 4 +-
src/plugins/front-matter/parser.js | 32 +-
src/plugins/front-matter/yaml.js | 380 ++++++++---------
src/plugins/search/search.js | 10 +-
test/unit/render-util.test.js | 10 +-
51 files changed, 1241 insertions(+), 1176 deletions(-)
create mode 100644 .prettierignore
delete mode 100644 src/core/event/scroll.js
delete mode 100644 src/core/event/sidebar.js
rename src/core/{fetch => util}/ajax.js (98%)
delete mode 100644 src/core/util/str.js
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index cde2188..81a77b7 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -1,44 +1,53 @@
---
name: Bug report
-about: Create a report to help us improve
-
+about: Create a report to help us fix an issue
---
-
-
-
-
-
+
+
## Bug Report
#### Steps to reproduce
+
+#### Current behaviour
-#### What is current behaviour
-
-
-
-#### What is the expected behaviour
+
+#### Expected behaviour
+
#### Other relevant information
-
-- [ ] Bug does still occur when all/other plugins are disabled?
+- Docsify version:
-- Your OS:
-- Node.js version:
-- npm/yarn version:
-- Browser version:
-- Docsify version:
-- Docsify plugins:
+
-
+- [ ] Bug still occurs when all/other plugins are disabled?
-#### Please create a reproducible sandbox
+- Docsify plugins (if the bug happens when plugins enabled, please try to isolate the issue):
+
+
+
+
+
+#### Please create a reproducible sandbox
[![Edit 307qqv236](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/307qqv236)
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
index 83f0826..b0afe13 100644
--- a/.github/ISSUE_TEMPLATE/config.yml
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -1,5 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Discord - the community chat
- url: https://discord.gg/3NwKFyR
- about: Join Discord community and chat about Docsify
+ url: https://discord.gg/docsify
+ about: Join the Discord community and chat about Docsify
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index 501e4de..cb840f6 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -1,25 +1,32 @@
---
name: Feature request
about: Suggest an idea for this project
-
---
-
-
-
-
+
+
## Feature request
-#### What problem does this feature solve?
+#### Problem or desire
+
+#### Proposal
-#### What does the proposed API look like?
+
+#### Implementation
+
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 4e6fad0..9e1aea1 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -1,31 +1,25 @@
-## **Summary**
+## Summary
-
+## Related issue, if any:
-## **What kind of change does this PR introduce?**
+
+
+## What kind of change does this PR introduce?
+ Copy/paste any of the relevant following options:
-
-
+## For any code change,
-## **For any code change,**
+
-- [ ] Related documentation has been updated if needed
-- [ ] Related tests have been updated or tests have been added
+- [ ] Related documentation has been updated, if needed
+- [ ] Related tests have been added or updated, if needed
-## **Does this PR introduce a breaking change?** (check one)
+## Does this PR introduce a breaking change?
-- [ ] Yes
-- [ ] No
+
-If yes, please describe the impact and migration path for existing applications:
+Yes
+No
-## **Related issue, if any:**
+
-
-
-## **Tested in the following browsers:**
+## Tested in the following browsers:
- [ ] Chrome
- [ ] Firefox
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 6c246b1..affcf76 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -6,12 +6,12 @@
version: 2
updates:
- package-ecosystem: npm # See documentation for possible values
- directory: "/" # Location of package manifests
+ directory: '/' # Location of package manifests
open-pull-requests-limit: 10
schedule:
- interval: "weekly"
- - package-ecosystem: "github-actions"
- directory: "/"
+ interval: 'weekly'
+ - package-ecosystem: 'github-actions'
+ directory: '/'
open-pull-requests-limit: 10
schedule:
interval: monthly
diff --git a/.gitpod.yml b/.gitpod.yml
index 8113b45..41805e3 100644
--- a/.gitpod.yml
+++ b/.gitpod.yml
@@ -7,4 +7,4 @@ ports:
onOpen: ignore
vscode:
extensions:
- - sysoev.language-stylus@1.11.0:xX39oruAJ5UQzTNVRdbBaQ==
\ No newline at end of file
+ - sysoev.language-stylus@1.11.0:xX39oruAJ5UQzTNVRdbBaQ==
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 0000000..6c424db
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,6 @@
+CHANGELOG.md
+HISTORY.md
+lib/
+themes/
+_playwright-*/
+emoji-data.*
diff --git a/HISTORY.md b/HISTORY.md
index fb720fd..b5abee6 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -1,3 +1,4 @@
+
## [3.7.3](https://github.com/QingWei-Li/docsify/compare/v3.7.2...v3.7.3) (2017-05-22)
diff --git a/README.md b/README.md
index 54b0e6a..28ac045 100644
--- a/README.md
+++ b/README.md
@@ -27,7 +27,7 @@
-Docsify turns one or more Markdown files into a Website, with no build process required.
+Docsify turns one or more Markdown files into a Website, with no build process required.
## Features
@@ -57,14 +57,6 @@ A large collection of showcase projects are included in [awesome-docsify](https:
- [Awesome docsify](https://github.com/docsifyjs/awesome-docsify)
- [Community chat](https://discord.gg/3NwKFyR)
-## Similar Projects
-
-| Project | Description |
-| ------------------------------------------------ | ---------------------------------------- |
-| [Docusaurus](https://docusaurus.io) | Docusaurus makes it easy to maintain Open Source documentation websites |
-| [MkDocs](https://www.mkdocs.org) | Project documentation with Markdown |
-| [VitePress](https://vitepress.dev/) | Vite & Vue Powered Static Site Generator |
-
## Contributing
See [CONTRIBUTING.md](./CONTRIBUTING.md).
diff --git a/SECURITY.md b/SECURITY.md
index 1b9f6f9..f57d273 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -6,7 +6,7 @@ If you believe you have found a security vulnerability in docsify, please report
**Please do not report security vulnerabilities through our public GitHub issues.**
-Send email via :email: maintainers@docsifyjs.org to us.
+Send email to us via :email: maintainers@docsifyjs.org.
Please include as much of the following information as possible to help us better understand the possible issue:
diff --git a/build/build.js b/build/build.js
index 6a3726e..eb03b80 100644
--- a/build/build.js
+++ b/build/build.js
@@ -32,83 +32,89 @@ async function build(opts) {
nodeResolve(),
replace({
__VERSION__: version,
- })
+ }),
],
onwarn(message) {
if (message.code === 'UNRESOLVED_IMPORT') {
throw new Error(
`Could not resolve module ` +
- message.source +
- `. Try running 'npm install' or using rollup's 'external' option if this is an external dependency. ` +
- `Module ${message.source} is imported in ${message.importer}`
- )
+ message.source +
+ `. Try running 'npm install' or using rollup's 'external' option if this is an external dependency. ` +
+ `Module ${message.source} is imported in ${message.importer}`
+ );
}
- }
+ },
})
.then(bundle => {
- const dest = 'lib/' + (opts.output || opts.input)
+ const dest = 'lib/' + (opts.output || opts.input);
- console.log(dest)
+ console.log(dest);
return bundle.write({
format: 'iife',
- output: opts.globalName ? {name: opts.globalName} : {},
+ output: opts.globalName ? { name: opts.globalName } : {},
file: dest,
- strict: false
- })
- })
+ strict: false,
+ });
+ });
}
async function buildCore() {
- const promises = []
+ const promises = [];
- promises.push(build({
- input: 'src/core/index.js',
- output: 'docsify.js',
- }))
+ promises.push(
+ build({
+ input: 'src/core/index.js',
+ output: 'docsify.js',
+ })
+ );
if (isProd) {
- promises.push(build({
- input: 'src/core/index.js',
- output: 'docsify.min.js',
- plugins: [uglify()]
- }))
+ promises.push(
+ build({
+ input: 'src/core/index.js',
+ output: 'docsify.min.js',
+ plugins: [uglify()],
+ })
+ );
}
- await Promise.all(promises)
+ await Promise.all(promises);
}
async function buildAllPlugin() {
const plugins = [
- {name: 'search', input: 'search/index.js'},
- {name: 'ga', input: 'ga.js'},
- {name: 'gtag', input: 'gtag.js'},
- {name: 'matomo', input: 'matomo.js'},
- {name: 'emoji', input: 'emoji.js'},
- {name: 'external-script', input: 'external-script.js'},
- {name: 'front-matter', input: 'front-matter/index.js'},
- {name: 'zoom-image', input: 'zoom-image.js'},
- {name: 'disqus', input: 'disqus.js'},
- {name: 'gitalk', input: 'gitalk.js'}
- ]
+ { name: 'search', input: 'search/index.js' },
+ { name: 'ga', input: 'ga.js' },
+ { name: 'gtag', input: 'gtag.js' },
+ { name: 'matomo', input: 'matomo.js' },
+ { name: 'emoji', input: 'emoji.js' },
+ { name: 'external-script', input: 'external-script.js' },
+ { name: 'front-matter', input: 'front-matter/index.js' },
+ { name: 'zoom-image', input: 'zoom-image.js' },
+ { name: 'disqus', input: 'disqus.js' },
+ { name: 'gitalk', input: 'gitalk.js' },
+ ];
const promises = plugins.map(item => {
return build({
input: 'src/plugins/' + item.input,
- output: 'plugins/' + item.name + '.js'
- })
- })
+ output: 'plugins/' + item.name + '.js',
+ });
+ });
if (isProd) {
plugins.forEach(item => {
- promises.push(build({
- input: 'src/plugins/' + item.input,
- output: 'plugins/' + item.name + '.min.js',
- plugins: [uglify()]
- }))
- })
+ promises.push(
+ build({
+ input: 'src/plugins/' + item.input,
+ output: 'plugins/' + item.name + '.min.js',
+ plugins: [uglify()],
+ })
+ );
+ });
}
- await Promise.all(promises)
+ await Promise.all(promises);
}
async function main() {
@@ -118,41 +124,37 @@ async function main() {
atomic: true,
awaitWriteFinish: {
stabilityThreshold: 1000,
- pollInterval: 100
- }
+ pollInterval: 100,
+ },
})
.on('change', p => {
- console.log('[watch] ', p)
- const dirs = p.split(path.sep)
+ console.log('[watch] ', p);
+ const dirs = p.split(path.sep);
if (dirs[1] === 'core') {
- buildCore()
+ buildCore();
} else if (dirs[2]) {
- const name = path.basename(dirs[2], '.js')
+ const name = path.basename(dirs[2], '.js');
const input = `src/plugins/${name}${
/\.js/.test(dirs[2]) ? '' : '/index'
- }.js`
+ }.js`;
build({
input,
- output: 'plugins/' + name + '.js'
- })
+ output: 'plugins/' + name + '.js',
+ });
}
})
.on('ready', () => {
- console.log('[start]')
- buildCore()
- buildAllPlugin()
- })
+ console.log('[start]');
+ buildCore();
+ buildAllPlugin();
+ });
} else {
- await Promise.all([
- buildCore(),
- buildAllPlugin()
- ])
+ await Promise.all([buildCore(), buildAllPlugin()]);
}
}
-main().catch((e) => {
- console.error(e)
- process.exit(1)
-})
-
+main().catch(e => {
+ console.error(e);
+ process.exit(1);
+});
diff --git a/build/css.js b/build/css.js
index 1047c58..71a9dc9 100644
--- a/build/css.js
+++ b/build/css.js
@@ -1,47 +1,48 @@
-import fs from 'fs'
-import path from 'path'
-import {spawn} from 'child_process'
+import fs from 'fs';
+import path from 'path';
+import { spawn } from 'child_process';
const relative = path => new URL(path, import.meta.url);
-const args = process.argv.slice(2)
+const args = process.argv.slice(2);
fs.readdir(relative('../src/themes'), (err, files) => {
- if (err) {
- console.error('err', err)
- process.exit(1)
- }
- files.map(async (file) => {
- if (/\.styl/g.test(file)) {
- const stylusBin = ['node_modules', 'stylus', 'bin', 'stylus'].join(path.sep)
- let cmdargs = [
- stylusBin,
- `src/themes/${file}`,
- '-u',
- 'autoprefixer-stylus'
- ]
- cmdargs = [...cmdargs, ...args]
+ if (err) {
+ console.error('err', err);
+ process.exit(1);
+ }
+ files.map(async file => {
+ if (/\.styl/g.test(file)) {
+ const stylusBin = ['node_modules', 'stylus', 'bin', 'stylus'].join(
+ path.sep
+ );
+ let cmdargs = [
+ stylusBin,
+ `src/themes/${file}`,
+ '-u',
+ 'autoprefixer-stylus',
+ ];
+ cmdargs = [...cmdargs, ...args];
- const stylusCMD = spawn('node', cmdargs, { shell: true })
+ const stylusCMD = spawn('node', cmdargs, { shell: true });
- stylusCMD.stdout.on('data', (data) => {
- console.log(`[Stylus Build ] stdout: ${data}`);
- });
+ stylusCMD.stdout.on('data', data => {
+ console.log(`[Stylus Build ] stdout: ${data}`);
+ });
- stylusCMD.stderr.on('data', (data) => {
- console.error(`[Stylus Build ] stderr: ${data}`);
- });
+ stylusCMD.stderr.on('data', data => {
+ console.error(`[Stylus Build ] stderr: ${data}`);
+ });
- stylusCMD.on('close', (code) => {
- const message = `[Stylus Build ] child process exited with code ${code}`
+ stylusCMD.on('close', code => {
+ const message = `[Stylus Build ] child process exited with code ${code}`;
- if (code !== 0) {
- console.error(message);
- process.exit(code)
- }
- console.log(message);
- });
- } else {
- return
+ if (code !== 0) {
+ console.error(message);
+ process.exit(code);
}
-
- })
-})
+ console.log(message);
+ });
+ } else {
+ return;
+ }
+ });
+});
diff --git a/build/mincss.js b/build/mincss.js
index 05b8d77..3e42060 100644
--- a/build/mincss.js
+++ b/build/mincss.js
@@ -1,15 +1,18 @@
import cssnano from 'cssnano';
-import path from 'path'
-import fs from 'fs'
+import path from 'path';
+import fs from 'fs';
-const files = fs.readdirSync(path.resolve('lib/themes'))
+const files = fs.readdirSync(path.resolve('lib/themes'));
files.forEach(file => {
- file = path.resolve('lib/themes', file)
- cssnano.process(fs.readFileSync(file)).then(result => {
- fs.writeFileSync(file, result.css)
- }).catch(e => {
- console.error(e)
- process.exit(1)
- })
-})
+ file = path.resolve('lib/themes', file);
+ cssnano
+ .process(fs.readFileSync(file))
+ .then(result => {
+ fs.writeFileSync(file, result.css);
+ })
+ .catch(e => {
+ console.error(e);
+ process.exit(1);
+ });
+});
diff --git a/docs/_media/example.html b/docs/_media/example.html
index d35ee16..9820b4c 100644
--- a/docs/_media/example.html
+++ b/docs/_media/example.html
@@ -1 +1 @@
-
To infinity and Beyond!
\ No newline at end of file
+
To infinity and Beyond!
diff --git a/docs/cdn.md b/docs/cdn.md
index 05fff3c..52c9924 100644
--- a/docs/cdn.md
+++ b/docs/cdn.md
@@ -6,7 +6,7 @@ Recommended: [jsDelivr](//cdn.jsdelivr.net), which will reflect the latest versi
```html
-
+
@@ -18,7 +18,10 @@ Alternatively, use [compressed files](#compressed-file).
```html
-
+
@@ -28,7 +31,10 @@ Alternatively, use [compressed files](#compressed-file).
```html
-
+
@@ -36,7 +42,10 @@ Alternatively, use [compressed files](#compressed-file).
```html
-
+
diff --git a/docs/cover.md b/docs/cover.md
index bf8c3c5..1be3b39 100644
--- a/docs/cover.md
+++ b/docs/cover.md
@@ -11,8 +11,8 @@ Set `coverpage` to **true**, and create a `_coverpage.md`:
```
@@ -81,7 +81,7 @@ Now, you can set
```js
window.$docsify = {
- coverpage: ['/', '/zh-cn/']
+ coverpage: ['/', '/zh-cn/'],
};
```
@@ -91,7 +91,7 @@ Or a special file name
window.$docsify = {
coverpage: {
'/': 'cover.md',
- '/zh-cn/': 'cover.md'
- }
+ '/zh-cn/': 'cover.md',
+ },
};
```
diff --git a/docs/custom-navbar.md b/docs/custom-navbar.md
index 0d05a24..d1722fb 100644
--- a/docs/custom-navbar.md
+++ b/docs/custom-navbar.md
@@ -27,8 +27,8 @@ Alternatively, you can create a custom markdown-based navigation file by setting
```
@@ -36,8 +36,8 @@ Alternatively, you can create a custom markdown-based navigation file by setting
```markdown
-* [En](/)
-* [chinese](/zh-cn/)
+- [En](/)
+- [chinese](/zh-cn/)
```
!> You need to create a `.nojekyll` in `./docs` to prevent GitHub Pages from ignoring files that begin with an underscore.
@@ -51,19 +51,19 @@ You can create sub-lists by indenting items that are under a certain parent.
```markdown
-* Getting started
+- Getting started
- * [Quick start](quickstart.md)
- * [Writing more pages](more-pages.md)
- * [Custom navbar](custom-navbar.md)
- * [Cover page](cover.md)
+ - [Quick start](quickstart.md)
+ - [Writing more pages](more-pages.md)
+ - [Custom navbar](custom-navbar.md)
+ - [Cover page](cover.md)
-* Configuration
- * [Configuration](configuration.md)
- * [Themes](themes.md)
- * [Using plugins](plugins.md)
- * [Markdown configuration](markdown.md)
- * [Language highlight](language-highlight.md)
+- Configuration
+ - [Configuration](configuration.md)
+ - [Themes](themes.md)
+ - [Using plugins](plugins.md)
+ - [Markdown configuration](markdown.md)
+ - [Language highlight](language-highlight.md)
```
renders as
@@ -80,7 +80,7 @@ If you use the [emoji plugin](plugins#emoji):
@@ -91,6 +91,6 @@ you could, for example, use flag emojis in your custom navbar Markdown file:
```markdown
-* [:us:, :uk:](/)
-* [:cn:](/zh-cn/)
+- [:us:, :uk:](/)
+- [:cn:](/zh-cn/)
```
diff --git a/docs/deploy.md b/docs/deploy.md
index 9ac3ca5..ce6a82a 100644
--- a/docs/deploy.md
+++ b/docs/deploy.md
@@ -96,14 +96,14 @@ When using the HTML5 router, you need to set up redirect rules that redirect all
## AWS Amplify
-1. Set the routerMode in the Docsify project `index.html` to *history* mode.
+1. Set the routerMode in the Docsify project `index.html` to _history_ mode.
```html
```
@@ -125,17 +125,15 @@ frontend:
- '**/*'
cache:
paths: []
-
```
6. Add the following Redirect rules in their displayed order. Note that the second record is a PNG image where you can change it with any image format you are using.
| Source address | Target address | Type |
-|----------------|----------------|---------------|
-| /<*>.md | /<*>.md | 200 (Rewrite) |
-| /<*>.png | /<*>.png | 200 (Rewrite) |
-| /<*> | /index.html | 200 (Rewrite) |
-
+| -------------- | -------------- | ------------- |
+| /<\*>.md | /<\*>.md | 200 (Rewrite) |
+| /<\*>.png | /<\*>.png | 200 (Rewrite) |
+| /<\*> | /index.html | 200 (Rewrite) |
## Docker
@@ -144,10 +142,10 @@ frontend:
You need prepare the initial files instead of making them inside the container.
See the [Quickstart](https://docsify.js.org/#/quickstart) section for instructions on how to create these files manually or using [docsify-cli](https://github.com/docsifyjs/docsify-cli).
- ```sh
- index.html
- README.md
- ```
+ ```sh
+ index.html
+ README.md
+ ```
- Create Dockerfile
@@ -180,4 +178,3 @@ frontend:
```sh
docker run -itp 3000:3000 --name=docsify -v $(pwd):/docs docsify/demo
```
-
diff --git a/docs/embed-files.md b/docs/embed-files.md
index 936494b..f06d121 100644
--- a/docs/embed-files.md
+++ b/docs/embed-files.md
@@ -26,11 +26,11 @@ Currently, file extensions are automatically recognized and embedded in differen
These types are supported:
-* **iframe** `.html`, `.htm`
-* **markdown** `.markdown`, `.md`
-* **audio** `.mp3`
-* **video** `.mp4`, `.ogg`
-* **code** other file extension
+- **iframe** `.html`, `.htm`
+- **markdown** `.markdown`, `.md`
+- **audio** `.mp3`
+- **video** `.mp4`, `.ogg`
+- **code** other file extension
Of course, you can force the specified type. For example, a Markdown file can be embedded as a code block by setting `:type=code`.
@@ -74,6 +74,7 @@ Example:
If you embed the file as `iframe`, `audio` and `video`, then you may need to set the attributes of these tags.
?> 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.
+
```md
[filename](_media/example.mp4 ':include :type=video controls width=100%')
```
@@ -114,11 +115,11 @@ Start by viewing a gist on `gist.github.com`. For the purposes of this guide, we
Identify the following items from the gist:
-Field | Example | Description
---- | --- | ---
-**Username** | `anikethsaha` | The gist's owner.
-**Gist ID** | `c2bece08f27c4277001f123898d16a7c` | Identifier for the gist. This is fixed for the gist's lifetime.
-**Filename** | `content.md` | Select a name of a file in the gist. This needed even on a single-file gist for embedding to work.
+| Field | Example | Description |
+| ------------ | ---------------------------------- | -------------------------------------------------------------------------------------------------- |
+| **Username** | `anikethsaha` | The gist's owner. |
+| **Gist ID** | `c2bece08f27c4277001f123898d16a7c` | Identifier for the gist. This is fixed for the gist's lifetime. |
+| **Filename** | `content.md` | Select a name of a file in the gist. This needed even on a single-file gist for embedding to work. |
You will need those to build the _raw gist URL_ for the target file. This has the following format:
diff --git a/docs/language-highlight.md b/docs/language-highlight.md
index e95823d..0ea9b66 100644
--- a/docs/language-highlight.md
+++ b/docs/language-highlight.md
@@ -2,10 +2,10 @@
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`
+- 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:
@@ -29,7 +29,7 @@ echo "hello"
```
```php
-function getAdder(int $x): int
+function getAdder(int $x): int
{
return 123;
}
@@ -48,18 +48,19 @@ echo "hello"
```
```php
-function getAdder(int $x): int
+function getAdder(int $x): int
{
return 123;
}
```
## Highlighting Dynamic Content
+
Code blocks [dynamically created from javascript](https://docsify.js.org/#/configuration?id=executescript) can be highlighted using the method `Prism.highlightElement` like so:
```javascript
-const code = document.createElement("code");
+const code = document.createElement('code');
code.innerHTML = "console.log('Hello World!')";
-code.setAttribute("class", "lang-javascript");
+code.setAttribute('class', 'lang-javascript');
Prism.highlightElement(code);
```
diff --git a/docs/markdown.md b/docs/markdown.md
index 6adc7f0..5cca17b 100644
--- a/docs/markdown.md
+++ b/docs/markdown.md
@@ -9,10 +9,10 @@ window.$docsify = {
renderer: {
link() {
// ...
- }
- }
- }
-}
+ },
+ },
+ },
+};
```
?> Configuration Options Reference: [marked documentation](https://marked.js.org/#/USING_ADVANCED.md)
@@ -24,9 +24,9 @@ window.$docsify = {
markdown(marked, renderer) {
// ...
- return marked
- }
-}
+ return marked;
+ },
+};
```
## Supports mermaid
@@ -43,14 +43,17 @@ window.$docsify = {
markdown: {
renderer: {
code(code, lang) {
- if (lang === "mermaid") {
+ if (lang === 'mermaid') {
return /* html */ `
-