├── .nojekyll
├── media
├── img
│ ├── bg.jpg
│ ├── icon.png
│ ├── favicon.ico
│ └── addDevice.png
├── css
│ ├── phone.css
│ ├── style.css
│ └── vue.css
└── js
│ ├── countable.js
│ ├── search.js
│ └── docsify_4.10.4.js
├── en
├── img
│ ├── addDevice.png
│ ├── contactUs.png
│ ├── eWeLinkShop.png
│ ├── getDevices.png
│ ├── hbInterval.png
│ ├── userOnline.png
│ ├── controlDevice.png
│ ├── calculateSignature.png
│ ├── userOnlineSuccess.png
│ ├── controlDeviceProcess.jpeg
│ ├── controlDeviceSuccess.png
│ └── distributionProcess.png
├── _404.md
├── FAQ.md
├── APICenter.md
├── ContactUs.md
├── APICenterV2.md
├── DeveloperGuide.md
├── ChangeLog.md
├── DeveloperGuideV2.md
├── PlatformOverview.md
├── APIReferenceV2.md
├── DataSecurity.md
├── Pricing.md
└── _sidebar.md
├── .vscode
└── settings.json
├── zh-cmn
├── img
│ ├── addDevice.png
│ ├── contactUs.png
│ ├── addDevice2.png
│ ├── eWeLinkShop.png
│ ├── getDevices.png
│ ├── hbInterval.png
│ ├── userOnline.png
│ ├── controlDevice.png
│ ├── userOnlineSuccess.png
│ ├── calculateSignature.png
│ ├── distributionProcess.png
│ ├── controlDeviceProcess.jpeg
│ └── controlDeviceSuccess.png
├── 准备开发环境.md
├── 常见问题.md
├── 平台概述.md
├── 接口中心.md
├── 收费标准.md
├── 联系我们.md
├── 修订记录.md
├── 开发文档.md
├── 数据安全.md
├── 开发文档_v2.md
├── 接口中心_v2.md
├── 接口清单_v2.md
├── _404.md
└── _sidebar.md
├── auto.md
├── README.md
├── _coverpage.md
└── index.html
/.nojekyll:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/media/img/bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/media/img/bg.jpg
--------------------------------------------------------------------------------
/media/img/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/media/img/icon.png
--------------------------------------------------------------------------------
/en/img/addDevice.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/en/img/addDevice.png
--------------------------------------------------------------------------------
/en/img/contactUs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/en/img/contactUs.png
--------------------------------------------------------------------------------
/en/img/eWeLinkShop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/en/img/eWeLinkShop.png
--------------------------------------------------------------------------------
/en/img/getDevices.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/en/img/getDevices.png
--------------------------------------------------------------------------------
/en/img/hbInterval.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/en/img/hbInterval.png
--------------------------------------------------------------------------------
/en/img/userOnline.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/en/img/userOnline.png
--------------------------------------------------------------------------------
/media/img/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/media/img/favicon.ico
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "python.pythonPath": "D:\\Environment\\Miniconda3\\envs\\test\\python.exe"
3 | }
--------------------------------------------------------------------------------
/en/img/controlDevice.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/en/img/controlDevice.png
--------------------------------------------------------------------------------
/media/img/addDevice.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/media/img/addDevice.png
--------------------------------------------------------------------------------
/zh-cmn/img/addDevice.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/zh-cmn/img/addDevice.png
--------------------------------------------------------------------------------
/zh-cmn/img/contactUs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/zh-cmn/img/contactUs.png
--------------------------------------------------------------------------------
/zh-cmn/img/addDevice2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/zh-cmn/img/addDevice2.png
--------------------------------------------------------------------------------
/zh-cmn/img/eWeLinkShop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/zh-cmn/img/eWeLinkShop.png
--------------------------------------------------------------------------------
/zh-cmn/img/getDevices.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/zh-cmn/img/getDevices.png
--------------------------------------------------------------------------------
/zh-cmn/img/hbInterval.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/zh-cmn/img/hbInterval.png
--------------------------------------------------------------------------------
/zh-cmn/img/userOnline.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/zh-cmn/img/userOnline.png
--------------------------------------------------------------------------------
/en/img/calculateSignature.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/en/img/calculateSignature.png
--------------------------------------------------------------------------------
/en/img/userOnlineSuccess.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/en/img/userOnlineSuccess.png
--------------------------------------------------------------------------------
/zh-cmn/img/controlDevice.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/zh-cmn/img/controlDevice.png
--------------------------------------------------------------------------------
/en/img/controlDeviceProcess.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/en/img/controlDeviceProcess.jpeg
--------------------------------------------------------------------------------
/en/img/controlDeviceSuccess.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/en/img/controlDeviceSuccess.png
--------------------------------------------------------------------------------
/en/img/distributionProcess.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/en/img/distributionProcess.png
--------------------------------------------------------------------------------
/zh-cmn/img/userOnlineSuccess.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/zh-cmn/img/userOnlineSuccess.png
--------------------------------------------------------------------------------
/zh-cmn/img/calculateSignature.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/zh-cmn/img/calculateSignature.png
--------------------------------------------------------------------------------
/zh-cmn/img/distributionProcess.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/zh-cmn/img/distributionProcess.png
--------------------------------------------------------------------------------
/zh-cmn/img/controlDeviceProcess.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/zh-cmn/img/controlDeviceProcess.jpeg
--------------------------------------------------------------------------------
/zh-cmn/img/controlDeviceSuccess.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoolKit-Technologies/apiDocs/HEAD/zh-cmn/img/controlDeviceSuccess.png
--------------------------------------------------------------------------------
/auto.md:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/zh-cmn/准备开发环境.md:
--------------------------------------------------------------------------------
1 |
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
7 |
8 | # apiDoc
9 |
10 | 本文档不再维护,已转移 [新地址](https://coolkit-technologies.github.io/eWeLink-API/),原内容废弃!
--------------------------------------------------------------------------------
/en/_404.md:
--------------------------------------------------------------------------------
1 |
7 | ## 404 | This page could not be found.
8 |
9 | You can return to "[Home](/en/)" to view other information.
--------------------------------------------------------------------------------
/zh-cmn/常见问题.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | 本文档不再维护,已转移 [新地址](https://coolkit-technologies.github.io/eWeLink-API/),原内容废弃!
11 |
--------------------------------------------------------------------------------
/zh-cmn/平台概述.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | 本文档不再维护,已转移 [新地址](https://coolkit-technologies.github.io/eWeLink-API/),原内容废弃!
11 |
--------------------------------------------------------------------------------
/zh-cmn/接口中心.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | 本文档不再维护,已转移 [新地址](https://coolkit-technologies.github.io/eWeLink-API/),原内容废弃!
11 |
--------------------------------------------------------------------------------
/zh-cmn/收费标准.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | 本文档不再维护,已转移 [新地址](https://coolkit-technologies.github.io/eWeLink-API/),原内容废弃!
11 |
--------------------------------------------------------------------------------
/zh-cmn/联系我们.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | 本文档不再维护,已转移 [新地址](https://coolkit-technologies.github.io/eWeLink-API/),原内容废弃!
11 |
--------------------------------------------------------------------------------
/zh-cmn/修订记录.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | 本文档不再维护,已转移 [新地址](https://coolkit-technologies.github.io/eWeLink-API/),原内容废弃!
11 |
--------------------------------------------------------------------------------
/zh-cmn/开发文档.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | 本文档不再维护,已转移 [新地址](https://coolkit-technologies.github.io/eWeLink-API/),原内容废弃!
11 |
--------------------------------------------------------------------------------
/zh-cmn/数据安全.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | 本文档不再维护,已转移 [新地址](https://coolkit-technologies.github.io/eWeLink-API/),原内容废弃!
11 |
--------------------------------------------------------------------------------
/zh-cmn/开发文档_v2.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | 本文档不再维护,已转移 [新地址](https://coolkit-technologies.github.io/eWeLink-API/),原内容废弃!
11 |
--------------------------------------------------------------------------------
/zh-cmn/接口中心_v2.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | 本文档不再维护,已转移 [新地址](https://coolkit-technologies.github.io/eWeLink-API/),原内容废弃!
11 |
--------------------------------------------------------------------------------
/zh-cmn/接口清单_v2.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | 本文档不再维护,已转移 [新地址](https://coolkit-technologies.github.io/eWeLink-API/),原内容废弃!
11 |
--------------------------------------------------------------------------------
/zh-cmn/_404.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | ## 404 | 这个页面不存在
11 |
12 | 你可以返回「[首页](https://coolkit-technologies.github.io/eWeLink-API/)」查看其它资料。
13 |
--------------------------------------------------------------------------------
/en/FAQ.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | This document is no longer maintained and has been transferred to [new address](https://coolkit-technologies.github.io/eWeLink-API/), the original content is discarded!
11 |
--------------------------------------------------------------------------------
/en/APICenter.md:
--------------------------------------------------------------------------------
1 |
9 | This document is no longer maintained and has been transferred to [new address](https://coolkit-technologies.github.io/eWeLink-API/), the original content is discarded!
10 |
--------------------------------------------------------------------------------
/en/ContactUs.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | This document is no longer maintained and has been transferred to [new address](https://coolkit-technologies.github.io/eWeLink-API/), the original content is discarded!
11 |
--------------------------------------------------------------------------------
/media/css/phone.css:
--------------------------------------------------------------------------------
1 | .cover-main span,.cover-main blockquote,.cover-main ul{
2 | color: #fff;
3 | }
4 | section.cover .cover-main>p:last-child a{
5 | background-color: #fff;
6 | }
7 |
8 | .app-nav a {
9 | color: #999;
10 | }
11 |
12 | section.cover .cover-main>p:last-child a:last-child:hover{
13 | opacity: 1;
14 | }
15 |
--------------------------------------------------------------------------------
/en/APICenterV2.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | This document is no longer maintained and has been transferred to [new address](https://coolkit-technologies.github.io/eWeLink-API/), the original content is discarded!
11 |
--------------------------------------------------------------------------------
/en/DeveloperGuide.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | This document is no longer maintained and has been transferred to [new address](https://coolkit-technologies.github.io/eWeLink-API/), the original content is discarded!
11 |
--------------------------------------------------------------------------------
/en/ChangeLog.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | This document is no longer maintained and has been transferred to [new address](https://coolkit-technologies.github.io/eWeLink-API/), the original content is discarded!
11 |
--------------------------------------------------------------------------------
/en/DeveloperGuideV2.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | This document is no longer maintained and has been transferred to [new address](https://coolkit-technologies.github.io/eWeLink-API/), the original content is discarded!
11 |
--------------------------------------------------------------------------------
/en/PlatformOverview.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | This document is no longer maintained and has been transferred to [new address](https://coolkit-technologies.github.io/eWeLink-API/), the original content is discarded!
11 |
--------------------------------------------------------------------------------
/en/APIReferenceV2.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | This document is no longer maintained and has been transferred to [new address](https://coolkit-technologies.github.io/eWeLink-API/), the original content is discarded!
11 |
--------------------------------------------------------------------------------
/en/DataSecurity.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | This document is no longer maintained and has been transferred to [new address](https://coolkit-technologies.github.io/eWeLink-API/), the original content is discarded!
11 |
--------------------------------------------------------------------------------
/en/Pricing.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | # Pricing
11 |
12 | This document is no longer maintained and has been transferred to [new address](https://coolkit-technologies.github.io/eWeLink-API/), the original content is discarded!
13 |
--------------------------------------------------------------------------------
/media/css/style.css:
--------------------------------------------------------------------------------
1 | body{
2 | font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
3 | }
4 |
5 | .markdown-section h1{
6 | font-weight: 400;
7 | }
8 | .markdown-section a{
9 | font-weight: 300;
10 | }
11 | /* .search .input-wrap input{
12 | font-family: "SimSun";
13 | } */
14 |
--------------------------------------------------------------------------------
/_coverpage.md:
--------------------------------------------------------------------------------
1 |
7 |
8 | 
9 |
10 | # 酷宅开放平台4.0
11 |
12 | > 开放共赢,优势互补
13 |
14 | - Amazon Alexa 智能家居 IoT 方案提供商(官方推荐)
15 | - Google Assistant 智能家居方案提供商(官方推荐)
16 |
17 | [跳转新地址](https://coolkit-technologies.github.io/eWeLink-API/)
18 |
--------------------------------------------------------------------------------
/zh-cmn/_sidebar.md:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 | * [平台概述](/zh-cmn/平台概述)
10 | * [收费标准](/zh-cmn/收费标准)
11 | * [接口清单_v2](/zh-cmn/接口清单_v2)
12 | * [开发文档_v2](/zh-cmn/开发文档_v2)
13 | * [接口中心_v2](/zh-cmn/接口中心_v2)
14 | * [开发文档](/zh-cmn/开发文档)
15 | * [接口中心](/zh-cmn/接口中心)
16 | * [常见问题](/zh-cmn/常见问题)
17 | * [数据安全](/zh-cmn/数据安全)
18 | * [联系我们](/zh-cmn/联系我们)
19 | * [修订记录](/zh-cmn/修订记录)
--------------------------------------------------------------------------------
/en/_sidebar.md:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 | * [Platform Overview](/en/PlatformOverview)
10 | * [Pricing](/en/Pricing)
11 | * [Developer Guide v2](/en/DeveloperGuideV2)
12 | * [API Reference v2](/en/APIReferenceV2)
13 | * [API Center v2](/en/APICenterV2)
14 | * [Developer Guide](/en/DeveloperGuide)
15 | * [API Center](/en/APICenter)
16 | * [FAQ](/en/FAQ)
17 | * [Data Security](/en/DataSecurity)
18 | * [Contact Us](/en/ContactUs)
19 | * [Change Log](/en/ChangeLog)
--------------------------------------------------------------------------------
/media/js/countable.js:
--------------------------------------------------------------------------------
1 | //default values
2 | var defaultOptions = {
3 | countable: true,
4 | position: "top",
5 | margin: "10px",
6 | float: "right",
7 | fontsize: "0.9em",
8 | color: "rgb(90,90,90)",
9 | language: "english",
10 | isExpected: true,
11 | }
12 |
13 | // Docsify plugin functions
14 | function plugin(hook, vm) {
15 | if (!defaultOptions.countable) {
16 | return
17 | }
18 | let wordsCount
19 | hook.beforeEach(function (content) {
20 | // Match regex every time you start parsing .md
21 | wordsCount = content.match(/([\u4e00-\u9fa5]+?|[a-zA-Z0-9]+)/g).length
22 | return content
23 | })
24 | hook.afterEach(function (html, next) {
25 | let str = wordsCount + " words"
26 | let readTime = Math.ceil(wordsCount / 400) + " min"
27 | //Determine whether to use the Chinese style according to the attribute "language"
28 | if (defaultOptions.language === "chinese") {
29 | str = wordsCount + " 字"
30 | readTime = Math.ceil(wordsCount / 400) + " 分钟"
31 | }
32 |
33 | //add html string
34 | next(
35 | `
36 | ${defaultOptions.position === "bottom" ? html : ""}
37 |
40 |
44 | ${str}
45 | ${defaultOptions.isExpected ? ` | ${readTime}` : ""}
46 |
47 |
48 |
49 | ${defaultOptions.position !== "bottom" ? html : ""}
50 | `
51 | )
52 | })
53 | }
54 |
55 | // Docsify plugin options
56 | window.$docsify["count"] = Object.assign(
57 | defaultOptions,
58 | window.$docsify["count"]
59 | )
60 | window.$docsify.plugins = [].concat(plugin, window.$docsify.plugins)
61 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 | 酷宅开放平台 4.0
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/media/css/vue.css:
--------------------------------------------------------------------------------
1 | @import url("https://fonts.googleapis.com/css?family=Roboto+Mono|Source+Sans+Pro:300,400,600");*{-webkit-font-smoothing:antialiased;-webkit-overflow-scrolling:touch;-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-text-size-adjust:none;-webkit-touch-callout:none;box-sizing:border-box}body:not(.ready){overflow:hidden}body:not(.ready) .app-nav,body:not(.ready)>nav,body:not(.ready) [data-cloak]{display:none}div#app{font-size:30px;font-weight:lighter;margin:40vh auto;text-align:center}div#app:empty:before{content:"Loading..."}.emoji{height:1.2rem;vertical-align:middle}.progress{background-color:var(--theme-color,#42b983);height:2px;left:0;position:fixed;right:0;top:0;transition:width .2s,opacity .4s;width:0;z-index:999999}.search .search-keyword,.search a:hover{color:var(--theme-color,#42b983)}.search .search-keyword{font-style:normal;font-weight:700}body,html{height:100%}body{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;color:#34495e;font-family:Source Sans Pro,Helvetica Neue,Arial,sans-serif;font-size:15px;letter-spacing:0;margin:0;overflow-x:hidden}img{max-width:100%}a[disabled]{cursor:not-allowed;opacity:.6}kbd{border:1px solid #ccc;border-radius:3px;display:inline-block;font-size:12px!important;line-height:12px;margin-bottom:3px;padding:3px 5px;vertical-align:middle}li input[type=checkbox]{margin:0 .2em .25em 0;vertical-align:middle}.app-nav{margin:25px 60px 0 0;position:absolute;right:0;text-align:right;z-index:10}.app-nav.no-badge{margin-right:25px}.app-nav p{margin:0}.app-nav>a{margin:0 1rem;padding:5px 0}.app-nav li,.app-nav ul{display:inline-block;list-style:none;margin:0}.app-nav a{color:inherit;font-size:16px;text-decoration:none;transition:color .3s}.app-nav a.active,.app-nav a:hover{color:var(--theme-color,#42b983)}.app-nav a.active{border-bottom:2px solid var(--theme-color,#42b983)}.app-nav li{display:inline-block;margin:0 1rem;padding:5px 0;position:relative;cursor:pointer}.app-nav li ul{background-color:#fff;border:1px solid;border-color:#ddd #ddd #ccc;border-radius:4px;box-sizing:border-box;display:none;max-height:calc(100vh - 61px);overflow-y:auto;padding:10px 0;position:absolute;right:-15px;text-align:left;top:100%;white-space:nowrap}.app-nav li ul li{display:block;font-size:14px;line-height:1rem;margin:8px 14px;white-space:nowrap}.app-nav li ul a{display:block;font-size:inherit;margin:0;padding:0}.app-nav li ul a.active{border-bottom:0}.app-nav li:hover ul{display:block}.github-corner{border-bottom:0;position:fixed;right:0;text-decoration:none;top:0;z-index:1}.github-corner:hover .octo-arm{-webkit-animation:octocat-wave .56s ease-in-out;animation:octocat-wave .56s ease-in-out}.github-corner svg{color:#fff;fill:var(--theme-color,#42b983);height:80px;width:80px}main{display:block;position:relative;width:100vw;height:100%;z-index:0}main.hidden{display:none}.anchor{display:inline-block;text-decoration:none;transition:all .3s}.anchor span{color:#34495e}.anchor:hover{text-decoration:underline}.sidebar{border-right:1px solid rgba(0,0,0,.07);overflow-y:auto;padding:40px 0 0;position:absolute;top:0;bottom:0;left:0;transition:transform .25s ease-out;width:300px;z-index:20}.sidebar>h1{margin:0 auto 1rem;font-size:1.5rem;font-weight:300;text-align:center}.sidebar>h1 a{color:inherit;text-decoration:none}.sidebar>h1 .app-nav{display:block;position:static}.sidebar .sidebar-nav{line-height:2em;padding-bottom:40px}.sidebar li.collapse .app-sub-sidebar{display:none}.sidebar ul{margin:0 0 0 15px;padding:0}.sidebar li>p{font-weight:700;margin:0}.sidebar ul,.sidebar ul li{list-style:none}.sidebar ul li a{border-bottom:none;display:block}.sidebar ul li ul{padding-left:20px}.sidebar::-webkit-scrollbar{width:4px}.sidebar::-webkit-scrollbar-thumb{background:transparent;border-radius:4px}.sidebar:hover::-webkit-scrollbar-thumb{background:hsla(0,0%,53.3%,.4)}.sidebar:hover::-webkit-scrollbar-track{background:hsla(0,0%,53.3%,.1)}.sidebar-toggle{background-color:transparent;background-color:hsla(0,0%,100%,.8);border:0;outline:none;padding:10px;position:absolute;bottom:0;left:0;text-align:center;transition:opacity .3s;width:284px;z-index:30;cursor:pointer}.sidebar-toggle:hover .sidebar-toggle-button{opacity:.4}.sidebar-toggle span{background-color:var(--theme-color,#42b983);display:block;margin-bottom:4px;width:16px;height:2px}body.sticky .sidebar,body.sticky .sidebar-toggle{position:fixed}.content{padding-top:60px;position:absolute;top:0;right:0;bottom:0;left:300px;transition:left .25s ease}.markdown-section{margin:0 auto;max-width:80%;padding:30px 15px 40px;position:relative}.markdown-section>*{box-sizing:border-box;font-size:inherit}.markdown-section>:first-child{margin-top:0!important}.markdown-section hr{border:none;border-bottom:1px solid #eee;margin:2em 0}.markdown-section iframe{border:1px solid #eee;width:1px;min-width:100%}.markdown-section table{border-collapse:collapse;border-spacing:0;display:block;margin-bottom:1rem;overflow:auto;width:100%}.markdown-section th{font-weight:700}.markdown-section td,.markdown-section th{border:1px solid #ddd;padding:6px 13px}.markdown-section tr{border-top:1px solid #ccc}.markdown-section p.tip,.markdown-section tr:nth-child(2n){background-color:#f8f8f8}.markdown-section p.tip{border-bottom-right-radius:2px;border-left:4px solid #f66;border-top-right-radius:2px;margin:2em 0;padding:12px 24px 12px 30px;position:relative}.markdown-section p.tip:before{background-color:#f66;border-radius:100%;color:#fff;content:"!";font-family:Dosis,Source Sans Pro,Helvetica Neue,Arial,sans-serif;font-size:14px;font-weight:700;left:-12px;line-height:20px;position:absolute;height:20px;width:20px;text-align:center;top:14px}.markdown-section p.tip code{background-color:#efefef}.markdown-section p.tip em{color:#34495e}.markdown-section p.warn{background:rgba(66,185,131,.1);border-radius:2px;padding:1rem}.markdown-section ul.task-list>li{list-style-type:none}body.close .sidebar{transform:translateX(-300px)}body.close .sidebar-toggle{width:auto}body.close .content{left:0}@media print{.app-nav,.github-corner,.sidebar,.sidebar-toggle{display:none}}@media screen and (max-width:768px){.github-corner,.sidebar,.sidebar-toggle{position:fixed}.app-nav{margin-top:16px}.app-nav li ul{top:30px}main{height:auto;overflow-x:hidden}.sidebar{left:-300px;transition:transform .25s ease-out}.content{left:0;max-width:100vw;position:static;padding-top:20px;transition:transform .25s ease}.app-nav,.github-corner{transition:transform .25s ease-out}.sidebar-toggle{background-color:transparent;width:auto;padding:30px 30px 10px 10px}body.close .sidebar{transform:translateX(300px)}body.close .sidebar-toggle{background-color:hsla(0,0%,100%,.8);transition:background-color 1s;width:284px;padding:10px}body.close .content{transform:translateX(300px)}body.close .app-nav,body.close .github-corner{display:none}.github-corner:hover .octo-arm{-webkit-animation:none;animation:none}.github-corner .octo-arm{-webkit-animation:octocat-wave .56s ease-in-out;animation:octocat-wave .56s ease-in-out}}@-webkit-keyframes octocat-wave{0%,to{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@keyframes octocat-wave{0%,to{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}section.cover{align-items:center;background-position:50%;background-repeat:no-repeat;background-size:cover;height:100vh;display:none}section.cover.show{display:flex}section.cover.has-mask .mask{background-color:#fff;opacity:.8;position:absolute;top:0;height:100%;width:100%}section.cover .cover-main{flex:1;margin:-20px 16px 0;text-align:center;z-index:1}section.cover a{color:inherit}section.cover a,section.cover a:hover{text-decoration:none}section.cover p{line-height:1.5rem;margin:1em 0}section.cover h1{color:inherit;font-size:2.5rem;font-weight:300;margin:.625rem 0 2.5rem;position:relative;text-align:center}section.cover h1 a{display:block}section.cover h1 small{bottom:-.4375rem;font-size:1rem;position:absolute}section.cover blockquote{font-size:1.5rem;text-align:center}section.cover ul{line-height:1.8;list-style-type:none;margin:1em auto;max-width:500px;padding:0}section.cover .cover-main>p:last-child a{border-radius:2rem;border:1px solid var(--theme-color,#42b983);box-sizing:border-box;color:var(--theme-color,#42b983);display:inline-block;font-size:1.05rem;letter-spacing:.1rem;margin:.5rem 1rem;padding:.75em 2rem;text-decoration:none;transition:all .15s ease}section.cover .cover-main>p:last-child a:last-child{background-color:var(--theme-color,#42b983);color:#fff}section.cover .cover-main>p:last-child a:last-child:hover{color:inherit;opacity:.8}section.cover .cover-main>p:last-child a:hover{color:inherit}section.cover blockquote>p>a{border-bottom:2px solid var(--theme-color,#42b983);transition:color .3s}section.cover blockquote>p>a:hover{color:var(--theme-color,#42b983)}.sidebar,body{background-color:#fff}.sidebar{color:#364149}.sidebar li{margin:6px 0}.sidebar ul li a{color:#505d6b;font-size:14px;font-weight:400;overflow:hidden;text-decoration:none;text-overflow:ellipsis;white-space:nowrap}.sidebar ul li a:hover{text-decoration:underline}.sidebar ul li ul{padding:0}.sidebar ul li.active>a{border-right:2px solid;color:var(--theme-color,#42b983);font-weight:600}.app-sub-sidebar li:before{content:"-";padding-right:4px;float:left}.markdown-section h1,.markdown-section h2,.markdown-section h3,.markdown-section h4,.markdown-section strong{color:#2c3e50;font-weight:600}.markdown-section a{color:var(--theme-color,#42b983);font-weight:600}.markdown-section h1{font-size:2rem;margin:0 0 1rem}.markdown-section h2{font-size:1.75rem;margin:45px 0 .8rem}.markdown-section h3{font-size:1.5rem;margin:40px 0 .6rem}.markdown-section h4{font-size:1.25rem}.markdown-section h5{font-size:1rem}.markdown-section h6{color:#777;font-size:1rem}.markdown-section figure,.markdown-section p{margin:1.2em 0}.markdown-section ol,.markdown-section p,.markdown-section ul{line-height:1.6rem;word-spacing:.05rem}.markdown-section ol,.markdown-section ul{padding-left:1.5rem}.markdown-section blockquote{border-left:4px solid var(--theme-color,#42b983);color:#858585;margin:2em 0;padding-left:20px}.markdown-section blockquote p{font-weight:600;margin-left:0}.markdown-section iframe{margin:1em 0}.markdown-section em{color:#7f8c8d}.markdown-section code{border-radius:2px;color:#e96900;font-size:.8rem;margin:0 2px;padding:3px 5px;white-space:pre-wrap}.markdown-section code,.markdown-section pre{background-color:#f8f8f8;font-family:Roboto Mono,Monaco,courier,monospace}.markdown-section pre{-moz-osx-font-smoothing:initial;-webkit-font-smoothing:initial;line-height:1.5rem;margin:1.2em 0;overflow:auto;padding:0 1.4rem;position:relative;word-wrap:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#8e908c}.token.namespace{opacity:.7}.token.boolean,.token.number{color:#c76b29}.token.punctuation{color:#525252}.token.property{color:#c08b30}.token.tag{color:#2973b7}.token.string{color:var(--theme-color,#42b983)}.token.selector{color:#6679cc}.token.attr-name{color:#2973b7}.language-css .token.string,.style .token.string,.token.entity,.token.url{color:#22a2c9}.token.attr-value,.token.control,.token.directive,.token.unit{color:var(--theme-color,#42b983)}.token.function,.token.keyword{color:#e96900}.token.atrule,.token.regex,.token.statement{color:#22a2c9}.token.placeholder,.token.variable{color:#3d8fd1}.token.deleted{text-decoration:line-through}.token.inserted{border-bottom:1px dotted #202746;text-decoration:none}.token.italic{font-style:italic}.token.bold,.token.important{font-weight:700}.token.important{color:#c94922}.token.entity{cursor:help}.markdown-section pre>code{-moz-osx-font-smoothing:initial;-webkit-font-smoothing:initial;background-color:#f8f8f8;border-radius:2px;color:#525252;display:block;font-family:Roboto Mono,Monaco,courier,monospace;font-size:.8rem;line-height:inherit;margin:0 2px;max-width:inherit;overflow:inherit;padding:2.2em 5px;white-space:inherit}.markdown-section code:after,.markdown-section code:before{letter-spacing:.05rem}code .token{-moz-osx-font-smoothing:initial;-webkit-font-smoothing:initial;min-height:1.5rem;position:relative;left:auto}pre:after{color:#ccc;content:attr(data-lang);font-size:.6rem;font-weight:600;height:15px;line-height:15px;padding:5px 10px 0;position:absolute;right:0;text-align:right;top:0}
--------------------------------------------------------------------------------
/media/js/search.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | /* eslint-disable no-unused-vars */
3 | var INDEXS = {};
4 |
5 | var LOCAL_STORAGE = {
6 | EXPIRE_KEY: 'docsify.search.expires',
7 | INDEX_KEY: 'docsify.search.index',
8 | };
9 |
10 | function resolveExpireKey(namespace) {
11 | return namespace
12 | ? ((LOCAL_STORAGE.EXPIRE_KEY) + "/" + namespace)
13 | : LOCAL_STORAGE.EXPIRE_KEY;
14 | }
15 |
16 | function resolveIndexKey(namespace) {
17 | return namespace
18 | ? ((LOCAL_STORAGE.INDEX_KEY) + "/" + namespace)
19 | : LOCAL_STORAGE.INDEX_KEY;
20 | }
21 |
22 | function escapeHtml(string) {
23 | var entityMap = {
24 | '&': '&',
25 | '<': '<',
26 | '>': '>',
27 | '"': '"',
28 | "'": ''',
29 | '/': '/',
30 | };
31 |
32 | return String(string).replace(/[&<>"'/]/g, function (s) { return entityMap[s]; });
33 | }
34 |
35 | function getAllPaths(router) {
36 | var paths = [];
37 |
38 | Docsify.dom
39 | .findAll('.sidebar-nav a:not(.section-link):not([data-nosearch])')
40 | .forEach(function (node) {
41 | var href = node.href;
42 | var originHref = node.getAttribute('href');
43 | var path = router.parse(href).path;
44 |
45 | if (
46 | path &&
47 | paths.indexOf(path) === -1 &&
48 | !Docsify.util.isAbsolutePath(originHref)
49 | ) {
50 | paths.push(path);
51 | }
52 | });
53 |
54 | return paths;
55 | }
56 |
57 | function saveData(maxAge, expireKey, indexKey) {
58 | localStorage.setItem(expireKey, Date.now() + maxAge);
59 | localStorage.setItem(indexKey, JSON.stringify(INDEXS));
60 | }
61 |
62 | function genIndex(path, content, router, depth) {
63 | if ( content === void 0 ) content = '';
64 |
65 | var tokens = window.marked.lexer(content);
66 | var slugify = window.Docsify.slugify;
67 | var index = {};
68 | var slug;
69 |
70 | tokens.forEach(function (token) {
71 | if (token.type === 'heading' && token.depth <= depth) {
72 | slug = router.toURL(path, { id: slugify(token.text) });
73 | index[slug] = { slug: slug, title: token.text, body: '' };
74 | } else {
75 | if (!slug) {
76 | return;
77 | }
78 |
79 | if (!index[slug]) {
80 | index[slug] = { slug: slug, title: '', body: '' };
81 | } else if (index[slug].body) {
82 | index[slug].body += '\n' + (token.text || '');
83 | } else {
84 | if (!token.text) {
85 | if (token.type === 'table') {
86 | token.text = token.cells
87 | .map(function(rows) {
88 | return rows.join(' | ');
89 | })
90 | .join(' |\n ');
91 | }
92 | }
93 |
94 | index[slug].body = index[slug].body
95 | ? index[slug].body + token.text
96 | : token.text;
97 | }
98 | }
99 | });
100 | slugify.clear();
101 | return index;
102 | }
103 |
104 | /**
105 | * @param {String} query Search query
106 | * @returns {Array} Array of results
107 | */
108 | function search(query) {
109 | var matchingResults = [];
110 | var data = [];
111 | Object.keys(INDEXS).forEach(function (key) {
112 | data = data.concat(Object.keys(INDEXS[key]).map(function (page) { return INDEXS[key][page]; }));
113 | });
114 |
115 | query = query.trim();
116 | var keywords = query.split(/[\s\-,\\/]+/);
117 | if (keywords.length !== 1) {
118 | keywords = [].concat(query, keywords);
119 | }
120 |
121 | var loop = function ( i ) {
122 | var post = data[i];
123 | var matchesScore = 0;
124 | var resultStr = '';
125 | var postTitle = post.title && post.title.trim();
126 | var postContent = post.body && post.body.trim();
127 | var postUrl = post.slug || '';
128 |
129 | if (postTitle) {
130 | keywords.forEach(function (keyword) {
131 | // From https://github.com/sindresorhus/escape-string-regexp
132 | var regEx = new RegExp(
133 | keyword.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&'),
134 | 'gi'
135 | );
136 | var indexTitle = -1;
137 | var indexContent = -1;
138 |
139 | indexTitle = postTitle ? postTitle.search(regEx) : -1;
140 | indexContent = postContent ? postContent.search(regEx) : -1;
141 |
142 | if (indexTitle >= 0 || indexContent >= 0) {
143 | matchesScore += indexTitle >= 0 ? 3 : indexContent >= 0 ? 2 : 0;
144 | if (indexContent < 0) {
145 | indexContent = 0;
146 | }
147 |
148 | var start = 0;
149 | var end = 0;
150 |
151 | start = indexContent < 11 ? 0 : indexContent - 10;
152 | end = start === 0 ? 70 : indexContent + keyword.length + 60;
153 |
154 | if (postContent && end > postContent.length) {
155 | end = postContent.length;
156 | }
157 |
158 | var matchContent =
159 | '...' +
160 | escapeHtml(postContent)
161 | .substring(start, end)
162 | .replace(regEx, ("" + keyword + "")) +
163 | '...';
164 |
165 | resultStr += matchContent;
166 | }
167 | });
168 |
169 | if (matchesScore > 0) {
170 | var matchingPost = {
171 | title: escapeHtml(postTitle),
172 | content: postContent ? resultStr : '',
173 | url: postUrl,
174 | score: matchesScore,
175 | };
176 |
177 | matchingResults.push(matchingPost);
178 | }
179 | }
180 | };
181 |
182 | for (var i = 0; i < data.length; i++) loop( i );
183 |
184 | return matchingResults.sort(function (r1, r2) { return r2.score - r1.score; });
185 | }
186 |
187 | function init(config, vm) {
188 | var isAuto = config.paths === 'auto';
189 |
190 | var expireKey = resolveExpireKey(config.namespace);
191 | var indexKey = resolveIndexKey(config.namespace);
192 |
193 | var isExpired = localStorage.getItem(expireKey) < Date.now();
194 |
195 | INDEXS = JSON.parse(localStorage.getItem(indexKey));
196 |
197 | if (isExpired) {
198 | INDEXS = {};
199 | } else if (!isAuto) {
200 | return;
201 | }
202 |
203 | var paths = isAuto ? getAllPaths(vm.router) : config.paths;
204 | var len = paths.length;
205 | var count = 0;
206 |
207 | paths.forEach(function (path) {
208 | if (INDEXS[path]) {
209 | return count++;
210 | }
211 |
212 | Docsify.get(vm.router.getFile(path), false, vm.config.requestHeaders).then(
213 | function (result) {
214 | INDEXS[path] = genIndex(path, result, vm.router, config.depth);
215 | len === ++count && saveData(config.maxAge, expireKey, indexKey);
216 | }
217 | );
218 | });
219 | }
220 |
221 | /* eslint-disable no-unused-vars */
222 |
223 | var NO_DATA_TEXT = '';
224 | var options;
225 |
226 | function style() {
227 | var code = "\n.sidebar {\n padding-top: 0;\n}\n\n.search {\n margin-bottom: 20px;\n padding: 6px;\n border-bottom: 1px solid #eee;\n}\n\n.search .input-wrap {\n display: flex;\n align-items: center;\n}\n\n.search .results-panel {\n display: none;\n}\n\n.search .results-panel.show {\n display: block;\n}\n\n.search input {\n outline: none;\n border: none;\n width: 100%;\n padding: 0 7px;\n line-height: 36px;\n font-size: 14px;\n border: 1px solid transparent;\n}\n\n.search input:focus {\n box-shadow: 0 0 5px var(--theme-color, #42b983);\n border: 1px solid var(--theme-color, #42b983);\n}\n\n.search input::-webkit-search-decoration,\n.search input::-webkit-search-cancel-button,\n.search input {\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n.search .clear-button {\n width: 36px;\n text-align: right;\n display: none;\n}\n\n.search .clear-button.show {\n display: block;\n}\n\n.search .clear-button svg {\n transform: scale(.5);\n}\n\n.search h2 {\n font-size: 17px;\n margin: 10px 0;\n}\n\n.search a {\n text-decoration: none;\n color: inherit;\n}\n\n.search .matching-post {\n border-bottom: 1px solid #eee;\n}\n\n.search .matching-post:last-child {\n border-bottom: 0;\n}\n\n.search p {\n font-size: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n}\n\n.search p.empty {\n text-align: center;\n}\n\n.app-name.hide, .sidebar-nav.hide {\n display: none;\n}";
228 |
229 | Docsify.dom.style(code);
230 | }
231 |
232 | function tpl(defaultValue) {
233 | if ( defaultValue === void 0 ) defaultValue = '';
234 |
235 | var html = "\n \n ";
236 | var el = Docsify.dom.create('div', html);
237 | var aside = Docsify.dom.find('aside');
238 |
239 | Docsify.dom.toggleClass(el, 'search');
240 | Docsify.dom.before(aside, el);
241 | }
242 |
243 | function doSearch(value) {
244 | var $search = Docsify.dom.find('div.search');
245 | var $panel = Docsify.dom.find($search, '.results-panel');
246 | var $clearBtn = Docsify.dom.find($search, '.clear-button');
247 | var $sidebarNav = Docsify.dom.find('.sidebar-nav');
248 | var $appName = Docsify.dom.find('.app-name');
249 |
250 | if (!value) {
251 | $panel.classList.remove('show');
252 | $clearBtn.classList.remove('show');
253 | $panel.innerHTML = '';
254 |
255 | if (options.hideOtherSidebarContent) {
256 | $sidebarNav.classList.remove('hide');
257 | $appName.classList.remove('hide');
258 | }
259 |
260 | return;
261 | }
262 |
263 | var matchs = search(value);
264 |
265 | var html = '';
266 | matchs.forEach(function (post) {
267 | html += "";
268 | });
269 |
270 | $panel.classList.add('show');
271 | $clearBtn.classList.add('show');
272 | $panel.innerHTML = html || ("" + NO_DATA_TEXT + "
");
273 | if (options.hideOtherSidebarContent) {
274 | $sidebarNav.classList.add('hide');
275 | $appName.classList.add('hide');
276 | }
277 | }
278 |
279 | function bindEvents() {
280 | var $search = Docsify.dom.find('div.search');
281 | var $input = Docsify.dom.find($search, 'input');
282 | var $inputWrap = Docsify.dom.find($search, '.input-wrap');
283 |
284 | var timeId;
285 | // Prevent to Fold sidebar
286 | Docsify.dom.on(
287 | $search,
288 | 'click',
289 | function (e) { return e.target.tagName !== 'A' && e.stopPropagation(); }
290 | );
291 | Docsify.dom.on($input, 'input', function (e) {
292 | clearTimeout(timeId);
293 | timeId = setTimeout(function (_) { return doSearch(e.target.value.trim()); }, 100);
294 | });
295 | Docsify.dom.on($inputWrap, 'click', function (e) {
296 | // Click input outside
297 | if (e.target.tagName !== 'INPUT') {
298 | $input.value = '';
299 | doSearch();
300 | }
301 | });
302 | }
303 |
304 | function updatePlaceholder(text, path) {
305 | var $input = Docsify.dom.getNode('.search input[type="search"]');
306 |
307 | if (!$input) {
308 | return;
309 | }
310 |
311 | if (typeof text === 'string') {
312 | $input.placeholder = text;
313 | } else {
314 | var match = Object.keys(text).filter(function (key) { return path.indexOf(key) > -1; })[0];
315 | $input.placeholder = text[match];
316 | }
317 | }
318 |
319 | function updateNoData(text, path) {
320 | if (typeof text === 'string') {
321 | NO_DATA_TEXT = text;
322 | } else {
323 | var match = Object.keys(text).filter(function (key) { return path.indexOf(key) > -1; })[0];
324 | NO_DATA_TEXT = text[match];
325 | }
326 | }
327 |
328 | function updateOptions(opts) {
329 | options = opts;
330 | }
331 |
332 | function init$1(opts, vm) {
333 | var keywords = vm.router.parse().query.s;
334 |
335 | updateOptions(opts);
336 | style();
337 | tpl(keywords);
338 | bindEvents();
339 | keywords && setTimeout(function (_) { return doSearch(keywords); }, 500);
340 | }
341 |
342 | function update(opts, vm) {
343 | updateOptions(opts);
344 | updatePlaceholder(opts.placeholder, vm.route.path);
345 | updateNoData(opts.noData, vm.route.path);
346 | }
347 |
348 | /* eslint-disable no-unused-vars */
349 |
350 | var CONFIG = {
351 | placeholder: 'Type to search',
352 | noData: 'No Results!',
353 | paths: 'auto',
354 | depth: 2,
355 | maxAge: 86400000, // 1 day
356 | hideOtherSidebarContent: false,
357 | namespace: undefined,
358 | };
359 |
360 | var install = function(hook, vm) {
361 | var util = Docsify.util;
362 | var opts = vm.config.search || CONFIG;
363 |
364 | if (Array.isArray(opts)) {
365 | CONFIG.paths = opts;
366 | } else if (typeof opts === 'object') {
367 | CONFIG.paths = Array.isArray(opts.paths) ? opts.paths : 'auto';
368 | CONFIG.maxAge = util.isPrimitive(opts.maxAge) ? opts.maxAge : CONFIG.maxAge;
369 | CONFIG.placeholder = opts.placeholder || CONFIG.placeholder;
370 | CONFIG.noData = opts.noData || CONFIG.noData;
371 | CONFIG.depth = opts.depth || CONFIG.depth;
372 | CONFIG.hideOtherSidebarContent =
373 | opts.hideOtherSidebarContent || CONFIG.hideOtherSidebarContent;
374 | CONFIG.namespace = opts.namespace || CONFIG.namespace;
375 | }
376 |
377 | var isAuto = CONFIG.paths === 'auto';
378 |
379 | hook.mounted(function (_) {
380 | init$1(CONFIG, vm);
381 | !isAuto && init(CONFIG, vm);
382 | });
383 | hook.doneEach(function (_) {
384 | update(CONFIG, vm);
385 | isAuto && init(CONFIG, vm);
386 | });
387 | };
388 |
389 | $docsify.plugins = [].concat(install, $docsify.plugins);
390 |
391 | }());
392 |
--------------------------------------------------------------------------------
/media/js/docsify_4.10.4.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | /**
3 | * Create a cached version of a pure function.
4 | */
5 | function cached(fn) {
6 | var cache = Object.create(null);
7 | return function (str) {
8 | var key = isPrimitive(str) ? str : JSON.stringify(str);
9 | var hit = cache[key];
10 | return hit || (cache[key] = fn(str))
11 | }
12 | }
13 |
14 | /**
15 | * Hyphenate a camelCase string.
16 | */
17 | var hyphenate = cached(function (str) {
18 | return str.replace(/([A-Z])/g, function (m) { return '-' + m.toLowerCase(); })
19 | });
20 |
21 | var hasOwn = Object.prototype.hasOwnProperty;
22 |
23 | /**
24 | * Simple Object.assign polyfill
25 | */
26 | var merge =
27 | Object.assign ||
28 | function (to) {
29 | var arguments$1 = arguments;
30 |
31 | for (var i = 1; i < arguments.length; i++) {
32 | var from = Object(arguments$1[i]);
33 |
34 | for (var key in from) {
35 | if (hasOwn.call(from, key)) {
36 | to[key] = from[key];
37 | }
38 | }
39 | }
40 |
41 | return to
42 | };
43 |
44 | /**
45 | * Check if value is primitive
46 | */
47 | function isPrimitive(value) {
48 | return typeof value === 'string' || typeof value === 'number'
49 | }
50 |
51 | /**
52 | * Perform no operation.
53 | */
54 | function noop() {}
55 |
56 | /**
57 | * Check if value is function
58 | */
59 | function isFn(obj) {
60 | return typeof obj === 'function'
61 | }
62 |
63 | /**
64 | * escape String
65 | */
66 | function escapeString(string) {
67 | var entityMap = {
68 | '&': '&',
69 | '<': '<',
70 | '>': '>',
71 | '"': '"',
72 | '\'': ''',
73 | '/': '/'
74 | };
75 |
76 | return String(string).replace(/[&<>"'/]/g, function (s) { return entityMap[s]; })
77 | }
78 |
79 | function config () {
80 | var config = merge(
81 | {
82 | el: '#app',
83 | repo: '',
84 | maxLevel: 6,
85 | subMaxLevel: 0,
86 | loadSidebar: null,
87 | loadNavbar: null,
88 | homepage: 'README.md',
89 | coverpage: '',
90 | basePath: '',
91 | auto2top: false,
92 | name: '',
93 | themeColor: '',
94 | nameLink: window.location.pathname,
95 | autoHeader: false,
96 | executeScript: null,
97 | noEmoji: false,
98 | ga: '',
99 | ext: '.md',
100 | mergeNavbar: false,
101 | formatUpdated: '',
102 | // this config for the links inside markdown
103 | externalLinkTarget: '_blank',
104 | // this config for the corner
105 | cornerExternalLinkTarget: '_blank',
106 | externalLinkRel: 'noopener',
107 | routerMode: 'hash',
108 | noCompileLinks: [],
109 | relativePath: false
110 | },
111 | window.$docsify
112 | );
113 |
114 | var script =
115 | document.currentScript ||
116 | [].slice
117 | .call(document.getElementsByTagName('script'))
118 | .filter(function (n) { return /docsify\./.test(n.src); })[0];
119 |
120 | if (script) {
121 | for (var prop in config) {
122 | if (hasOwn.call(config, prop)) {
123 | var val = script.getAttribute('data-' + hyphenate(prop));
124 |
125 | if (isPrimitive(val)) {
126 | config[prop] = val === '' ? true : val;
127 | }
128 | }
129 | }
130 |
131 | if (config.loadSidebar === true) {
132 | config.loadSidebar = '_sidebar' + config.ext;
133 | }
134 | if (config.loadNavbar === true) {
135 | config.loadNavbar = '_navbar' + config.ext;
136 | }
137 | if (config.coverpage === true) {
138 | config.coverpage = '_coverpage' + config.ext;
139 | }
140 | if (config.repo === true) {
141 | config.repo = '';
142 | }
143 | if (config.name === true) {
144 | config.name = '';
145 | }
146 | }
147 |
148 | window.$docsify = config;
149 |
150 | return config
151 | }
152 |
153 | function initLifecycle(vm) {
154 | var hooks = [
155 | 'init',
156 | 'mounted',
157 | 'beforeEach',
158 | 'afterEach',
159 | 'doneEach',
160 | 'ready'
161 | ];
162 |
163 | vm._hooks = {};
164 | vm._lifecycle = {};
165 | hooks.forEach(function (hook) {
166 | var arr = (vm._hooks[hook] = []);
167 | vm._lifecycle[hook] = function (fn) { return arr.push(fn); };
168 | });
169 | }
170 |
171 | function callHook(vm, hook, data, next) {
172 | if ( next === void 0 ) next = noop;
173 |
174 | var queue = vm._hooks[hook];
175 |
176 | var step = function (index) {
177 | var hook = queue[index];
178 | if (index >= queue.length) {
179 | next(data);
180 | } else if (typeof hook === 'function') {
181 | if (hook.length === 2) {
182 | hook(data, function (result) {
183 | data = result;
184 | step(index + 1);
185 | });
186 | } else {
187 | var result = hook(data);
188 | data = result === undefined ? data : result;
189 | step(index + 1);
190 | }
191 | } else {
192 | step(index + 1);
193 | }
194 | };
195 |
196 | step(0);
197 | }
198 |
199 | var inBrowser = !false;
200 |
201 | var isMobile = document.body.clientWidth <= 600;
202 |
203 | /**
204 | * @see https://github.com/MoOx/pjax/blob/master/lib/is-supported.js
205 | */
206 | var supportsPushState =
207 |
208 | (function () {
209 | // Borrowed wholesale from https://github.com/defunkt/jquery-pjax
210 | return (
211 | window.history &&
212 | window.history.pushState &&
213 | window.history.replaceState &&
214 | // PushState isn’t reliable on iOS until 5.
215 | !navigator.userAgent.match(
216 | /((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/
217 | )
218 | )
219 | })();
220 |
221 | var cacheNode = {};
222 |
223 | /**
224 | * Get Node
225 | * @param {String|Element} el
226 | * @param {Boolean} noCache
227 | * @return {Element}
228 | */
229 | function getNode(el, noCache) {
230 | if ( noCache === void 0 ) noCache = false;
231 |
232 | if (typeof el === 'string') {
233 | if (typeof window.Vue !== 'undefined') {
234 | return find(el)
235 | }
236 | el = noCache ? find(el) : cacheNode[el] || (cacheNode[el] = find(el));
237 | }
238 |
239 | return el
240 | }
241 |
242 | var $ = document;
243 |
244 | var body = $.body;
245 |
246 | var head = $.head;
247 |
248 | /**
249 | * Find element
250 | * @example
251 | * find('nav') => document.querySelector('nav')
252 | * find(nav, 'a') => nav.querySelector('a')
253 | */
254 | function find(el, node) {
255 | return node ? el.querySelector(node) : $.querySelector(el)
256 | }
257 |
258 | /**
259 | * Find all elements
260 | * @example
261 | * findAll('a') => [].slice.call(document.querySelectorAll('a'))
262 | * findAll(nav, 'a') => [].slice.call(nav.querySelectorAll('a'))
263 | */
264 | function findAll(el, node) {
265 | return [].slice.call(
266 | node ? el.querySelectorAll(node) : $.querySelectorAll(el)
267 | )
268 | }
269 |
270 | function create(node, tpl) {
271 | node = $.createElement(node);
272 | if (tpl) {
273 | node.innerHTML = tpl;
274 | }
275 | return node
276 | }
277 |
278 | function appendTo(target, el) {
279 | return target.appendChild(el)
280 | }
281 |
282 | function before(target, el) {
283 | return target.insertBefore(el, target.children[0])
284 | }
285 |
286 | function on(el, type, handler) {
287 | isFn(type) ?
288 | window.addEventListener(el, type) :
289 | el.addEventListener(type, handler);
290 | }
291 |
292 | function off(el, type, handler) {
293 | isFn(type) ?
294 | window.removeEventListener(el, type) :
295 | el.removeEventListener(type, handler);
296 | }
297 |
298 | /**
299 | * Toggle class
300 | *
301 | * @example
302 | * toggleClass(el, 'active') => el.classList.toggle('active')
303 | * toggleClass(el, 'add', 'active') => el.classList.add('active')
304 | */
305 | function toggleClass(el, type, val) {
306 | el && el.classList[val ? type : 'toggle'](val || type);
307 | }
308 |
309 | function style(content) {
310 | appendTo(head, create('style', content));
311 | }
312 |
313 | var dom = /*#__PURE__*/Object.freeze({
314 | __proto__: null,
315 | getNode: getNode,
316 | $: $,
317 | body: body,
318 | head: head,
319 | find: find,
320 | findAll: findAll,
321 | create: create,
322 | appendTo: appendTo,
323 | before: before,
324 | on: on,
325 | off: off,
326 | toggleClass: toggleClass,
327 | style: style
328 | });
329 |
330 | /**
331 | * Render github corner
332 | * @param {Object} data
333 | * @return {String}
334 | */
335 | function corner(data, cornerExternalLinkTarge) {
336 | if (!data) {
337 | return ''
338 | }
339 | if (!/\/\//.test(data)) {
340 | data = 'https://github.com/' + data;
341 | }
342 | data = data.replace(/^git\+/, '');
343 | // double check
344 | cornerExternalLinkTarge = cornerExternalLinkTarge || '_blank';
345 |
346 | return (
347 | "" +
348 | '' +
353 | ''
354 | )
355 | }
356 |
357 | /**
358 | * Render main content
359 | */
360 | function main(config) {
361 | var name = (config.name && (typeof config.name === 'string')) ? escapeString(config.name):'';
362 | var aside =
363 | '' +
368 | '';
376 | return (
377 | (isMobile ? (aside + "") : ("" + aside)) +
378 | '' +
381 | ''
382 | )
383 | }
384 | /**
385 | * Cover Page
386 | */
387 | // function cover() {
388 | // var SL = ', 100%, 85%';
389 | // var bgc =
390 | // 'linear-gradient(to left bottom, ' +
391 | // "hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 0%," +
392 | // "hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 100%)";
393 |
394 | // return (
395 | // "" +
396 | // '' +
397 | // '' +
398 | // ''
399 | // )
400 | // }
401 | // 自定义封面背景渐变色
402 | function cover() {
403 | //定义变量获取屏幕视口宽度
404 | let windowWidth = window.outerWidth;
405 | if(windowWidth < 640){
406 | var bgc = "background-color: #fff;";
407 | }
408 | if(windowWidth >= 640){
409 | var bgc = "background:url('./media/img/bg.jpg')center center / cover;";
410 | }
411 | return (
412 | "" +
413 | '' +
414 | '' +
415 | ''
416 | )
417 | }
418 |
419 | /**
420 | * Render tree
421 | * @param {Array} tree
422 | * @param {String} tpl
423 | * @return {String}
424 | */
425 | function tree(toc, tpl) {
426 | if ( tpl === void 0 ) tpl = '';
427 |
428 | if (!toc || !toc.length) {
429 | return ''
430 | }
431 | var innerHTML = '';
432 | toc.forEach(function (node) {
433 | innerHTML += "" + (node.title) + "";
434 | if (node.children) {
435 | innerHTML += tree(node.children, tpl);
436 | }
437 | });
438 | return tpl.replace('{inner}', innerHTML)
439 | }
440 |
441 | function helper(className, content) {
442 | return ("" + (content.slice(5).trim()) + "
")
443 | }
444 |
445 | function theme(color) {
446 | return ("")
447 | }
448 |
449 | var barEl;
450 | var timeId;
451 |
452 | /**
453 | * Init progress component
454 | */
455 | function init() {
456 | var div = create('div');
457 |
458 | div.classList.add('progress');
459 | appendTo(body, div);
460 | barEl = div;
461 | }
462 | /**
463 | * Render progress bar
464 | */
465 | function progressbar (ref) {
466 | var loaded = ref.loaded;
467 | var total = ref.total;
468 | var step = ref.step;
469 |
470 | var num;
471 |
472 | !barEl && init();
473 |
474 | if (step) {
475 | num = parseInt(barEl.style.width || 0, 10) + step;
476 | num = num > 80 ? 80 : num;
477 | } else {
478 | num = Math.floor(loaded / total * 100);
479 | }
480 |
481 | barEl.style.opacity = 1;
482 | barEl.style.width = num >= 95 ? '100%' : num + '%';
483 |
484 | if (num >= 95) {
485 | clearTimeout(timeId);
486 | timeId = setTimeout(function (_) {
487 | barEl.style.opacity = 0;
488 | barEl.style.width = '0%';
489 | }, 200);
490 | }
491 | }
492 |
493 | var cache = {};
494 |
495 | /**
496 | * Simple ajax get
497 | * @param {string} url
498 | * @param {boolean} [hasBar=false] has progress bar
499 | * @return { then(resolve, reject), abort }
500 | */
501 | function get(url, hasBar, headers) {
502 | if ( hasBar === void 0 ) hasBar = false;
503 | if ( headers === void 0 ) headers = {};
504 |
505 | var xhr = new XMLHttpRequest();
506 | var on = function () {
507 | xhr.addEventListener.apply(xhr, arguments);
508 | };
509 | var cached = cache[url];
510 |
511 | if (cached) {
512 | return {then: function (cb) { return cb(cached.content, cached.opt); }, abort: noop}
513 | }
514 |
515 | xhr.open('GET', url);
516 | for (var i in headers) {
517 | if (hasOwn.call(headers, i)) {
518 | xhr.setRequestHeader(i, headers[i]);
519 | }
520 | }
521 | xhr.send();
522 |
523 | return {
524 | then: function (success, error) {
525 | if ( error === void 0 ) error = noop;
526 |
527 | if (hasBar) {
528 | var id = setInterval(
529 | function (_) { return progressbar({
530 | step: Math.floor(Math.random() * 5 + 1)
531 | }); },
532 | 500
533 | );
534 |
535 | on('progress', progressbar);
536 | on('loadend', function (evt) {
537 | progressbar(evt);
538 | clearInterval(id);
539 | });
540 | }
541 |
542 | on('error', error);
543 | on('load', function (ref) {
544 | var target = ref.target;
545 |
546 | if (target.status >= 400) {
547 | error(target);
548 | } else {
549 | var result = (cache[url] = {
550 | content: target.response,
551 | opt: {
552 | updatedAt: xhr.getResponseHeader('last-modified')
553 | }
554 | });
555 |
556 | success(result.content, result.opt);
557 | }
558 | });
559 | },
560 | abort: function (_) { return xhr.readyState !== 4 && xhr.abort(); }
561 | }
562 | }
563 |
564 | function replaceVar(block, color) {
565 | block.innerHTML = block.innerHTML.replace(
566 | /var\(\s*--theme-color.*?\)/g,
567 | color
568 | );
569 | }
570 |
571 | function cssVars (color) {
572 | // Variable support
573 | if (window.CSS && window.CSS.supports && window.CSS.supports('(--v:red)')) {
574 | return
575 | }
576 |
577 | var styleBlocks = findAll('style:not(.inserted),link');
578 | [].forEach.call(styleBlocks, function (block) {
579 | if (block.nodeName === 'STYLE') {
580 | replaceVar(block, color);
581 | } else if (block.nodeName === 'LINK') {
582 | var href = block.getAttribute('href');
583 |
584 | if (!/\.css$/.test(href)) {
585 | return
586 | }
587 |
588 | get(href).then(function (res) {
589 | var style = create('style', res);
590 |
591 | head.appendChild(style);
592 | replaceVar(style, color);
593 | });
594 | }
595 | });
596 | }
597 |
598 | var RGX = /([^{]*?)\w(?=\})/g;
599 |
600 | var MAP = {
601 | YYYY: 'getFullYear',
602 | YY: 'getYear',
603 | MM: function (d) {
604 | return d.getMonth() + 1;
605 | },
606 | DD: 'getDate',
607 | HH: 'getHours',
608 | mm: 'getMinutes',
609 | ss: 'getSeconds',
610 | fff: 'getMilliseconds'
611 | };
612 |
613 | function tinydate (str, custom) {
614 | var parts=[], offset=0;
615 |
616 | str.replace(RGX, function (key, _, idx) {
617 | // save preceding string
618 | parts.push(str.substring(offset, idx - 1));
619 | offset = idx += key.length + 1;
620 | // save function
621 | parts.push(custom && custom[key] || function (d) {
622 | return ('00' + (typeof MAP[key] === 'string' ? d[MAP[key]]() : MAP[key](d))).slice(-key.length);
623 | });
624 | });
625 |
626 | if (offset !== str.length) {
627 | parts.push(str.substring(offset));
628 | }
629 |
630 | return function (arg) {
631 | var out='', i=0, d=arg||new Date();
632 | for (; i ?(paragraph|[^\n]*)(?:\n|$))+/,
659 | list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
660 | html: '^ {0,3}(?:' // optional indentation
661 | + '<(script|pre|style)[\\s>][\\s\\S]*?(?:\\1>[^\\n]*\\n+|$)' // (1)
662 | + '|comment[^\\n]*(\\n+|$)' // (2)
663 | + '|<\\?[\\s\\S]*?\\?>\\n*' // (3)
664 | + '|\\n*' // (4)
665 | + '|\\n*' // (5)
666 | + '|?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' // (6)
667 | + '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
668 | + '|(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
669 | + ')',
670 | def: /^ {0,3}\[(label)\]: *\n? *([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
671 | nptable: noop,
672 | table: noop,
673 | lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
674 | // regex template, placeholders will be replaced according to different paragraph
675 | // interruption rules of commonmark and the original markdown spec:
676 | _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,
677 | text: /^[^\n]+/
678 | };
679 |
680 | block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
681 | block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
682 | block.def = edit(block.def)
683 | .replace('label', block._label)
684 | .replace('title', block._title)
685 | .getRegex();
686 |
687 | block.bullet = /(?:[*+-]|\d{1,9}\.)/;
688 | block.item = /^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/;
689 | block.item = edit(block.item, 'gm')
690 | .replace(/bull/g, block.bullet)
691 | .getRegex();
692 |
693 | block.list = edit(block.list)
694 | .replace(/bull/g, block.bullet)
695 | .replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
696 | .replace('def', '\\n+(?=' + block.def.source + ')')
697 | .getRegex();
698 |
699 | block._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
700 | + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
701 | + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
702 | + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
703 | + '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
704 | + '|track|ul';
705 | block._comment = //;
706 | block.html = edit(block.html, 'i')
707 | .replace('comment', block._comment)
708 | .replace('tag', block._tag)
709 | .replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
710 | .getRegex();
711 |
712 | block.paragraph = edit(block._paragraph)
713 | .replace('hr', block.hr)
714 | .replace('heading', ' {0,3}#{1,6} +')
715 | .replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
716 | .replace('blockquote', ' {0,3}>')
717 | .replace('fences', ' {0,3}(?:`{3,}|~{3,})[^`\\n]*\\n')
718 | .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
719 | .replace('html', '?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
720 | .replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
721 | .getRegex();
722 |
723 | block.blockquote = edit(block.blockquote)
724 | .replace('paragraph', block.paragraph)
725 | .getRegex();
726 |
727 | /**
728 | * Normal Block Grammar
729 | */
730 |
731 | block.normal = merge({}, block);
732 |
733 | /**
734 | * GFM Block Grammar
735 | */
736 |
737 | block.gfm = merge({}, block.normal, {
738 | nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,
739 | table: /^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/
740 | });
741 |
742 | /**
743 | * Pedantic grammar (original John Gruber's loose markdown specification)
744 | */
745 |
746 | block.pedantic = merge({}, block.normal, {
747 | html: edit(
748 | '^ *(?:comment *(?:\\n|\\s*$)'
749 | + '|<(tag)[\\s\\S]+?\\1> *(?:\\n{2,}|\\s*$)' // closed tag
750 | + '|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
751 | .replace('comment', block._comment)
752 | .replace(/tag/g, '(?!(?:'
753 | + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
754 | + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
755 | + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
756 | .getRegex(),
757 | def: /^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
758 | heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
759 | fences: noop, // fences not supported
760 | paragraph: edit(block.normal._paragraph)
761 | .replace('hr', block.hr)
762 | .replace('heading', ' *#{1,6} *[^\n]')
763 | .replace('lheading', block.lheading)
764 | .replace('blockquote', ' {0,3}>')
765 | .replace('|fences', '')
766 | .replace('|list', '')
767 | .replace('|html', '')
768 | .getRegex()
769 | });
770 |
771 | /**
772 | * Block Lexer
773 | */
774 |
775 | function Lexer(options) {
776 | this.tokens = [];
777 | this.tokens.links = Object.create(null);
778 | this.options = options || marked.defaults;
779 | this.rules = block.normal;
780 |
781 | if (this.options.pedantic) {
782 | this.rules = block.pedantic;
783 | } else if (this.options.gfm) {
784 | this.rules = block.gfm;
785 | }
786 | }
787 |
788 | /**
789 | * Expose Block Rules
790 | */
791 |
792 | Lexer.rules = block;
793 |
794 | /**
795 | * Static Lex Method
796 | */
797 |
798 | Lexer.lex = function(src, options) {
799 | var lexer = new Lexer(options);
800 | return lexer.lex(src);
801 | };
802 |
803 | /**
804 | * Preprocessing
805 | */
806 |
807 | Lexer.prototype.lex = function(src) {
808 | src = src
809 | .replace(/\r\n|\r/g, '\n')
810 | .replace(/\t/g, ' ')
811 | .replace(/\u00a0/g, ' ')
812 | .replace(/\u2424/g, '\n');
813 |
814 | return this.token(src, true);
815 | };
816 |
817 | /**
818 | * Lexing
819 | */
820 |
821 | Lexer.prototype.token = function(src, top) {
822 | src = src.replace(/^ +$/gm, '');
823 | var next,
824 | loose,
825 | cap,
826 | bull,
827 | b,
828 | item,
829 | listStart,
830 | listItems,
831 | t,
832 | space,
833 | i,
834 | tag,
835 | l,
836 | isordered,
837 | istask,
838 | ischecked;
839 |
840 | while (src) {
841 | // newline
842 | if (cap = this.rules.newline.exec(src)) {
843 | src = src.substring(cap[0].length);
844 | if (cap[0].length > 1) {
845 | this.tokens.push({
846 | type: 'space'
847 | });
848 | }
849 | }
850 |
851 | // code
852 | if (cap = this.rules.code.exec(src)) {
853 | var lastToken = this.tokens[this.tokens.length - 1];
854 | src = src.substring(cap[0].length);
855 | // An indented code block cannot interrupt a paragraph.
856 | if (lastToken && lastToken.type === 'paragraph') {
857 | lastToken.text += '\n' + cap[0].trimRight();
858 | } else {
859 | cap = cap[0].replace(/^ {4}/gm, '');
860 | this.tokens.push({
861 | type: 'code',
862 | codeBlockStyle: 'indented',
863 | text: !this.options.pedantic
864 | ? rtrim(cap, '\n')
865 | : cap
866 | });
867 | }
868 | continue;
869 | }
870 |
871 | // fences
872 | if (cap = this.rules.fences.exec(src)) {
873 | src = src.substring(cap[0].length);
874 | this.tokens.push({
875 | type: 'code',
876 | lang: cap[2] ? cap[2].trim() : cap[2],
877 | text: cap[3] || ''
878 | });
879 | continue;
880 | }
881 |
882 | // heading
883 | if (cap = this.rules.heading.exec(src)) {
884 | src = src.substring(cap[0].length);
885 | this.tokens.push({
886 | type: 'heading',
887 | depth: cap[1].length,
888 | text: cap[2]
889 | });
890 | continue;
891 | }
892 |
893 | // table no leading pipe (gfm)
894 | if (cap = this.rules.nptable.exec(src)) {
895 | item = {
896 | type: 'table',
897 | header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
898 | align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
899 | cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
900 | };
901 |
902 | if (item.header.length === item.align.length) {
903 | src = src.substring(cap[0].length);
904 |
905 | for (i = 0; i < item.align.length; i++) {
906 | if (/^ *-+: *$/.test(item.align[i])) {
907 | item.align[i] = 'right';
908 | } else if (/^ *:-+: *$/.test(item.align[i])) {
909 | item.align[i] = 'center';
910 | } else if (/^ *:-+ *$/.test(item.align[i])) {
911 | item.align[i] = 'left';
912 | } else {
913 | item.align[i] = null;
914 | }
915 | }
916 |
917 | for (i = 0; i < item.cells.length; i++) {
918 | item.cells[i] = splitCells(item.cells[i], item.header.length);
919 | }
920 |
921 | this.tokens.push(item);
922 |
923 | continue;
924 | }
925 | }
926 |
927 | // hr
928 | if (cap = this.rules.hr.exec(src)) {
929 | src = src.substring(cap[0].length);
930 | this.tokens.push({
931 | type: 'hr'
932 | });
933 | continue;
934 | }
935 |
936 | // blockquote
937 | if (cap = this.rules.blockquote.exec(src)) {
938 | src = src.substring(cap[0].length);
939 |
940 | this.tokens.push({
941 | type: 'blockquote_start'
942 | });
943 |
944 | cap = cap[0].replace(/^ *> ?/gm, '');
945 |
946 | // Pass `top` to keep the current
947 | // "toplevel" state. This is exactly
948 | // how markdown.pl works.
949 | this.token(cap, top);
950 |
951 | this.tokens.push({
952 | type: 'blockquote_end'
953 | });
954 |
955 | continue;
956 | }
957 |
958 | // list
959 | if (cap = this.rules.list.exec(src)) {
960 | src = src.substring(cap[0].length);
961 | bull = cap[2];
962 | isordered = bull.length > 1;
963 |
964 | listStart = {
965 | type: 'list_start',
966 | ordered: isordered,
967 | start: isordered ? +bull : '',
968 | loose: false
969 | };
970 |
971 | this.tokens.push(listStart);
972 |
973 | // Get each top-level item.
974 | cap = cap[0].match(this.rules.item);
975 |
976 | listItems = [];
977 | next = false;
978 | l = cap.length;
979 | i = 0;
980 |
981 | for (; i < l; i++) {
982 | item = cap[i];
983 |
984 | // Remove the list item's bullet
985 | // so it is seen as the next token.
986 | space = item.length;
987 | item = item.replace(/^ *([*+-]|\d+\.) */, '');
988 |
989 | // Outdent whatever the
990 | // list item contains. Hacky.
991 | if (~item.indexOf('\n ')) {
992 | space -= item.length;
993 | item = !this.options.pedantic
994 | ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
995 | : item.replace(/^ {1,4}/gm, '');
996 | }
997 |
998 | // Determine whether the next list item belongs here.
999 | // Backpedal if it does not belong in this list.
1000 | if (i !== l - 1) {
1001 | b = block.bullet.exec(cap[i + 1])[0];
1002 | if (bull.length > 1 ? b.length === 1
1003 | : (b.length > 1 || (this.options.smartLists && b !== bull))) {
1004 | src = cap.slice(i + 1).join('\n') + src;
1005 | i = l - 1;
1006 | }
1007 | }
1008 |
1009 | // Determine whether item is loose or not.
1010 | // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
1011 | // for discount behavior.
1012 | loose = next || /\n\n(?!\s*$)/.test(item);
1013 | if (i !== l - 1) {
1014 | next = item.charAt(item.length - 1) === '\n';
1015 | if (!loose) { loose = next; }
1016 | }
1017 |
1018 | if (loose) {
1019 | listStart.loose = true;
1020 | }
1021 |
1022 | // Check for task list items
1023 | istask = /^\[[ xX]\] /.test(item);
1024 | ischecked = undefined;
1025 | if (istask) {
1026 | ischecked = item[1] !== ' ';
1027 | item = item.replace(/^\[[ xX]\] +/, '');
1028 | }
1029 |
1030 | t = {
1031 | type: 'list_item_start',
1032 | task: istask,
1033 | checked: ischecked,
1034 | loose: loose
1035 | };
1036 |
1037 | listItems.push(t);
1038 | this.tokens.push(t);
1039 |
1040 | // Recurse.
1041 | this.token(item, false);
1042 |
1043 | this.tokens.push({
1044 | type: 'list_item_end'
1045 | });
1046 | }
1047 |
1048 | if (listStart.loose) {
1049 | l = listItems.length;
1050 | i = 0;
1051 | for (; i < l; i++) {
1052 | listItems[i].loose = true;
1053 | }
1054 | }
1055 |
1056 | this.tokens.push({
1057 | type: 'list_end'
1058 | });
1059 |
1060 | continue;
1061 | }
1062 |
1063 | // html
1064 | if (cap = this.rules.html.exec(src)) {
1065 | src = src.substring(cap[0].length);
1066 | this.tokens.push({
1067 | type: this.options.sanitize
1068 | ? 'paragraph'
1069 | : 'html',
1070 | pre: !this.options.sanitizer
1071 | && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
1072 | text: this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0])) : cap[0]
1073 | });
1074 | continue;
1075 | }
1076 |
1077 | // def
1078 | if (top && (cap = this.rules.def.exec(src))) {
1079 | src = src.substring(cap[0].length);
1080 | if (cap[3]) { cap[3] = cap[3].substring(1, cap[3].length - 1); }
1081 | tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
1082 | if (!this.tokens.links[tag]) {
1083 | this.tokens.links[tag] = {
1084 | href: cap[2],
1085 | title: cap[3]
1086 | };
1087 | }
1088 | continue;
1089 | }
1090 |
1091 | // table (gfm)
1092 | if (cap = this.rules.table.exec(src)) {
1093 | item = {
1094 | type: 'table',
1095 | header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
1096 | align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
1097 | cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
1098 | };
1099 |
1100 | if (item.header.length === item.align.length) {
1101 | src = src.substring(cap[0].length);
1102 |
1103 | for (i = 0; i < item.align.length; i++) {
1104 | if (/^ *-+: *$/.test(item.align[i])) {
1105 | item.align[i] = 'right';
1106 | } else if (/^ *:-+: *$/.test(item.align[i])) {
1107 | item.align[i] = 'center';
1108 | } else if (/^ *:-+ *$/.test(item.align[i])) {
1109 | item.align[i] = 'left';
1110 | } else {
1111 | item.align[i] = null;
1112 | }
1113 | }
1114 |
1115 | for (i = 0; i < item.cells.length; i++) {
1116 | item.cells[i] = splitCells(
1117 | item.cells[i].replace(/^ *\| *| *\| *$/g, ''),
1118 | item.header.length);
1119 | }
1120 |
1121 | this.tokens.push(item);
1122 |
1123 | continue;
1124 | }
1125 | }
1126 |
1127 | // lheading
1128 | if (cap = this.rules.lheading.exec(src)) {
1129 | src = src.substring(cap[0].length);
1130 | this.tokens.push({
1131 | type: 'heading',
1132 | depth: cap[2].charAt(0) === '=' ? 1 : 2,
1133 | text: cap[1]
1134 | });
1135 | continue;
1136 | }
1137 |
1138 | // top-level paragraph
1139 | if (top && (cap = this.rules.paragraph.exec(src))) {
1140 | src = src.substring(cap[0].length);
1141 | this.tokens.push({
1142 | type: 'paragraph',
1143 | text: cap[1].charAt(cap[1].length - 1) === '\n'
1144 | ? cap[1].slice(0, -1)
1145 | : cap[1]
1146 | });
1147 | continue;
1148 | }
1149 |
1150 | // text
1151 | if (cap = this.rules.text.exec(src)) {
1152 | // Top-level should never reach here.
1153 | src = src.substring(cap[0].length);
1154 | this.tokens.push({
1155 | type: 'text',
1156 | text: cap[0]
1157 | });
1158 | continue;
1159 | }
1160 |
1161 | if (src) {
1162 | throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
1163 | }
1164 | }
1165 |
1166 | return this.tokens;
1167 | };
1168 |
1169 | /**
1170 | * Inline-Level Grammar
1171 | */
1172 |
1173 | var inline = {
1174 | escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
1175 | autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
1176 | url: noop,
1177 | tag: '^comment'
1178 | + '|^[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
1179 | + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
1180 | + '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g.
1181 | + '|^' // declaration, e.g.
1182 | + '|^', // CDATA section
1183 | link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,
1184 | reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
1185 | nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
1186 | strong: /^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,
1187 | em: /^_([^\s_])_(?!_)|^\*([^\s*<\[])\*(?!\*)|^_([^\s<][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_<][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s<"][\s\S]*?[^\s\*])\*(?!\*|[^\spunctuation])|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,
1188 | code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
1189 | br: /^( {2,}|\\)\n(?!\s*$)/,
1190 | del: noop,
1191 | text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\?@\\[^_{|}~';
1197 | inline.em = edit(inline.em).replace(/punctuation/g, inline._punctuation).getRegex();
1198 |
1199 | inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
1200 |
1201 | inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
1202 | inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
1203 | inline.autolink = edit(inline.autolink)
1204 | .replace('scheme', inline._scheme)
1205 | .replace('email', inline._email)
1206 | .getRegex();
1207 |
1208 | inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
1209 |
1210 | inline.tag = edit(inline.tag)
1211 | .replace('comment', block._comment)
1212 | .replace('attribute', inline._attribute)
1213 | .getRegex();
1214 |
1215 | inline._label = /(?:\[[^\[\]]*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
1216 | inline._href = /<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/;
1217 | inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
1218 |
1219 | inline.link = edit(inline.link)
1220 | .replace('label', inline._label)
1221 | .replace('href', inline._href)
1222 | .replace('title', inline._title)
1223 | .getRegex();
1224 |
1225 | inline.reflink = edit(inline.reflink)
1226 | .replace('label', inline._label)
1227 | .getRegex();
1228 |
1229 | /**
1230 | * Normal Inline Grammar
1231 | */
1232 |
1233 | inline.normal = merge({}, inline);
1234 |
1235 | /**
1236 | * Pedantic Inline Grammar
1237 | */
1238 |
1239 | inline.pedantic = merge({}, inline.normal, {
1240 | strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
1241 | em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,
1242 | link: edit(/^!?\[(label)\]\((.*?)\)/)
1243 | .replace('label', inline._label)
1244 | .getRegex(),
1245 | reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
1246 | .replace('label', inline._label)
1247 | .getRegex()
1248 | });
1249 |
1250 | /**
1251 | * GFM Inline Grammar
1252 | */
1253 |
1254 | inline.gfm = merge({}, inline.normal, {
1255 | escape: edit(inline.escape).replace('])', '~|])').getRegex(),
1256 | _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
1257 | url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
1258 | _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
1259 | del: /^~+(?=\S)([\s\S]*?\S)~+/,
1260 | text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\/i.test(cap[0])) {
1345 | this.inLink = false;
1346 | }
1347 | if (!this.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
1348 | this.inRawBlock = true;
1349 | } else if (this.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
1350 | this.inRawBlock = false;
1351 | }
1352 |
1353 | src = src.substring(cap[0].length);
1354 | out += this.options.sanitize
1355 | ? this.options.sanitizer
1356 | ? this.options.sanitizer(cap[0])
1357 | : escape(cap[0])
1358 | : cap[0];
1359 | continue;
1360 | }
1361 |
1362 | // link
1363 | if (cap = this.rules.link.exec(src)) {
1364 | var lastParenIndex = findClosingBracket(cap[2], '()');
1365 | if (lastParenIndex > -1) {
1366 | var linkLen = 4 + cap[1].length + lastParenIndex;
1367 | cap[2] = cap[2].substring(0, lastParenIndex);
1368 | cap[0] = cap[0].substring(0, linkLen).trim();
1369 | cap[3] = '';
1370 | }
1371 | src = src.substring(cap[0].length);
1372 | this.inLink = true;
1373 | href = cap[2];
1374 | if (this.options.pedantic) {
1375 | link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
1376 |
1377 | if (link) {
1378 | href = link[1];
1379 | title = link[3];
1380 | } else {
1381 | title = '';
1382 | }
1383 | } else {
1384 | title = cap[3] ? cap[3].slice(1, -1) : '';
1385 | }
1386 | href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
1387 | out += this.outputLink(cap, {
1388 | href: InlineLexer.escapes(href),
1389 | title: InlineLexer.escapes(title)
1390 | });
1391 | this.inLink = false;
1392 | continue;
1393 | }
1394 |
1395 | // reflink, nolink
1396 | if ((cap = this.rules.reflink.exec(src))
1397 | || (cap = this.rules.nolink.exec(src))) {
1398 | src = src.substring(cap[0].length);
1399 | link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
1400 | link = this.links[link.toLowerCase()];
1401 | if (!link || !link.href) {
1402 | out += cap[0].charAt(0);
1403 | src = cap[0].substring(1) + src;
1404 | continue;
1405 | }
1406 | this.inLink = true;
1407 | out += this.outputLink(cap, link);
1408 | this.inLink = false;
1409 | continue;
1410 | }
1411 |
1412 | // strong
1413 | if (cap = this.rules.strong.exec(src)) {
1414 | src = src.substring(cap[0].length);
1415 | out += this.renderer.strong(this.output(cap[4] || cap[3] || cap[2] || cap[1]));
1416 | continue;
1417 | }
1418 |
1419 | // em
1420 | if (cap = this.rules.em.exec(src)) {
1421 | src = src.substring(cap[0].length);
1422 | out += this.renderer.em(this.output(cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1]));
1423 | continue;
1424 | }
1425 |
1426 | // code
1427 | if (cap = this.rules.code.exec(src)) {
1428 | src = src.substring(cap[0].length);
1429 | out += this.renderer.codespan(escape(cap[2].trim(), true));
1430 | continue;
1431 | }
1432 |
1433 | // br
1434 | if (cap = this.rules.br.exec(src)) {
1435 | src = src.substring(cap[0].length);
1436 | out += this.renderer.br();
1437 | continue;
1438 | }
1439 |
1440 | // del (gfm)
1441 | if (cap = this.rules.del.exec(src)) {
1442 | src = src.substring(cap[0].length);
1443 | out += this.renderer.del(this.output(cap[1]));
1444 | continue;
1445 | }
1446 |
1447 | // autolink
1448 | if (cap = this.rules.autolink.exec(src)) {
1449 | src = src.substring(cap[0].length);
1450 | if (cap[2] === '@') {
1451 | text = escape(this.mangle(cap[1]));
1452 | href = 'mailto:' + text;
1453 | } else {
1454 | text = escape(cap[1]);
1455 | href = text;
1456 | }
1457 | out += this.renderer.link(href, null, text);
1458 | continue;
1459 | }
1460 |
1461 | // url (gfm)
1462 | if (!this.inLink && (cap = this.rules.url.exec(src))) {
1463 | if (cap[2] === '@') {
1464 | text = escape(cap[0]);
1465 | href = 'mailto:' + text;
1466 | } else {
1467 | // do extended autolink path validation
1468 | do {
1469 | prevCapZero = cap[0];
1470 | cap[0] = this.rules._backpedal.exec(cap[0])[0];
1471 | } while (prevCapZero !== cap[0]);
1472 | text = escape(cap[0]);
1473 | if (cap[1] === 'www.') {
1474 | href = 'http://' + text;
1475 | } else {
1476 | href = text;
1477 | }
1478 | }
1479 | src = src.substring(cap[0].length);
1480 | out += this.renderer.link(href, null, text);
1481 | continue;
1482 | }
1483 |
1484 | // text
1485 | if (cap = this.rules.text.exec(src)) {
1486 | src = src.substring(cap[0].length);
1487 | if (this.inRawBlock) {
1488 | out += this.renderer.text(this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0])) : cap[0]);
1489 | } else {
1490 | out += this.renderer.text(escape(this.smartypants(cap[0])));
1491 | }
1492 | continue;
1493 | }
1494 |
1495 | if (src) {
1496 | throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
1497 | }
1498 | }
1499 |
1500 | return out;
1501 | };
1502 |
1503 | InlineLexer.escapes = function(text) {
1504 | return text ? text.replace(InlineLexer.rules._escapes, '$1') : text;
1505 | };
1506 |
1507 | /**
1508 | * Compile Link
1509 | */
1510 |
1511 | InlineLexer.prototype.outputLink = function(cap, link) {
1512 | var href = link.href,
1513 | title = link.title ? escape(link.title) : null;
1514 |
1515 | return cap[0].charAt(0) !== '!'
1516 | ? this.renderer.link(href, title, this.output(cap[1]))
1517 | : this.renderer.image(href, title, escape(cap[1]));
1518 | };
1519 |
1520 | /**
1521 | * Smartypants Transformations
1522 | */
1523 |
1524 | InlineLexer.prototype.smartypants = function(text) {
1525 | if (!this.options.smartypants) { return text; }
1526 | return text
1527 | // em-dashes
1528 | .replace(/---/g, '\u2014')
1529 | // en-dashes
1530 | .replace(/--/g, '\u2013')
1531 | // opening singles
1532 | .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
1533 | // closing singles & apostrophes
1534 | .replace(/'/g, '\u2019')
1535 | // opening doubles
1536 | .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
1537 | // closing doubles
1538 | .replace(/"/g, '\u201d')
1539 | // ellipses
1540 | .replace(/\.{3}/g, '\u2026');
1541 | };
1542 |
1543 | /**
1544 | * Mangle Links
1545 | */
1546 |
1547 | InlineLexer.prototype.mangle = function(text) {
1548 | if (!this.options.mangle) { return text; }
1549 | var out = '',
1550 | l = text.length,
1551 | i = 0,
1552 | ch;
1553 |
1554 | for (; i < l; i++) {
1555 | ch = text.charCodeAt(i);
1556 | if (Math.random() > 0.5) {
1557 | ch = 'x' + ch.toString(16);
1558 | }
1559 | out += '' + ch + ';';
1560 | }
1561 |
1562 | return out;
1563 | };
1564 |
1565 | /**
1566 | * Renderer
1567 | */
1568 |
1569 | function Renderer(options) {
1570 | this.options = options || marked.defaults;
1571 | }
1572 |
1573 | Renderer.prototype.code = function(code, infostring, escaped) {
1574 | var lang = (infostring || '').match(/\S*/)[0];
1575 | if (this.options.highlight) {
1576 | var out = this.options.highlight(code, lang);
1577 | if (out != null && out !== code) {
1578 | escaped = true;
1579 | code = out;
1580 | }
1581 | }
1582 |
1583 | if (!lang) {
1584 | return ''
1585 | + (escaped ? code : escape(code, true))
1586 | + '
';
1587 | }
1588 |
1589 | return ''
1593 | + (escaped ? code : escape(code, true))
1594 | + '
\n';
1595 | };
1596 |
1597 | Renderer.prototype.blockquote = function(quote) {
1598 | return '\n' + quote + '
\n';
1599 | };
1600 |
1601 | Renderer.prototype.html = function(html) {
1602 | return html;
1603 | };
1604 |
1605 | Renderer.prototype.heading = function(text, level, raw, slugger) {
1606 | if (this.options.headerIds) {
1607 | return '\n';
1617 | }
1618 | // ignore IDs
1619 | return '' + text + '\n';
1620 | };
1621 |
1622 | Renderer.prototype.hr = function() {
1623 | return this.options.xhtml ? '
\n' : '
\n';
1624 | };
1625 |
1626 | Renderer.prototype.list = function(body, ordered, start) {
1627 | var type = ordered ? 'ol' : 'ul',
1628 | startatt = (ordered && start !== 1) ? (' start="' + start + '"') : '';
1629 | return '<' + type + startatt + '>\n' + body + '' + type + '>\n';
1630 | };
1631 |
1632 | Renderer.prototype.listitem = function(text) {
1633 | return '' + text + '\n';
1634 | };
1635 |
1636 | Renderer.prototype.checkbox = function(checked) {
1637 | return ' ';
1642 | };
1643 |
1644 | Renderer.prototype.paragraph = function(text) {
1645 | return '' + text + '
\n';
1646 | };
1647 |
1648 | Renderer.prototype.table = function(header, body) {
1649 | if (body) { body = '' + body + ''; }
1650 |
1651 | return '\n'
1652 | + '\n'
1653 | + header
1654 | + '\n'
1655 | + body
1656 | + '
\n';
1657 | };
1658 |
1659 | Renderer.prototype.tablerow = function(content) {
1660 | return '\n' + content + '
\n';
1661 | };
1662 |
1663 | Renderer.prototype.tablecell = function(content, flags) {
1664 | var type = flags.header ? 'th' : 'td';
1665 | var tag = flags.align
1666 | ? '<' + type + ' align="' + flags.align + '">'
1667 | : '<' + type + '>';
1668 | return tag + content + '' + type + '>\n';
1669 | };
1670 |
1671 | // span level renderer
1672 | Renderer.prototype.strong = function(text) {
1673 | return '' + text + '';
1674 | };
1675 |
1676 | Renderer.prototype.em = function(text) {
1677 | return '' + text + '';
1678 | };
1679 |
1680 | Renderer.prototype.codespan = function(text) {
1681 | return '' + text + '';
1682 | };
1683 |
1684 | Renderer.prototype.br = function() {
1685 | return this.options.xhtml ? '
' : '
';
1686 | };
1687 |
1688 | Renderer.prototype.del = function(text) {
1689 | return '' + text + '';
1690 | };
1691 |
1692 | Renderer.prototype.link = function(href, title, text) {
1693 | href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
1694 | if (href === null) {
1695 | return text;
1696 | }
1697 | var out = '' + text + '';
1702 | return out;
1703 | };
1704 |
1705 | Renderer.prototype.image = function(href, title, text) {
1706 | href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
1707 | if (href === null) {
1708 | return text;
1709 | }
1710 |
1711 | var out = '
' : '>';
1716 | return out;
1717 | };
1718 |
1719 | Renderer.prototype.text = function(text) {
1720 | return text;
1721 | };
1722 |
1723 | /**
1724 | * TextRenderer
1725 | * returns only the textual part of the token
1726 | */
1727 |
1728 | function TextRenderer() {}
1729 |
1730 | // no need for block level renderers
1731 |
1732 | TextRenderer.prototype.strong =
1733 | TextRenderer.prototype.em =
1734 | TextRenderer.prototype.codespan =
1735 | TextRenderer.prototype.del =
1736 | TextRenderer.prototype.text = function(text) {
1737 | return text;
1738 | };
1739 |
1740 | TextRenderer.prototype.link =
1741 | TextRenderer.prototype.image = function(href, title, text) {
1742 | return '' + text;
1743 | };
1744 |
1745 | TextRenderer.prototype.br = function() {
1746 | return '';
1747 | };
1748 |
1749 | /**
1750 | * Parsing & Compiling
1751 | */
1752 |
1753 | function Parser(options) {
1754 | this.tokens = [];
1755 | this.token = null;
1756 | this.options = options || marked.defaults;
1757 | this.options.renderer = this.options.renderer || new Renderer();
1758 | this.renderer = this.options.renderer;
1759 | this.renderer.options = this.options;
1760 | this.slugger = new Slugger();
1761 | }
1762 |
1763 | /**
1764 | * Static Parse Method
1765 | */
1766 |
1767 | Parser.parse = function(src, options) {
1768 | var parser = new Parser(options);
1769 | return parser.parse(src);
1770 | };
1771 |
1772 | /**
1773 | * Parse Loop
1774 | */
1775 |
1776 | Parser.prototype.parse = function(src) {
1777 | this.inline = new InlineLexer(src.links, this.options);
1778 | // use an InlineLexer with a TextRenderer to extract pure text
1779 | this.inlineText = new InlineLexer(
1780 | src.links,
1781 | merge({}, this.options, { renderer: new TextRenderer() })
1782 | );
1783 | this.tokens = src.reverse();
1784 |
1785 | var out = '';
1786 | while (this.next()) {
1787 | out += this.tok();
1788 | }
1789 |
1790 | return out;
1791 | };
1792 |
1793 | /**
1794 | * Next Token
1795 | */
1796 |
1797 | Parser.prototype.next = function() {
1798 | this.token = this.tokens.pop();
1799 | return this.token;
1800 | };
1801 |
1802 | /**
1803 | * Preview Next Token
1804 | */
1805 |
1806 | Parser.prototype.peek = function() {
1807 | return this.tokens[this.tokens.length - 1] || 0;
1808 | };
1809 |
1810 | /**
1811 | * Parse Text Tokens
1812 | */
1813 |
1814 | Parser.prototype.parseText = function() {
1815 | var body = this.token.text;
1816 |
1817 | while (this.peek().type === 'text') {
1818 | body += '\n' + this.next().text;
1819 | }
1820 |
1821 | return this.inline.output(body);
1822 | };
1823 |
1824 | /**
1825 | * Parse Current Token
1826 | */
1827 |
1828 | Parser.prototype.tok = function() {
1829 | switch (this.token.type) {
1830 | case 'space': {
1831 | return '';
1832 | }
1833 | case 'hr': {
1834 | return this.renderer.hr();
1835 | }
1836 | case 'heading': {
1837 | return this.renderer.heading(
1838 | this.inline.output(this.token.text),
1839 | this.token.depth,
1840 | unescape(this.inlineText.output(this.token.text)),
1841 | this.slugger);
1842 | }
1843 | case 'code': {
1844 | return this.renderer.code(this.token.text,
1845 | this.token.lang,
1846 | this.token.escaped);
1847 | }
1848 | case 'table': {
1849 | var header = '',
1850 | body = '',
1851 | i,
1852 | row,
1853 | cell,
1854 | j;
1855 |
1856 | // header
1857 | cell = '';
1858 | for (i = 0; i < this.token.header.length; i++) {
1859 | cell += this.renderer.tablecell(
1860 | this.inline.output(this.token.header[i]),
1861 | { header: true, align: this.token.align[i] }
1862 | );
1863 | }
1864 | header += this.renderer.tablerow(cell);
1865 |
1866 | for (i = 0; i < this.token.cells.length; i++) {
1867 | row = this.token.cells[i];
1868 |
1869 | cell = '';
1870 | for (j = 0; j < row.length; j++) {
1871 | cell += this.renderer.tablecell(
1872 | this.inline.output(row[j]),
1873 | { header: false, align: this.token.align[j] }
1874 | );
1875 | }
1876 |
1877 | body += this.renderer.tablerow(cell);
1878 | }
1879 | return this.renderer.table(header, body);
1880 | }
1881 | case 'blockquote_start': {
1882 | body = '';
1883 |
1884 | while (this.next().type !== 'blockquote_end') {
1885 | body += this.tok();
1886 | }
1887 |
1888 | return this.renderer.blockquote(body);
1889 | }
1890 | case 'list_start': {
1891 | body = '';
1892 | var ordered = this.token.ordered,
1893 | start = this.token.start;
1894 |
1895 | while (this.next().type !== 'list_end') {
1896 | body += this.tok();
1897 | }
1898 |
1899 | return this.renderer.list(body, ordered, start);
1900 | }
1901 | case 'list_item_start': {
1902 | body = '';
1903 | var loose = this.token.loose;
1904 | var checked = this.token.checked;
1905 | var task = this.token.task;
1906 |
1907 | if (this.token.task) {
1908 | body += this.renderer.checkbox(checked);
1909 | }
1910 |
1911 | while (this.next().type !== 'list_item_end') {
1912 | body += !loose && this.token.type === 'text'
1913 | ? this.parseText()
1914 | : this.tok();
1915 | }
1916 | return this.renderer.listitem(body, task, checked);
1917 | }
1918 | case 'html': {
1919 | // TODO parse inline content if parameter markdown=1
1920 | return this.renderer.html(this.token.text);
1921 | }
1922 | case 'paragraph': {
1923 | return this.renderer.paragraph(this.inline.output(this.token.text));
1924 | }
1925 | case 'text': {
1926 | return this.renderer.paragraph(this.parseText());
1927 | }
1928 | default: {
1929 | var errMsg = 'Token with "' + this.token.type + '" type was not found.';
1930 | if (this.options.silent) {
1931 | console.log(errMsg);
1932 | } else {
1933 | throw new Error(errMsg);
1934 | }
1935 | }
1936 | }
1937 | };
1938 |
1939 | /**
1940 | * Slugger generates header id
1941 | */
1942 |
1943 | function Slugger() {
1944 | this.seen = {};
1945 | }
1946 |
1947 | /**
1948 | * Convert string to unique id
1949 | */
1950 |
1951 | Slugger.prototype.slug = function(value) {
1952 | var slug = value
1953 | .toLowerCase()
1954 | .trim()
1955 | .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
1956 | .replace(/\s/g, '-');
1957 |
1958 | if (this.seen.hasOwnProperty(slug)) {
1959 | var originalSlug = slug;
1960 | do {
1961 | this.seen[originalSlug]++;
1962 | slug = originalSlug + '-' + this.seen[originalSlug];
1963 | } while (this.seen.hasOwnProperty(slug));
1964 | }
1965 | this.seen[slug] = 0;
1966 |
1967 | return slug;
1968 | };
1969 |
1970 | /**
1971 | * Helpers
1972 | */
1973 |
1974 | function escape(html, encode) {
1975 | if (encode) {
1976 | if (escape.escapeTest.test(html)) {
1977 | return html.replace(escape.escapeReplace, function(ch) { return escape.replacements[ch]; });
1978 | }
1979 | } else {
1980 | if (escape.escapeTestNoEncode.test(html)) {
1981 | return html.replace(escape.escapeReplaceNoEncode, function(ch) { return escape.replacements[ch]; });
1982 | }
1983 | }
1984 |
1985 | return html;
1986 | }
1987 |
1988 | escape.escapeTest = /[&<>"']/;
1989 | escape.escapeReplace = /[&<>"']/g;
1990 | escape.replacements = {
1991 | '&': '&',
1992 | '<': '<',
1993 | '>': '>',
1994 | '"': '"',
1995 | "'": '''
1996 | };
1997 |
1998 | escape.escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
1999 | escape.escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
2000 |
2001 | function unescape(html) {
2002 | // explicitly match decimal, hex, and named HTML entities
2003 | return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function(_, n) {
2004 | n = n.toLowerCase();
2005 | if (n === 'colon') { return ':'; }
2006 | if (n.charAt(0) === '#') {
2007 | return n.charAt(1) === 'x'
2008 | ? String.fromCharCode(parseInt(n.substring(2), 16))
2009 | : String.fromCharCode(+n.substring(1));
2010 | }
2011 | return '';
2012 | });
2013 | }
2014 |
2015 | function edit(regex, opt) {
2016 | regex = regex.source || regex;
2017 | opt = opt || '';
2018 | return {
2019 | replace: function(name, val) {
2020 | val = val.source || val;
2021 | val = val.replace(/(^|[^\[])\^/g, '$1');
2022 | regex = regex.replace(name, val);
2023 | return this;
2024 | },
2025 | getRegex: function() {
2026 | return new RegExp(regex, opt);
2027 | }
2028 | };
2029 | }
2030 |
2031 | function cleanUrl(sanitize, base, href) {
2032 | if (sanitize) {
2033 | try {
2034 | var prot = decodeURIComponent(unescape(href))
2035 | .replace(/[^\w:]/g, '')
2036 | .toLowerCase();
2037 | } catch (e) {
2038 | return null;
2039 | }
2040 | if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
2041 | return null;
2042 | }
2043 | }
2044 | if (base && !originIndependentUrl.test(href)) {
2045 | href = resolveUrl(base, href);
2046 | }
2047 | try {
2048 | href = encodeURI(href).replace(/%25/g, '%');
2049 | } catch (e) {
2050 | return null;
2051 | }
2052 | return href;
2053 | }
2054 |
2055 | function resolveUrl(base, href) {
2056 | if (!baseUrls[' ' + base]) {
2057 | // we can ignore everything in base after the last slash of its path component,
2058 | // but we might need to add _that_
2059 | // https://tools.ietf.org/html/rfc3986#section-3
2060 | if (/^[^:]+:\/*[^/]*$/.test(base)) {
2061 | baseUrls[' ' + base] = base + '/';
2062 | } else {
2063 | baseUrls[' ' + base] = rtrim(base, '/', true);
2064 | }
2065 | }
2066 | base = baseUrls[' ' + base];
2067 |
2068 | if (href.slice(0, 2) === '//') {
2069 | return base.replace(/:[\s\S]*/, ':') + href;
2070 | } else if (href.charAt(0) === '/') {
2071 | return base.replace(/(:\/*[^/]*)[\s\S]*/, '$1') + href;
2072 | } else {
2073 | return base + href;
2074 | }
2075 | }
2076 | var baseUrls = {};
2077 | var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
2078 |
2079 | function noop() {}
2080 | noop.exec = noop;
2081 |
2082 | function merge(obj) {
2083 | var arguments$1 = arguments;
2084 |
2085 | var i = 1,
2086 | target,
2087 | key;
2088 |
2089 | for (; i < arguments.length; i++) {
2090 | target = arguments$1[i];
2091 | for (key in target) {
2092 | if (Object.prototype.hasOwnProperty.call(target, key)) {
2093 | obj[key] = target[key];
2094 | }
2095 | }
2096 | }
2097 |
2098 | return obj;
2099 | }
2100 |
2101 | function splitCells(tableRow, count) {
2102 | // ensure that every cell-delimiting pipe has a space
2103 | // before it to distinguish it from an escaped pipe
2104 | var row = tableRow.replace(/\|/g, function(match, offset, str) {
2105 | var escaped = false,
2106 | curr = offset;
2107 | while (--curr >= 0 && str[curr] === '\\') { escaped = !escaped; }
2108 | if (escaped) {
2109 | // odd number of slashes means | is escaped
2110 | // so we leave it alone
2111 | return '|';
2112 | } else {
2113 | // add space before unescaped |
2114 | return ' |';
2115 | }
2116 | }),
2117 | cells = row.split(/ \|/),
2118 | i = 0;
2119 |
2120 | if (cells.length > count) {
2121 | cells.splice(count);
2122 | } else {
2123 | while (cells.length < count) { cells.push(''); }
2124 | }
2125 |
2126 | for (; i < cells.length; i++) {
2127 | // leading or trailing whitespace is ignored per the gfm spec
2128 | cells[i] = cells[i].trim().replace(/\\\|/g, '|');
2129 | }
2130 | return cells;
2131 | }
2132 |
2133 | // Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
2134 | // /c*$/ is vulnerable to REDOS.
2135 | // invert: Remove suffix of non-c chars instead. Default falsey.
2136 | function rtrim(str, c, invert) {
2137 | if (str.length === 0) {
2138 | return '';
2139 | }
2140 |
2141 | // Length of suffix matching the invert condition.
2142 | var suffLen = 0;
2143 |
2144 | // Step left until we fail to match the invert condition.
2145 | while (suffLen < str.length) {
2146 | var currChar = str.charAt(str.length - suffLen - 1);
2147 | if (currChar === c && !invert) {
2148 | suffLen++;
2149 | } else if (currChar !== c && invert) {
2150 | suffLen++;
2151 | } else {
2152 | break;
2153 | }
2154 | }
2155 |
2156 | return str.substr(0, str.length - suffLen);
2157 | }
2158 |
2159 | function findClosingBracket(str, b) {
2160 | if (str.indexOf(b[1]) === -1) {
2161 | return -1;
2162 | }
2163 | var level = 0;
2164 | for (var i = 0; i < str.length; i++) {
2165 | if (str[i] === '\\') {
2166 | i++;
2167 | } else if (str[i] === b[0]) {
2168 | level++;
2169 | } else if (str[i] === b[1]) {
2170 | level--;
2171 | if (level < 0) {
2172 | return i;
2173 | }
2174 | }
2175 | }
2176 | return -1;
2177 | }
2178 |
2179 | function checkSanitizeDeprecation(opt) {
2180 | if (opt && opt.sanitize && !opt.silent) {
2181 | console.warn('marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options');
2182 | }
2183 | }
2184 |
2185 | /**
2186 | * Marked
2187 | */
2188 |
2189 | function marked(src, opt, callback) {
2190 | // throw error in case of non string input
2191 | if (typeof src === 'undefined' || src === null) {
2192 | throw new Error('marked(): input parameter is undefined or null');
2193 | }
2194 | if (typeof src !== 'string') {
2195 | throw new Error('marked(): input parameter is of type '
2196 | + Object.prototype.toString.call(src) + ', string expected');
2197 | }
2198 |
2199 | if (callback || typeof opt === 'function') {
2200 | if (!callback) {
2201 | callback = opt;
2202 | opt = null;
2203 | }
2204 |
2205 | opt = merge({}, marked.defaults, opt || {});
2206 | checkSanitizeDeprecation(opt);
2207 |
2208 | var highlight = opt.highlight,
2209 | tokens,
2210 | pending,
2211 | i = 0;
2212 |
2213 | try {
2214 | tokens = Lexer.lex(src, opt);
2215 | } catch (e) {
2216 | return callback(e);
2217 | }
2218 |
2219 | pending = tokens.length;
2220 |
2221 | var done = function(err) {
2222 | if (err) {
2223 | opt.highlight = highlight;
2224 | return callback(err);
2225 | }
2226 |
2227 | var out;
2228 |
2229 | try {
2230 | out = Parser.parse(tokens, opt);
2231 | } catch (e) {
2232 | err = e;
2233 | }
2234 |
2235 | opt.highlight = highlight;
2236 |
2237 | return err
2238 | ? callback(err)
2239 | : callback(null, out);
2240 | };
2241 |
2242 | if (!highlight || highlight.length < 3) {
2243 | return done();
2244 | }
2245 |
2246 | delete opt.highlight;
2247 |
2248 | if (!pending) { return done(); }
2249 |
2250 | for (; i < tokens.length; i++) {
2251 | (function(token) {
2252 | if (token.type !== 'code') {
2253 | return --pending || done();
2254 | }
2255 | return highlight(token.text, token.lang, function(err, code) {
2256 | if (err) { return done(err); }
2257 | if (code == null || code === token.text) {
2258 | return --pending || done();
2259 | }
2260 | token.text = code;
2261 | token.escaped = true;
2262 | --pending || done();
2263 | });
2264 | })(tokens[i]);
2265 | }
2266 |
2267 | return;
2268 | }
2269 | try {
2270 | if (opt) { opt = merge({}, marked.defaults, opt); }
2271 | checkSanitizeDeprecation(opt);
2272 | return Parser.parse(Lexer.lex(src, opt), opt);
2273 | } catch (e) {
2274 | e.message += '\nPlease report this to https://github.com/markedjs/marked.';
2275 | if ((opt || marked.defaults).silent) {
2276 | return 'An error occurred:
'
2277 | + escape(e.message + '', true)
2278 | + '
';
2279 | }
2280 | throw e;
2281 | }
2282 | }
2283 |
2284 | /**
2285 | * Options
2286 | */
2287 |
2288 | marked.options =
2289 | marked.setOptions = function(opt) {
2290 | merge(marked.defaults, opt);
2291 | return marked;
2292 | };
2293 |
2294 | marked.getDefaults = function() {
2295 | return {
2296 | baseUrl: null,
2297 | breaks: false,
2298 | gfm: true,
2299 | headerIds: true,
2300 | headerPrefix: '',
2301 | highlight: null,
2302 | langPrefix: 'language-',
2303 | mangle: true,
2304 | pedantic: false,
2305 | renderer: new Renderer(),
2306 | sanitize: false,
2307 | sanitizer: null,
2308 | silent: false,
2309 | smartLists: false,
2310 | smartypants: false,
2311 | xhtml: false
2312 | };
2313 | };
2314 |
2315 | marked.defaults = marked.getDefaults();
2316 |
2317 | /**
2318 | * Expose
2319 | */
2320 |
2321 | marked.Parser = Parser;
2322 | marked.parser = Parser.parse;
2323 |
2324 | marked.Renderer = Renderer;
2325 | marked.TextRenderer = TextRenderer;
2326 |
2327 | marked.Lexer = Lexer;
2328 | marked.lexer = Lexer.lex;
2329 |
2330 | marked.InlineLexer = InlineLexer;
2331 | marked.inlineLexer = InlineLexer.output;
2332 |
2333 | marked.Slugger = Slugger;
2334 |
2335 | marked.parse = marked;
2336 |
2337 | {
2338 | module.exports = marked;
2339 | }
2340 | })();
2341 | });
2342 |
2343 | var prism = createCommonjsModule(function (module) {
2344 | /* **********************************************
2345 | Begin prism-core.js
2346 | ********************************************** */
2347 |
2348 | var _self = (typeof window !== 'undefined')
2349 | ? window // if in browser
2350 | : (
2351 | (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
2352 | ? self // if in worker
2353 | : {} // if in node js
2354 | );
2355 |
2356 | /**
2357 | * Prism: Lightweight, robust, elegant syntax highlighting
2358 | * MIT license http://www.opensource.org/licenses/mit-license.php/
2359 | * @author Lea Verou http://lea.verou.me
2360 | */
2361 |
2362 | var Prism = (function (_self){
2363 |
2364 | // Private helper vars
2365 | var lang = /\blang(?:uage)?-([\w-]+)\b/i;
2366 | var uniqueId = 0;
2367 |
2368 | var _ = {
2369 | manual: _self.Prism && _self.Prism.manual,
2370 | disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
2371 | util: {
2372 | encode: function (tokens) {
2373 | if (tokens instanceof Token) {
2374 | return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
2375 | } else if (Array.isArray(tokens)) {
2376 | return tokens.map(_.util.encode);
2377 | } else {
2378 | return tokens.replace(/&/g, '&').replace(/ text.length) {
2662 | // Something went terribly wrong, ABORT, ABORT!
2663 | return;
2664 | }
2665 |
2666 | if (str instanceof Token) {
2667 | continue;
2668 | }
2669 |
2670 | if (greedy && i != strarr.length - 1) {
2671 | pattern.lastIndex = pos;
2672 | var match = pattern.exec(text);
2673 | if (!match) {
2674 | break;
2675 | }
2676 |
2677 | var from = match.index + (lookbehind ? match[1].length : 0),
2678 | to = match.index + match[0].length,
2679 | k = i,
2680 | p = pos;
2681 |
2682 | for (var len = strarr.length; k < len && (p < to || (!strarr[k].type && !strarr[k - 1].greedy)); ++k) {
2683 | p += strarr[k].length;
2684 | // Move the index i to the element in strarr that is closest to from
2685 | if (from >= p) {
2686 | ++i;
2687 | pos = p;
2688 | }
2689 | }
2690 |
2691 | // If strarr[i] is a Token, then the match starts inside another Token, which is invalid
2692 | if (strarr[i] instanceof Token) {
2693 | continue;
2694 | }
2695 |
2696 | // Number of tokens to delete and replace with the new match
2697 | delNum = k - i;
2698 | str = text.slice(pos, p);
2699 | match.index -= pos;
2700 | } else {
2701 | pattern.lastIndex = 0;
2702 |
2703 | var match = pattern.exec(str),
2704 | delNum = 1;
2705 | }
2706 |
2707 | if (!match) {
2708 | if (oneshot) {
2709 | break;
2710 | }
2711 |
2712 | continue;
2713 | }
2714 |
2715 | if(lookbehind) {
2716 | lookbehindLength = match[1] ? match[1].length : 0;
2717 | }
2718 |
2719 | var from = match.index + lookbehindLength,
2720 | match = match[0].slice(lookbehindLength),
2721 | to = from + match.length,
2722 | before = str.slice(0, from),
2723 | after = str.slice(to);
2724 |
2725 | var args = [i, delNum];
2726 |
2727 | if (before) {
2728 | ++i;
2729 | pos += before.length;
2730 | args.push(before);
2731 | }
2732 |
2733 | var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy);
2734 |
2735 | args.push(wrapped);
2736 |
2737 | if (after) {
2738 | args.push(after);
2739 | }
2740 |
2741 | Array.prototype.splice.apply(strarr, args);
2742 |
2743 | if (delNum != 1)
2744 | { _.matchGrammar(text, strarr, grammar, i, pos, true, token); }
2745 |
2746 | if (oneshot)
2747 | { break; }
2748 | }
2749 | }
2750 | }
2751 | },
2752 |
2753 | tokenize: function(text, grammar) {
2754 | var strarr = [text];
2755 |
2756 | var rest = grammar.rest;
2757 |
2758 | if (rest) {
2759 | for (var token in rest) {
2760 | grammar[token] = rest[token];
2761 | }
2762 |
2763 | delete grammar.rest;
2764 | }
2765 |
2766 | _.matchGrammar(text, strarr, grammar, 0, 0, false);
2767 |
2768 | return strarr;
2769 | },
2770 |
2771 | hooks: {
2772 | all: {},
2773 |
2774 | add: function (name, callback) {
2775 | var hooks = _.hooks.all;
2776 |
2777 | hooks[name] = hooks[name] || [];
2778 |
2779 | hooks[name].push(callback);
2780 | },
2781 |
2782 | run: function (name, env) {
2783 | var callbacks = _.hooks.all[name];
2784 |
2785 | if (!callbacks || !callbacks.length) {
2786 | return;
2787 | }
2788 |
2789 | for (var i=0, callback; callback = callbacks[i++];) {
2790 | callback(env);
2791 | }
2792 | }
2793 | },
2794 |
2795 | Token: Token
2796 | };
2797 |
2798 | _self.Prism = _;
2799 |
2800 | function Token(type, content, alias, matchedStr, greedy) {
2801 | this.type = type;
2802 | this.content = content;
2803 | this.alias = alias;
2804 | // Copy of the full string this token was created from
2805 | this.length = (matchedStr || "").length|0;
2806 | this.greedy = !!greedy;
2807 | }
2808 |
2809 | Token.stringify = function(o, language) {
2810 | if (typeof o == 'string') {
2811 | return o;
2812 | }
2813 |
2814 | if (Array.isArray(o)) {
2815 | return o.map(function(element) {
2816 | return Token.stringify(element, language);
2817 | }).join('');
2818 | }
2819 |
2820 | var env = {
2821 | type: o.type,
2822 | content: Token.stringify(o.content, language),
2823 | tag: 'span',
2824 | classes: ['token', o.type],
2825 | attributes: {},
2826 | language: language
2827 | };
2828 |
2829 | if (o.alias) {
2830 | var aliases = Array.isArray(o.alias) ? o.alias : [o.alias];
2831 | Array.prototype.push.apply(env.classes, aliases);
2832 | }
2833 |
2834 | _.hooks.run('wrap', env);
2835 |
2836 | var attributes = Object.keys(env.attributes).map(function(name) {
2837 | return name + '="' + (env.attributes[name] || '').replace(/"/g, '"') + '"';
2838 | }).join(' ');
2839 |
2840 | return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '' + env.tag + '>';
2841 | };
2842 |
2843 | if (!_self.document) {
2844 | if (!_self.addEventListener) {
2845 | // in Node.js
2846 | return _;
2847 | }
2848 |
2849 | if (!_.disableWorkerMessageHandler) {
2850 | // In worker
2851 | _self.addEventListener('message', function (evt) {
2852 | var message = JSON.parse(evt.data),
2853 | lang = message.language,
2854 | code = message.code,
2855 | immediateClose = message.immediateClose;
2856 |
2857 | _self.postMessage(_.highlight(code, _.languages[lang], lang));
2858 | if (immediateClose) {
2859 | _self.close();
2860 | }
2861 | }, false);
2862 | }
2863 |
2864 | return _;
2865 | }
2866 |
2867 | //Get current script and highlight
2868 | var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop();
2869 |
2870 | if (script) {
2871 | _.filename = script.src;
2872 |
2873 | if (!_.manual && !script.hasAttribute('data-manual')) {
2874 | if(document.readyState !== "loading") {
2875 | if (window.requestAnimationFrame) {
2876 | window.requestAnimationFrame(_.highlightAll);
2877 | } else {
2878 | window.setTimeout(_.highlightAll, 16);
2879 | }
2880 | }
2881 | else {
2882 | document.addEventListener('DOMContentLoaded', _.highlightAll);
2883 | }
2884 | }
2885 | }
2886 |
2887 | return _;
2888 |
2889 | })(_self);
2890 |
2891 | if ( module.exports) {
2892 | module.exports = Prism;
2893 | }
2894 |
2895 | // hack for components to work correctly in node.js
2896 | if (typeof commonjsGlobal !== 'undefined') {
2897 | commonjsGlobal.Prism = Prism;
2898 | }
2899 |
2900 |
2901 | /* **********************************************
2902 | Begin prism-markup.js
2903 | ********************************************** */
2904 |
2905 | Prism.languages.markup = {
2906 | 'comment': //,
2907 | 'prolog': /<\?[\s\S]+?\?>/,
2908 | 'doctype': //i,
2909 | 'cdata': //i,
2910 | 'tag': {
2911 | pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i,
2912 | greedy: true,
2913 | inside: {
2914 | 'tag': {
2915 | pattern: /^<\/?[^\s>\/]+/i,
2916 | inside: {
2917 | 'punctuation': /^<\/?/,
2918 | 'namespace': /^[^\s>\/:]+:/
2919 | }
2920 | },
2921 | 'attr-value': {
2922 | pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i,
2923 | inside: {
2924 | 'punctuation': [
2925 | /^=/,
2926 | {
2927 | pattern: /^(\s*)["']|["']$/,
2928 | lookbehind: true
2929 | }
2930 | ]
2931 | }
2932 | },
2933 | 'punctuation': /\/?>/,
2934 | 'attr-name': {
2935 | pattern: /[^\s>\/]+/,
2936 | inside: {
2937 | 'namespace': /^[^\s>\/:]+:/
2938 | }
2939 | }
2940 |
2941 | }
2942 | },
2943 | 'entity': /?[\da-z]{1,8};/i
2944 | };
2945 |
2946 | Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
2947 | Prism.languages.markup['entity'];
2948 |
2949 | // Plugin to make entity title show the real entity, idea by Roman Komarov
2950 | Prism.hooks.add('wrap', function(env) {
2951 |
2952 | if (env.type === 'entity') {
2953 | env.attributes['title'] = env.content.replace(/&/, '&');
2954 | }
2955 | });
2956 |
2957 | Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
2958 | /**
2959 | * Adds an inlined language to markup.
2960 | *
2961 | * An example of an inlined language is CSS with `