Compare commits

..

1 commit

Author SHA1 Message Date
Anton Wilhelm
89389e786a
Remove IE10 from supported browsers 2019-02-26 08:27:59 +01:00
61 changed files with 7168 additions and 603 deletions

2
.github/ISSUE_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,2 @@
<!-- Love docsify? Please consider supporting our collective:
👉 https://opencollective.com/docsify/donate -->

View file

@ -1,38 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
---
<!-- Please don't delete this template or we'll close your issue -->
<!-- Please use English language -->
<!-- Before creating an issue please make sure you are using the latest version of Docsify. -->
<!-- Please ask questions on StackOverflow: https://stackoverflow.com/questions/ask?tags=docsify -->
## Bug Report
#### Steps to reproduce
#### What is current behaviour
#### What is the expected behaviour
#### Other relevant information
<!-- (Update "[ ]" to "[x]" to check a box) -->
- [ ] Bug does still occur when all/other plugins are disabled?
- Your OS:
- Node.js version:
- npm/yarn version:
- Browser version:
- Docsify version:
- Docsify plugins:
<!-- Love docsify? Please consider supporting our collective:
👉 https://opencollective.com/docsify/donate -->

View file

@ -1,25 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
---
<!-- Please don't delete this template or we'll close your issue -->
<!-- Please use English language -->
<!-- Before creating an issue please make sure you are using the latest version of Docsify. -->
<!-- Please ask questions on StackOverflow 👉 https://stackoverflow.com/questions/ask?tags=docsify -->
## Feature request
#### What problem does this feature solve?
#### What does the proposed API look like?
#### How should this be implemented in your opinion?
#### Are you willing to work on this yourself?

View file

@ -1,54 +1,5 @@
<!-- Please use English language -->
<!-- Please don't delete this template -->
<!-- PULL REQUEST TEMPLATE -->
<!-- (Update "[ ]" to "[x]" to check a box) -->
**Summary**
**What kind of change does this PR introduce?** (check at least one)
- [ ] Bugfix
- [ ] Feature
- [ ] Code style update
- [ ] Refactor
- [ ] Docs
- [ ] Build-related changes
- [ ] Other, please describe:
If changing the UI of default theme, please provide the **before/after** screenshot:
**Does this PR introduce a breaking change?** (check one)
- [ ] Yes
- [ ] No
If yes, please describe the impact and migration path for existing applications:
**The PR fulfills these requirements:**
- [ ] When resolving a specific issue, it's referenced in the PR's title (e.g. `fix #xxx[,#xxx]`, where "xxx" is the issue number)
You have tested in the following browsers: (Providing a detailed version will be better.)
- [ ] Chrome
- [ ] Firefox
- [ ] Safari
- [ ] Edge
- [ ] IE
If adding a **new feature**, the PR's description includes:
- [ ] A convincing reason for adding this feature
- [ ] Related documents have been updated
- [ ] Related tests have been updated
To avoid wasting your time, it's best to open a **feature request issue** first and wait for approval before working on it.
**Other information:**
---
Please makes sure these boxes are checked before submitting your PR, thank you!
* [ ] Make sure you are merging your commits to `master` branch.
* [ ] Add some descriptions and refer relative issues for you PR.
* [ ] DO NOT include files inside `lib` directory.

10
.gitignore vendored
View file

@ -1,9 +1,7 @@
*.log
.DS_Store
.idea
/themes/*
!.gitkeep
node_modules
themes/
lib/
# exceptions
!.gitkeep
/lib/
.idea

View file

@ -1,23 +1,3 @@
<a name="4.9.4"></a>
## [4.9.4](https://github.com/docsifyjs/docsify/compare/v4.9.2...v4.9.4) (2019-05-05)
<a name="4.9.2"></a>
## [4.9.2](https://github.com/docsifyjs/docsify/compare/v4.9.1...v4.9.2) (2019-04-21)
### Bug Fixes
* re-render gitalk when router changed ([11ea1f8](https://github.com/docsifyjs/docsify/commit/11ea1f8))
### Features
* allows relative path, fixed [#590](https://github.com/docsifyjs/docsify/issues/590) ([31654f1](https://github.com/docsifyjs/docsify/commit/31654f1))
<a name="4.9.1"></a>
## [4.9.1](https://github.com/docsifyjs/docsify/compare/v4.9.0...v4.9.1) (2019-02-21)

View file

@ -27,7 +27,6 @@
## Links
- [`develop` branch preview](https://docsifyjs.netlify.com/)
- [Documentation](https://docsify.js.org)
- [CLI](https://github.com/docsifyjs/docsify-cli)
- CDN: [UNPKG](https://unpkg.com/docsify/) | [jsDelivr](https://cdn.jsdelivr.net/npm/docsify/) | [cdnjs](https://cdnjs.com/libraries/docsify)
@ -55,7 +54,7 @@ Look at [this tutorial](https://docsify.js.org/#/quickstart)
These projects are using docsify to generate their sites. Pull requests welcome :blush:
Move to [awesome-docsify](https://github.com/docsifyjs/awesome-docsify#showcase)
Move to [awesome-docsify](https://github.com/docsifyjs/awesome-docsify)
## Similar projects

View file

@ -55,7 +55,6 @@ const buildAllPlugin = function () {
var plugins = [
{name: 'search', input: 'search/index.js'},
{name: 'ga', input: 'ga.js'},
{name: 'matomo', input: 'matomo.js'},
{name: 'emoji', input: 'emoji.js'},
{name: 'external-script', input: 'external-script.js'},
{name: 'front-matter', input: 'front-matter/index.js'},

1
build/release.sh Executable file → Normal file
View file

@ -29,6 +29,7 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then
# commit
git add -A
git add -f lib/ -A
git commit -m "[build] $VERSION $RELEASE_TAG"
npm --no-git-tag-version version $VERSION --message "[release] $VERSION $RELEASE_TAG"

View file

@ -16,12 +16,12 @@ See the [Quick start](quickstart.md) guide for more details.
- Multiple themes
- Useful plugin API
- Emoji support
- Compatible with IE11
- Compatible with IE10+
- Support server-side rendering ([example](https://github.com/docsifyjs/docsify-ssr-demo))
## Examples
Check out the [Showcase](https://github.com/docsifyjs/awesome-docsify#showcase) to see docsify in use.
Check out the [Showcase](https://github.com/docsifyjs/docsify/#showcase) to see docsify in use.
## Donate

View file

@ -1,6 +1,6 @@
![logo](_media/icon.svg)
# docsify <small>4.9.4</small>
# docsify <small>4.9.1</small>
> A magical documentation site generator.

View file

@ -150,46 +150,6 @@ window.$docsify = {
};
```
## relativePath
- Type: `Boolean`
- Default: `false`
If **true** links are relative to the current context.
For example, the directory structure is as follows:
```text
.
└── docs
├── README.md
├── guide.md
└── zh-cn
├── README.md
├── guide.md
└── config
└── example.md
```
With relative path **enabled** and current URL `http://domain.com/zh-cn/README`, given links will resolve to:
```text
guide.md => http://domain.com/zh-cn/guide
config/example.md => http://domain.com/zh-cn/config/example
../README.md => http://domain.com/README
/README.md => http://domain.com/README
```
```js
window.$docsify = {
// Relative path enabled
relativePath: true,
// Relative path disabled (default value)
relativePath: false
};
```
## coverpage
- Type: `Boolean|String|String[]|Object`

View file

@ -15,7 +15,7 @@ It is recommended that you save your files to the `./docs` subfolder of the `mas
![github pages](_images/deploy-github-pages.png)
!> You can also save files in the root directory and select `master branch`.
You'll need to place a `.nojekyll` file in the deploy location (such as `/docs` or the gh-pages branch)
You'll need to place a `.nojekyll` file in the deploy location (such as `/docs` or the gh-pages branch
## GitLab Pages
@ -87,45 +87,3 @@ When using the HTML5 router, you need to set up redirect rules that redirect all
```sh
/* /index.html 200
```
## AWS Amplify
1. Set the routerMode in the Docsify project `index.html` to *history* mode.
```html
<script>
window.$docsify = {
loadSidebar: true,
routerMode: 'history'
}
</script>
```
2. Login to your [AWS Console](https://aws.amazon.com).
3. Go to the [AWS Amplify Dashboard](https://aws.amazon.com/amplify).
4. Choose the **Deploy** route to setup your project.
5. When prompted, keep the build settings empty if you're serving your docs within the root directory. If you're serving your docs from a different directory, customise your amplify.yml
```yml
version: 0.1
frontend:
phases:
build:
commands:
- echo "Nothing to build"
artifacts:
baseDirectory: /docs
files:
- '**/*'
cache:
paths: []
```
6. Add the following Redirect rules in their displayed order.
| Source address | Target address | Type |
|----------------|----------------|---------------|
| /<*>.md | /<*>.md | 200 (Rewrite) |
| /<*> | /index.html | 200 (Rewrite) |

View file

@ -44,10 +44,6 @@
maxLevel: 4,
subMaxLevel: 2,
ga: 'UA-106147152-1',
matomo: {
host: '//matomo.thunderwave.de',
id: 6
},
name: 'docsify',
search: {
noData: {
@ -88,7 +84,6 @@
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
<script src="//unpkg.com/docsify/lib/plugins/ga.min.js"></script>
<script src="//unpkg.com/docsify/lib/plugins/matomo.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-markdown.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-nginx.min.js"></script>

View file

@ -72,16 +72,6 @@ You can specify `alias` to avoid unnecessary fallback.
!> You can create a `README.md` file in a subdirectory to use it as the landing page for the route.
## Set Page Titles from Sidebar Selection
A page's `title` tag is generated from the _selected_ sidebar item name. For better SEO, you can customize the title by specifying a string after the filename.
```markdown
<!-- docs/_sidebar.md -->
* [Home](/)
* [Guide](guide.md "The greatest guide in the world")
```
## Table of Contents
Once you've created `_sidebar.md`, the sidebar content is automatically generated based on the headers in the markdown files.

View file

@ -79,7 +79,7 @@ window.$docsify = {
function(hook, vm) {
hook.beforeEach(function(html) {
var url =
'https://github.com/docsifyjs/docsify/blob/master/docs/' +
'https://github.com/docsifyjs/docsify/blob/master/docs' +
vm.route.file;
var editHtml = '[📝 EDIT DOCUMENT](' + url + ')\n';

View file

@ -21,64 +21,48 @@
<script>
window.$docsify = {
alias: {
'.*?/awesome': 'https://raw.githubusercontent.com/docsifyjs/awesome-docsify/master/README.md',
'.*?/changelog': 'https://raw.githubusercontent.com/docsifyjs/docsify/master/CHANGELOG.md',
'.*?/changelog': 'https://raw.githubusercontent.com/docsifyjs/docsify/master/CHANGELOG',
'/.*/_navbar.md': '/_navbar.md',
'/zh-cn/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-zh/master/$1',
'/de-de/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-de/master/$1',
'/ru/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-ru/master/$1',
'/es/(.*)': 'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1'
},
notFoundPage: '_404.html',
auto2top: true,
basePath: '/docs/',
coverpage: true,
executeScript: true,
loadSidebar: true,
loadNavbar: true,
mergeNavbar: true,
maxLevel: 4,
subMaxLevel: 2,
loadSidebar: true,
coverpage: true,
name: 'docsify',
search: {
noData: {
'/de-de/': 'Keine Ergebnisse!',
'/zh-cn/': '没有结果!',
'/': 'No results!'
},
paths: 'auto',
placeholder: {
'/de-de/': 'Suche',
'/zh-cn/': '搜索',
'/': 'Search'
}
},
subMaxLevel: 2,
mergeNavbar: true,
formatUpdated: '{MM}/{DD} {HH}:{mm}',
plugins: [
function (hook, vm) {
hook.beforeEach(function (html) {
var url
if (/githubusercontent\.com/.test(vm.route.file)) {
url = vm.route.file
.replace('raw.githubusercontent.com', 'github.com')
.replace(/\/master/, '/blob/master')
} else {
url = 'https://github.com/docsifyjs/docsify/blob/master/docs/' + vm.route.file
url = 'https://github.com/docsifyjs/docsify/blob/master/' + vm.route.file
}
var editHtml = '[:memo: Edit Document](' + url + ')\n'
return editHtml
+ html
+ '\n\n----\n\n'
+ '<a href="https://docsify.js.org" target="_blank" style="color: inherit; font-weight: normal; text-decoration: none;">Powered by docsify</a>'
+ 'Last modified {docsify-updated} '
+ editHtml
})
},
}
]
}
</script>
<script src="/lib/docsify.js"></script>
<script src="/lib/plugins/search.js"></script>
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-markdown.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-nginx.min.js"></script>
</body>
</html>

5091
lib/docsify.js Normal file

File diff suppressed because it is too large Load diff

1
lib/docsify.min.js vendored Normal file

File diff suppressed because one or more lines are too long

54
lib/plugins/disqus.js Normal file
View file

@ -0,0 +1,54 @@
(function () {
var fixedPath = location.href.replace('/-/', '/#/');
if (fixedPath !== location.href) {
location.href = fixedPath;
}
function install(hook, vm) {
var dom = Docsify.dom;
var disqus = vm.config.disqus;
if (!disqus) {
throw Error('$docsify.disqus is required')
}
hook.init(function (_) {
var script = dom.create('script');
script.async = true;
script.src = "https://" + disqus + ".disqus.com/embed.js";
script.setAttribute('data-timestamp', Number(new Date()));
dom.appendTo(dom.body, script);
});
hook.mounted(function (_) {
var div = dom.create('div');
div.id = 'disqus_thread';
var main = dom.getNode('#main');
div.style = "width: " + (main.clientWidth) + "px; margin: 0 auto 20px;";
dom.appendTo(dom.find('.content'), div);
// eslint-disable-next-line
window.disqus_config = function() {
this.page.url = location.origin + '/-' + vm.route.path;
this.page.identifier = vm.route.path;
this.page.title = document.title;
};
});
hook.doneEach(function (_) {
if (typeof window.DISQUS !== 'undefined') {
window.DISQUS.reset({
reload: true,
config: function () {
this.page.url = location.origin + '/-' + vm.route.path;
this.page.identifier = vm.route.path;
this.page.title = document.title;
}
});
}
});
}
$docsify.plugins = [].concat(install, $docsify.plugins);
}());

1
lib/plugins/disqus.min.js vendored Normal file
View file

@ -0,0 +1 @@
!function(){var i=location.href.replace("/-/","/#/");i!==location.href&&(location.href=i),$docsify.plugins=[].concat(function(i,o){var n=Docsify.dom,e=o.config.disqus;if(!e)throw Error("$docsify.disqus is required");i.init(function(i){var t=n.create("script");t.async=!0,t.src="https://"+e+".disqus.com/embed.js",t.setAttribute("data-timestamp",Number(new Date)),n.appendTo(n.body,t)}),i.mounted(function(i){var t=n.create("div");t.id="disqus_thread";var e=n.getNode("#main");t.style="width: "+e.clientWidth+"px; margin: 0 auto 20px;",n.appendTo(n.find(".content"),t),window.disqus_config=function(){this.page.url=location.origin+"/-"+o.route.path,this.page.identifier=o.route.path,this.page.title=document.title}}),i.doneEach(function(i){void 0!==window.DISQUS&&window.DISQUS.reset({reload:!0,config:function(){this.page.url=location.origin+"/-"+o.route.path,this.page.identifier=o.route.path,this.page.title=document.title}})})},$docsify.plugins)}();

903
lib/plugins/emoji.js Normal file
View file

@ -0,0 +1,903 @@
(function () {
var AllGithubEmoji = [
'+1',
'100',
'1234',
'8ball',
'a',
'ab',
'abc',
'abcd',
'accept',
'aerial_tramway',
'airplane',
'alarm_clock',
'alien',
'ambulance',
'anchor',
'angel',
'anger',
'angry',
'anguished',
'ant',
'apple',
'aquarius',
'aries',
'arrow_backward',
'arrow_double_down',
'arrow_double_up',
'arrow_down',
'arrow_down_small',
'arrow_forward',
'arrow_heading_down',
'arrow_heading_up',
'arrow_left',
'arrow_lower_left',
'arrow_lower_right',
'arrow_right',
'arrow_right_hook',
'arrow_up',
'arrow_up_down',
'arrow_up_small',
'arrow_upper_left',
'arrow_upper_right',
'arrows_clockwise',
'arrows_counterclockwise',
'art',
'articulated_lorry',
'astonished',
'athletic_shoe',
'atm',
'b',
'baby',
'baby_bottle',
'baby_chick',
'baby_symbol',
'back',
'baggage_claim',
'balloon',
'ballot_box_with_check',
'bamboo',
'banana',
'bangbang',
'bank',
'bar_chart',
'barber',
'baseball',
'basketball',
'bath',
'bathtub',
'battery',
'bear',
'bee',
'beer',
'beers',
'beetle',
'beginner',
'bell',
'bento',
'bicyclist',
'bike',
'bikini',
'bird',
'birthday',
'black_circle',
'black_joker',
'black_large_square',
'black_medium_small_square',
'black_medium_square',
'black_nib',
'black_small_square',
'black_square_button',
'blossom',
'blowfish',
'blue_book',
'blue_car',
'blue_heart',
'blush',
'boar',
'boat',
'bomb',
'book',
'bookmark',
'bookmark_tabs',
'books',
'boom',
'boot',
'bouquet',
'bow',
'bowling',
'bowtie',
'boy',
'bread',
'bride_with_veil',
'bridge_at_night',
'briefcase',
'broken_heart',
'bug',
'bulb',
'bullettrain_front',
'bullettrain_side',
'bus',
'busstop',
'bust_in_silhouette',
'busts_in_silhouette',
'cactus',
'cake',
'calendar',
'calling',
'camel',
'camera',
'cancer',
'candy',
'capital_abcd',
'capricorn',
'car',
'card_index',
'carousel_horse',
'cat',
'cat2',
'cd',
'chart',
'chart_with_downwards_trend',
'chart_with_upwards_trend',
'checkered_flag',
'cherries',
'cherry_blossom',
'chestnut',
'chicken',
'children_crossing',
'chocolate_bar',
'christmas_tree',
'church',
'cinema',
'circus_tent',
'city_sunrise',
'city_sunset',
'cl',
'clap',
'clapper',
'clipboard',
'clock1',
'clock10',
'clock1030',
'clock11',
'clock1130',
'clock12',
'clock1230',
'clock130',
'clock2',
'clock230',
'clock3',
'clock330',
'clock4',
'clock430',
'clock5',
'clock530',
'clock6',
'clock630',
'clock7',
'clock730',
'clock8',
'clock830',
'clock9',
'clock930',
'closed_book',
'closed_lock_with_key',
'closed_umbrella',
'cloud',
'clubs',
'cn',
'cocktail',
'coffee',
'cold_sweat',
'collision',
'computer',
'confetti_ball',
'confounded',
'confused',
'congratulations',
'construction',
'construction_worker',
'convenience_store',
'cookie',
'cool',
'cop',
'copyright',
'corn',
'couple',
'couple_with_heart',
'couplekiss',
'cow',
'cow2',
'credit_card',
'crescent_moon',
'crocodile',
'crossed_flags',
'crown',
'cry',
'crying_cat_face',
'crystal_ball',
'cupid',
'curly_loop',
'currency_exchange',
'curry',
'custard',
'customs',
'cyclone',
'dancer',
'dancers',
'dango',
'dart',
'dash',
'date',
'de',
'deciduous_tree',
'department_store',
'diamond_shape_with_a_dot_inside',
'diamonds',
'disappointed',
'disappointed_relieved',
'dizzy',
'dizzy_face',
'do_not_litter',
'dog',
'dog2',
'dollar',
'dolls',
'dolphin',
'door',
'doughnut',
'dragon',
'dragon_face',
'dress',
'dromedary_camel',
'droplet',
'dvd',
'e-mail',
'ear',
'ear_of_rice',
'earth_africa',
'earth_americas',
'earth_asia',
'egg',
'eggplant',
'eight',
'eight_pointed_black_star',
'eight_spoked_asterisk',
'electric_plug',
'elephant',
'email',
'end',
'envelope',
'envelope_with_arrow',
'es',
'euro',
'european_castle',
'european_post_office',
'evergreen_tree',
'exclamation',
'expressionless',
'eyeglasses',
'eyes',
'facepunch',
'factory',
'fallen_leaf',
'family',
'fast_forward',
'fax',
'fearful',
'feelsgood',
'feet',
'ferris_wheel',
'file_folder',
'finnadie',
'fire',
'fire_engine',
'fireworks',
'first_quarter_moon',
'first_quarter_moon_with_face',
'fish',
'fish_cake',
'fishing_pole_and_fish',
'fist',
'five',
'flags',
'flashlight',
'flipper',
'floppy_disk',
'flower_playing_cards',
'flushed',
'foggy',
'football',
'footprints',
'fork_and_knife',
'fountain',
'four',
'four_leaf_clover',
'fr',
'free',
'fried_shrimp',
'fries',
'frog',
'frowning',
'fu',
'fuelpump',
'full_moon',
'full_moon_with_face',
'game_die',
'gb',
'gem',
'gemini',
'ghost',
'gift',
'gift_heart',
'girl',
'globe_with_meridians',
'goat',
'goberserk',
'godmode',
'golf',
'grapes',
'green_apple',
'green_book',
'green_heart',
'grey_exclamation',
'grey_question',
'grimacing',
'grin',
'grinning',
'guardsman',
'guitar',
'gun',
'haircut',
'hamburger',
'hammer',
'hamster',
'hand',
'handbag',
'hankey',
'hash',
'hatched_chick',
'hatching_chick',
'headphones',
'hear_no_evil',
'heart',
'heart_decoration',
'heart_eyes',
'heart_eyes_cat',
'heartbeat',
'heartpulse',
'hearts',
'heavy_check_mark',
'heavy_division_sign',
'heavy_dollar_sign',
'heavy_exclamation_mark',
'heavy_minus_sign',
'heavy_multiplication_x',
'heavy_plus_sign',
'helicopter',
'herb',
'hibiscus',
'high_brightness',
'high_heel',
'hocho',
'honey_pot',
'honeybee',
'horse',
'horse_racing',
'hospital',
'hotel',
'hotsprings',
'hourglass',
'hourglass_flowing_sand',
'house',
'house_with_garden',
'hurtrealbad',
'hushed',
'ice_cream',
'icecream',
'id',
'ideograph_advantage',
'imp',
'inbox_tray',
'incoming_envelope',
'information_desk_person',
'information_source',
'innocent',
'interrobang',
'iphone',
'it',
'izakaya_lantern',
'jack_o_lantern',
'japan',
'japanese_castle',
'japanese_goblin',
'japanese_ogre',
'jeans',
'joy',
'joy_cat',
'jp',
'key',
'keycap_ten',
'kimono',
'kiss',
'kissing',
'kissing_cat',
'kissing_closed_eyes',
'kissing_heart',
'kissing_smiling_eyes',
'koala',
'koko',
'kr',
'lantern',
'large_blue_circle',
'large_blue_diamond',
'large_orange_diamond',
'last_quarter_moon',
'last_quarter_moon_with_face',
'laughing',
'leaves',
'ledger',
'left_luggage',
'left_right_arrow',
'leftwards_arrow_with_hook',
'lemon',
'leo',
'leopard',
'libra',
'light_rail',
'link',
'lips',
'lipstick',
'lock',
'lock_with_ink_pen',
'lollipop',
'loop',
'loud_sound',
'loudspeaker',
'love_hotel',
'love_letter',
'low_brightness',
'm',
'mag',
'mag_right',
'mahjong',
'mailbox',
'mailbox_closed',
'mailbox_with_mail',
'mailbox_with_no_mail',
'man',
'man_with_gua_pi_mao',
'man_with_turban',
'mans_shoe',
'maple_leaf',
'mask',
'massage',
'meat_on_bone',
'mega',
'melon',
'memo',
'mens',
'metal',
'metro',
'microphone',
'microscope',
'milky_way',
'minibus',
'minidisc',
'mobile_phone_off',
'money_with_wings',
'moneybag',
'monkey',
'monkey_face',
'monorail',
'moon',
'mortar_board',
'mount_fuji',
'mountain_bicyclist',
'mountain_cableway',
'mountain_railway',
'mouse',
'mouse2',
'movie_camera',
'moyai',
'muscle',
'mushroom',
'musical_keyboard',
'musical_note',
'musical_score',
'mute',
'nail_care',
'name_badge',
'neckbeard',
'necktie',
'negative_squared_cross_mark',
'neutral_face',
'new',
'new_moon',
'new_moon_with_face',
'newspaper',
'ng',
'night_with_stars',
'nine',
'no_bell',
'no_bicycles',
'no_entry',
'no_entry_sign',
'no_good',
'no_mobile_phones',
'no_mouth',
'no_pedestrians',
'no_smoking',
'non-potable_water',
'nose',
'notebook',
'notebook_with_decorative_cover',
'notes',
'nut_and_bolt',
'o',
'o2',
'ocean',
'octocat',
'octopus',
'oden',
'office',
'ok',
'ok_hand',
'ok_woman',
'older_man',
'older_woman',
'on',
'oncoming_automobile',
'oncoming_bus',
'oncoming_police_car',
'oncoming_taxi',
'one',
'open_book',
'open_file_folder',
'open_hands',
'open_mouth',
'ophiuchus',
'orange_book',
'outbox_tray',
'ox',
'package',
'page_facing_up',
'page_with_curl',
'pager',
'palm_tree',
'panda_face',
'paperclip',
'parking',
'part_alternation_mark',
'partly_sunny',
'passport_control',
'paw_prints',
'peach',
'pear',
'pencil',
'pencil2',
'penguin',
'pensive',
'performing_arts',
'persevere',
'person_frowning',
'person_with_blond_hair',
'person_with_pouting_face',
'phone',
'pig',
'pig2',
'pig_nose',
'pill',
'pineapple',
'pisces',
'pizza',
'point_down',
'point_left',
'point_right',
'point_up',
'point_up_2',
'police_car',
'poodle',
'poop',
'post_office',
'postal_horn',
'postbox',
'potable_water',
'pouch',
'poultry_leg',
'pound',
'pouting_cat',
'pray',
'princess',
'punch',
'purple_heart',
'purse',
'pushpin',
'put_litter_in_its_place',
'question',
'rabbit',
'rabbit2',
'racehorse',
'radio',
'radio_button',
'rage',
'rage1',
'rage2',
'rage3',
'rage4',
'railway_car',
'rainbow',
'raised_hand',
'raised_hands',
'raising_hand',
'ram',
'ramen',
'rat',
'recycle',
'red_car',
'red_circle',
'registered',
'relaxed',
'relieved',
'repeat',
'repeat_one',
'restroom',
'revolving_hearts',
'rewind',
'ribbon',
'rice',
'rice_ball',
'rice_cracker',
'rice_scene',
'ring',
'rocket',
'roller_coaster',
'rooster',
'rose',
'rotating_light',
'round_pushpin',
'rowboat',
'ru',
'rugby_football',
'runner',
'running',
'running_shirt_with_sash',
'sa',
'sagittarius',
'sailboat',
'sake',
'sandal',
'santa',
'satellite',
'satisfied',
'saxophone',
'school',
'school_satchel',
'scissors',
'scorpius',
'scream',
'scream_cat',
'scroll',
'seat',
'secret',
'see_no_evil',
'seedling',
'seven',
'shaved_ice',
'sheep',
'shell',
'ship',
'shipit',
'shirt',
'shit',
'shoe',
'shower',
'signal_strength',
'six',
'six_pointed_star',
'ski',
'skull',
'sleeping',
'sleepy',
'slot_machine',
'small_blue_diamond',
'small_orange_diamond',
'small_red_triangle',
'small_red_triangle_down',
'smile',
'smile_cat',
'smiley',
'smiley_cat',
'smiling_imp',
'smirk',
'smirk_cat',
'smoking',
'snail',
'snake',
'snowboarder',
'snowflake',
'snowman',
'sob',
'soccer',
'soon',
'sos',
'sound',
'space_invader',
'spades',
'spaghetti',
'sparkle',
'sparkler',
'sparkles',
'sparkling_heart',
'speak_no_evil',
'speaker',
'speech_balloon',
'speedboat',
'squirrel',
'star',
'star2',
'stars',
'station',
'statue_of_liberty',
'steam_locomotive',
'stew',
'straight_ruler',
'strawberry',
'stuck_out_tongue',
'stuck_out_tongue_closed_eyes',
'stuck_out_tongue_winking_eye',
'sun_with_face',
'sunflower',
'sunglasses',
'sunny',
'sunrise',
'sunrise_over_mountains',
'surfer',
'sushi',
'suspect',
'suspension_railway',
'sweat',
'sweat_drops',
'sweat_smile',
'sweet_potato',
'swimmer',
'symbols',
'syringe',
'tada',
'tanabata_tree',
'tangerine',
'taurus',
'taxi',
'tea',
'telephone',
'telephone_receiver',
'telescope',
'tennis',
'tent',
'thought_balloon',
'three',
'thumbsdown',
'thumbsup',
'ticket',
'tiger',
'tiger2',
'tired_face',
'tm',
'toilet',
'tokyo_tower',
'tomato',
'tongue',
'top',
'tophat',
'tractor',
'traffic_light',
'train',
'train2',
'tram',
'triangular_flag_on_post',
'triangular_ruler',
'trident',
'triumph',
'trolleybus',
'trollface',
'trophy',
'tropical_drink',
'tropical_fish',
'truck',
'trumpet',
'tshirt',
'tulip',
'turtle',
'tv',
'twisted_rightwards_arrows',
'two',
'two_hearts',
'two_men_holding_hands',
'two_women_holding_hands',
'u5272',
'u5408',
'u55b6',
'u6307',
'u6708',
'u6709',
'u6e80',
'u7121',
'u7533',
'u7981',
'u7a7a',
'uk',
'umbrella',
'unamused',
'underage',
'unlock',
'up',
'us',
'v',
'vertical_traffic_light',
'vhs',
'vibration_mode',
'video_camera',
'video_game',
'violin',
'virgo',
'volcano',
'vs',
'walking',
'waning_crescent_moon',
'waning_gibbous_moon',
'warning',
'watch',
'water_buffalo',
'watermelon',
'wave',
'wavy_dash',
'waxing_crescent_moon',
'waxing_gibbous_moon',
'wc',
'weary',
'wedding',
'whale',
'whale2',
'wheelchair',
'white_check_mark',
'white_circle',
'white_flower',
'white_large_square',
'white_medium_small_square',
'white_medium_square',
'white_small_square',
'white_square_button',
'wind_chime',
'wine_glass',
'wink',
'wolf',
'woman',
'womans_clothes',
'womans_hat',
'womens',
'worried',
'wrench',
'x',
'yellow_heart',
'yen',
'yum',
'zap',
'zero',
'zzz'
];
// Emoji from All-Github-Emoji-Icons
// https://github.com/scotch-io/All-Github-Emoji-Icons
window.emojify = function (match, $1) {
return AllGithubEmoji.indexOf($1) === -1 ?
match :
'<img class="emoji" src="https://github.githubassets.com/images/icons/emoji/' +
$1 +
'.png" alt="' +
$1 +
'" />'
};
}());

1
lib/plugins/emoji.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,28 @@
(function () {
function handleExternalScript() {
var container = Docsify.dom.getNode('#main');
var scripts = Docsify.dom.findAll(container, 'script');
for (var i = scripts.length; i--;) {
var script = scripts[i];
if (script && script.src) {
var newScript = document.createElement('script');
Array.prototype.slice.call(script.attributes).forEach(function (attribute) {
newScript[attribute.name] = attribute.value;
});
script.parentNode.insertBefore(newScript, script);
script.parentNode.removeChild(script);
}
}
}
var install = function (hook) {
hook.doneEach(handleExternalScript);
};
window.$docsify.plugins = [].concat(install, window.$docsify.plugins);
}());

1
lib/plugins/external-script.min.js vendored Normal file
View file

@ -0,0 +1 @@
!function(){function e(){for(var o=Docsify.dom.getNode("#main"),e=Docsify.dom.findAll(o,"script"),n=e.length;n--;){var i=e[n];if(i&&i.src){var t=document.createElement("script");Array.prototype.slice.call(i.attributes).forEach(function(o){t[o.name]=o.value}),i.parentNode.insertBefore(t,i),i.parentNode.removeChild(i)}}}window.$docsify.plugins=[].concat(function(o){o.doneEach(e)},window.$docsify.plugins)}();

496
lib/plugins/front-matter.js Normal file
View file

@ -0,0 +1,496 @@
(function () {
/**
* Fork https://github.com/egoist/docute/blob/master/src/utils/yaml.js
*/
/* eslint-disable */
/*
YAML parser for Javascript
Author: Diogo Costa
This program is released under the MIT License as follows:
Copyright (c) 2011 Diogo Costa (costa.h4evr@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/**
* @name YAML
* @namespace
*/
var errors = [];
var reference_blocks = [];
var processing_time = 0;
var regex$1 = {
regLevel: new RegExp('^([\\s\\-]+)'),
invalidLine: new RegExp('^\\-\\-\\-|^\\.\\.\\.|^\\s*#.*|^\\s*$'),
dashesString: new RegExp('^\\s*\\"([^\\"]*)\\"\\s*$'),
quotesString: new RegExp("^\\s*\\'([^\\']*)\\'\\s*$"),
float: new RegExp('^[+-]?[0-9]+\\.[0-9]+(e[+-]?[0-9]+(\\.[0-9]+)?)?$'),
integer: new RegExp('^[+-]?[0-9]+$'),
array: new RegExp('\\[\\s*(.*)\\s*\\]'),
map: new RegExp('\\{\\s*(.*)\\s*\\}'),
key_value: new RegExp('([a-z0-9_-][ a-z0-9_-]*):( .+)', 'i'),
single_key_value: new RegExp('^([a-z0-9_-][ a-z0-9_-]*):( .+?)$', 'i'),
key: new RegExp('([a-z0-9_-][ a-z0-9_-]+):( .+)?', 'i'),
item: new RegExp('^-\\s+'),
trim: new RegExp('^\\s+|\\s+$'),
comment: new RegExp('([^\\\'\\"#]+([\\\'\\"][^\\\'\\"]*[\\\'\\"])*)*(#.*)?')
};
/**
* @class A block of lines of a given level.
* @param {int} lvl The block's level.
* @private
*/
function Block(lvl) {
return {
/* The block's parent */
parent: null,
/* Number of children */
length: 0,
/* Block's level */
level: lvl,
/* Lines of code to process */
lines: [],
/* Blocks with greater level */
children: [],
/* Add a block to the children collection */
addChild: function(obj) {
this.children.push(obj);
obj.parent = this;
++this.length;
}
}
}
function parser$1(str) {
var regLevel = regex$1['regLevel'];
var invalidLine = regex$1['invalidLine'];
var lines = str.split('\n');
var m;
var level = 0,
curLevel = 0;
var blocks = [];
var result = new Block(-1);
var currentBlock = new Block(0);
result.addChild(currentBlock);
var levels = [];
var line = '';
blocks.push(currentBlock);
levels.push(level);
for (var i = 0, len = lines.length; i < len; ++i) {
line = lines[i];
if (line.match(invalidLine)) {
continue
}
if ((m = regLevel.exec(line))) {
level = m[1].length;
} else { level = 0; }
if (level > curLevel) {
var oldBlock = currentBlock;
currentBlock = new Block(level);
oldBlock.addChild(currentBlock);
blocks.push(currentBlock);
levels.push(level);
} else if (level < curLevel) {
var added = false;
var k = levels.length - 1;
for (; k >= 0; --k) {
if (levels[k] == level) {
currentBlock = new Block(level);
blocks.push(currentBlock);
levels.push(level);
if (blocks[k].parent != null) { blocks[k].parent.addChild(currentBlock); }
added = true;
break
}
}
if (!added) {
errors.push('Error: Invalid indentation at line ' + i + ': ' + line);
return
}
}
currentBlock.lines.push(line.replace(regex$1['trim'], ''));
curLevel = level;
}
return result
}
function processValue(val) {
val = val.replace(regex$1['trim'], '');
var m = null;
if (val == 'true') {
return true
} else if (val == 'false') {
return false
} else if (val == '.NaN') {
return Number.NaN
} else if (val == 'null') {
return null
} else if (val == '.inf') {
return Number.POSITIVE_INFINITY
} else if (val == '-.inf') {
return Number.NEGATIVE_INFINITY
} else if ((m = val.match(regex$1['dashesString']))) {
return m[1]
} else if ((m = val.match(regex$1['quotesString']))) {
return m[1]
} else if ((m = val.match(regex$1['float']))) {
return parseFloat(m[0])
} else if ((m = val.match(regex$1['integer']))) {
return parseInt(m[0])
} else if (!isNaN((m = Date.parse(val)))) {
return new Date(m)
} else if ((m = val.match(regex$1['single_key_value']))) {
var res = {};
res[m[1]] = processValue(m[2]);
return res
} else if ((m = val.match(regex$1['array']))) {
var count = 0,
c = ' ';
var res = [];
var content = '';
var str = false;
for (var j = 0, lenJ = m[1].length; j < lenJ; ++j) {
c = m[1][j];
if (c == "'" || c == '"') {
if (str === false) {
str = c;
content += c;
continue
} else if ((c == "'" && str == "'") || (c == '"' && str == '"')) {
str = false;
content += c;
continue
}
} else if (str === false && (c == '[' || c == '{')) {
++count;
} else if (str === false && (c == ']' || c == '}')) {
--count;
} else if (str === false && count == 0 && c == ',') {
res.push(processValue(content));
content = '';
continue
}
content += c;
}
if (content.length > 0) { res.push(processValue(content)); }
return res
} else if ((m = val.match(regex$1['map']))) {
var count = 0,
c = ' ';
var res = [];
var content = '';
var str = false;
for (var j = 0, lenJ = m[1].length; j < lenJ; ++j) {
c = m[1][j];
if (c == "'" || c == '"') {
if (str === false) {
str = c;
content += c;
continue
} else if ((c == "'" && str == "'") || (c == '"' && str == '"')) {
str = false;
content += c;
continue
}
} else if (str === false && (c == '[' || c == '{')) {
++count;
} else if (str === false && (c == ']' || c == '}')) {
--count;
} else if (str === false && count == 0 && c == ',') {
res.push(content);
content = '';
continue
}
content += c;
}
if (content.length > 0) { res.push(content); }
var newRes = {};
for (var j = 0, lenJ = res.length; j < lenJ; ++j) {
if ((m = res[j].match(regex$1['key_value']))) {
newRes[m[1]] = processValue(m[2]);
}
}
return newRes
} else { return val }
}
function processFoldedBlock(block) {
var lines = block.lines;
var children = block.children;
var str = lines.join(' ');
var chunks = [str];
for (var i = 0, len = children.length; i < len; ++i) {
chunks.push(processFoldedBlock(children[i]));
}
return chunks.join('\n')
}
function processLiteralBlock(block) {
var lines = block.lines;
var children = block.children;
var str = lines.join('\n');
for (var i = 0, len = children.length; i < len; ++i) {
str += processLiteralBlock(children[i]);
}
return str
}
function processBlock(blocks) {
var m = null;
var res = {};
var lines = null;
var children = null;
var currentObj = null;
var level = -1;
var processedBlocks = [];
var isMap = true;
for (var j = 0, lenJ = blocks.length; j < lenJ; ++j) {
if (level != -1 && level != blocks[j].level) { continue }
processedBlocks.push(j);
level = blocks[j].level;
lines = blocks[j].lines;
children = blocks[j].children;
currentObj = null;
for (var i = 0, len = lines.length; i < len; ++i) {
var line = lines[i];
if ((m = line.match(regex$1['key']))) {
var key = m[1];
if (key[0] == '-') {
key = key.replace(regex$1['item'], '');
if (isMap) {
isMap = false;
if (typeof res.length === 'undefined') {
res = [];
}
}
if (currentObj != null) { res.push(currentObj); }
currentObj = {};
isMap = true;
}
if (typeof m[2] != 'undefined') {
var value = m[2].replace(regex$1['trim'], '');
if (value[0] == '&') {
var nb = processBlock(children);
if (currentObj != null) { currentObj[key] = nb; }
else { res[key] = nb; }
reference_blocks[value.substr(1)] = nb;
} else if (value[0] == '|') {
if (currentObj != null)
{ currentObj[key] = processLiteralBlock(children.shift()); }
else { res[key] = processLiteralBlock(children.shift()); }
} else if (value[0] == '*') {
var v = value.substr(1);
var no = {};
if (typeof reference_blocks[v] == 'undefined') {
errors.push("Reference '" + v + "' not found!");
} else {
for (var k in reference_blocks[v]) {
no[k] = reference_blocks[v][k];
}
if (currentObj != null) { currentObj[key] = no; }
else { res[key] = no; }
}
} else if (value[0] == '>') {
if (currentObj != null)
{ currentObj[key] = processFoldedBlock(children.shift()); }
else { res[key] = processFoldedBlock(children.shift()); }
} else {
if (currentObj != null) { currentObj[key] = processValue(value); }
else { res[key] = processValue(value); }
}
} else {
if (currentObj != null) { currentObj[key] = processBlock(children); }
else { res[key] = processBlock(children); }
}
} else if (line.match(/^-\s*$/)) {
if (isMap) {
isMap = false;
if (typeof res.length === 'undefined') {
res = [];
}
}
if (currentObj != null) { res.push(currentObj); }
currentObj = {};
isMap = true;
continue
} else if ((m = line.match(/^-\s*(.*)/))) {
if (currentObj != null) { currentObj.push(processValue(m[1])); }
else {
if (isMap) {
isMap = false;
if (typeof res.length === 'undefined') {
res = [];
}
}
res.push(processValue(m[1]));
}
continue
}
}
if (currentObj != null) {
if (isMap) {
isMap = false;
if (typeof res.length === 'undefined') {
res = [];
}
}
res.push(currentObj);
}
}
for (var j = processedBlocks.length - 1; j >= 0; --j) {
blocks.splice.call(blocks, processedBlocks[j], 1);
}
return res
}
function semanticAnalysis(blocks) {
var res = processBlock(blocks.children);
return res
}
function preProcess(src) {
var m;
var lines = src.split('\n');
var r = regex$1['comment'];
for (var i in lines) {
if ((m = lines[i].match(r))) {
/* var cmt = "";
if(typeof m[3] != "undefined")
lines[i] = m[1];
else if(typeof m[3] != "undefined")
lines[i] = m[3];
else
lines[i] = "";
*/
if (typeof m[3] !== 'undefined') {
lines[i] = m[0].substr(0, m[0].length - m[3].length);
}
}
}
return lines.join('\n')
}
function load(str) {
errors = [];
reference_blocks = [];
processing_time = new Date().getTime();
var pre = preProcess(str);
var doc = parser$1(pre);
var res = semanticAnalysis(doc);
processing_time = new Date().getTime() - processing_time;
return res
}
/**
* Fork https://github.com/egoist/docute/blob/master/src/utils/front-matter.js
*/
/* eslint-disable */
var optionalByteOrderMark = '\\ufeff?';
var pattern =
'^(' +
optionalByteOrderMark +
'(= yaml =|---)' +
'$([\\s\\S]*?)' +
'(?:\\2|\\.\\.\\.)' +
'$' +
'' +
'(?:\\n)?)';
// NOTE: If this pattern uses the 'g' flag the `regex` variable definition will
// need to be moved down into the functions that use it.
var regex = new RegExp(pattern, 'm');
function extractor(string) {
string = string || '';
var lines = string.split(/(\r?\n)/);
if (lines[0] && /= yaml =|---/.test(lines[0])) {
return parse(string)
} else {
return { attributes: {}, body: string }
}
}
function parse(string) {
var match = regex.exec(string);
if (!match) {
return {
attributes: {},
body: string
}
}
var yaml = match[match.length - 1].replace(/^\s+|\s+$/g, '');
var attributes = load(yaml) || {};
var body = string.replace(match[0], '');
return { attributes: attributes, body: body, frontmatter: yaml }
}
var install = function (hook, vm) {
hook.beforeEach(function (content) {
var ref = extractor(content);
var attributes = ref.attributes;
var body = ref.body;
vm.frontmatter = attributes;
return body
});
};
$docsify.plugins = [].concat(install, $docsify.plugins);
}());

1
lib/plugins/front-matter.min.js vendored Normal file
View file

@ -0,0 +1 @@
!function(){var b=[],y=[],t=0,R={regLevel:new RegExp("^([\\s\\-]+)"),invalidLine:new RegExp("^\\-\\-\\-|^\\.\\.\\.|^\\s*#.*|^\\s*$"),dashesString:new RegExp('^\\s*\\"([^\\"]*)\\"\\s*$'),quotesString:new RegExp("^\\s*\\'([^\\']*)\\'\\s*$"),float:new RegExp("^[+-]?[0-9]+\\.[0-9]+(e[+-]?[0-9]+(\\.[0-9]+)?)?$"),integer:new RegExp("^[+-]?[0-9]+$"),array:new RegExp("\\[\\s*(.*)\\s*\\]"),map:new RegExp("\\{\\s*(.*)\\s*\\}"),key_value:new RegExp("([a-z0-9_-][ a-z0-9_-]*):( .+)","i"),single_key_value:new RegExp("^([a-z0-9_-][ a-z0-9_-]*):( .+?)$","i"),key:new RegExp("([a-z0-9_-][ a-z0-9_-]+):( .+)?","i"),item:new RegExp("^-\\s+"),trim:new RegExp("^\\s+|\\s+$"),comment:new RegExp("([^\\'\\\"#]+([\\'\\\"][^\\'\\\"]*[\\'\\\"])*)*(#.*)?")};function m(e){return{parent:null,length:0,level:e,lines:[],children:[],addChild:function(e){this.children.push(e),++(e.parent=this).length}}}function N(e){var n=null;if("true"==(e=e.replace(R.trim,"")))return!0;if("false"==e)return!1;if(".NaN"==e)return Number.NaN;if("null"==e)return null;if(".inf"==e)return Number.POSITIVE_INFINITY;if("-.inf"==e)return Number.NEGATIVE_INFINITY;if(n=e.match(R.dashesString))return n[1];if(n=e.match(R.quotesString))return n[1];if(n=e.match(R.float))return parseFloat(n[0]);if(n=e.match(R.integer))return parseInt(n[0]);if(isNaN(n=Date.parse(e))){if(n=e.match(R.single_key_value))return(i={})[n[1]]=N(n[2]),i;if(n=e.match(R.array)){for(var t=0,r=" ",i=[],l="",u=!1,a=0,s=n[1].length;a<s;++a){if("'"==(r=n[1][a])||'"'==r){if(!1===u){l+=u=r;continue}if("'"==r&&"'"==u||'"'==r&&'"'==u){u=!1,l+=r;continue}}else if(!1!==u||"["!=r&&"{"!=r)if(!1!==u||"]"!=r&&"}"!=r){if(!1===u&&0==t&&","==r){i.push(N(l)),l="";continue}}else--t;else++t;l+=r}return 0<l.length&&i.push(N(l)),i}if(n=e.match(R.map)){for(t=0,r=" ",i=[],l="",u=!1,a=0,s=n[1].length;a<s;++a){if("'"==(r=n[1][a])||'"'==r){if(!1===u){l+=u=r;continue}if("'"==r&&"'"==u||'"'==r&&'"'==u){u=!1,l+=r;continue}}else if(!1!==u||"["!=r&&"{"!=r)if(!1!==u||"]"!=r&&"}"!=r){if(!1===u&&0==t&&","==r){i.push(l),l="";continue}}else--t;else++t;l+=r}0<l.length&&i.push(l);var f={};for(a=0,s=i.length;a<s;++a)(n=i[a].match(R.key_value))&&(f[n[1]]=N(n[2]));return f}return e}return new Date(n)}function _(e){for(var n=e.lines,t=e.children,r=[n.join(" ")],i=0,l=t.length;i<l;++i)r.push(_(t[i]));return r.join("\n")}function $(e){for(var n=e.lines,t=e.children,r=n.join("\n"),i=0,l=t.length;i<l;++i)r+=$(t[i]);return r}function r(e){return function e(n){for(var t=null,r={},i=null,l=null,u=null,a=-1,s=[],f=!0,h=0,o=n.length;h<o;++h)if(-1==a||a==n[h].level){s.push(h),a=n[h].level,i=n[h].lines,l=n[h].children,u=null;for(var c=0,p=i.length;c<p;++c){var g=i[c];if(t=g.match(R.key)){var v=t[1];if("-"==v[0]&&(v=v.replace(R.item,""),f&&(f=!1,void 0===r.length&&(r=[])),null!=u&&r.push(u),u={},f=!0),void 0!==t[2]){var d=t[2].replace(R.trim,"");if("&"==d[0]){var m=e(l);null!=u?u[v]=m:r[v]=m,y[d.substr(1)]=m}else if("|"==d[0])null!=u?u[v]=$(l.shift()):r[v]=$(l.shift());else if("*"==d[0]){var w=d.substr(1),E={};if(void 0===y[w])b.push("Reference '"+w+"' not found!");else{for(var x in y[w])E[x]=y[w][x];null!=u?u[v]=E:r[v]=E}}else">"==d[0]?null!=u?u[v]=_(l.shift()):r[v]=_(l.shift()):null!=u?u[v]=N(d):r[v]=N(d)}else null!=u?u[v]=e(l):r[v]=e(l)}else{if(g.match(/^-\s*$/)){f&&(f=!1,void 0===r.length&&(r=[])),null!=u&&r.push(u),u={},f=!0;continue}if(t=g.match(/^-\s*(.*)/)){null!=u?u.push(N(t[1])):(f&&(f=!1,void 0===r.length&&(r=[])),r.push(N(t[1])));continue}}}null!=u&&(f&&(f=!1,void 0===r.length&&(r=[])),r.push(u))}for(h=s.length-1;0<=h;--h)n.splice.call(n,s[h],1);return r}(e.children)}function l(e){b=[],y=[],t=(new Date).getTime();var n=r(function(e){var n,t=R.regLevel,r=R.invalidLine,i=e.split("\n"),l=0,u=0,a=[],s=new m(-1),f=new m(0);s.addChild(f);var h=[],o="";a.push(f),h.push(l);for(var c=0,p=i.length;c<p;++c)if(!(o=i[c]).match(r)){if(u<(l=(n=t.exec(o))?n[1].length:0)){var g=f;f=new m(l),g.addChild(f),a.push(f),h.push(l)}else if(l<u){for(var v=!1,d=h.length-1;0<=d;--d)if(h[d]==l){f=new m(l),a.push(f),h.push(l),null!=a[d].parent&&a[d].parent.addChild(f),v=!0;break}if(!v)return void b.push("Error: Invalid indentation at line "+c+": "+o)}f.lines.push(o.replace(R.trim,"")),u=l}return s}(function(e){var n,t=e.split("\n"),r=R.comment;for(var i in t)(n=t[i].match(r))&&void 0!==n[3]&&(t[i]=n[0].substr(0,n[0].length-n[3].length));return t.join("\n")}(e)));return t=(new Date).getTime()-t,n}var u=new RegExp("^(\\ufeff?(= yaml =|---)$([\\s\\S]*?)(?:\\2|\\.\\.\\.)$(?:\\n)?)","m");function a(e){var n=(e=e||"").split(/(\r?\n)/);return n[0]&&/= yaml =|---/.test(n[0])?function(e){var n=u.exec(e);if(!n)return{attributes:{},body:e};var t=n[n.length-1].replace(/^\s+|\s+$/g,""),r=l(t)||{},i=e.replace(n[0],"");return{attributes:r,body:i,frontmatter:t}}(e):{attributes:{},body:e}}$docsify.plugins=[].concat(function(e,i){e.beforeEach(function(e){var n=a(e),t=n.attributes,r=n.body;return i.frontmatter=t,r})},$docsify.plugins)}();

41
lib/plugins/ga.js Normal file
View file

@ -0,0 +1,41 @@
(function () {
// From https://github.com/egoist/vue-ga/blob/master/src/index.js
function appendScript() {
var script = document.createElement('script');
script.async = true;
script.src = 'https://www.google-analytics.com/analytics.js';
document.body.appendChild(script);
}
function init(id) {
appendScript();
window.ga =
window.ga ||
function () {
(window.ga.q = window.ga.q || []).push(arguments);
};
window.ga.l = Number(new Date());
window.ga('create', id, 'auto');
}
function collect() {
if (!window.ga) {
init($docsify.ga);
}
window.ga('set', 'page', location.hash);
window.ga('send', 'pageview');
}
var install = function (hook) {
if (!$docsify.ga) {
console.error('[Docsify] ga is required.');
return
}
hook.beforeEach(collect);
};
$docsify.plugins = [].concat(install, $docsify.plugins);
}());

1
lib/plugins/ga.min.js vendored Normal file
View file

@ -0,0 +1 @@
!function(){function n(n){var o;(o=document.createElement("script")).async=!0,o.src="https://www.google-analytics.com/analytics.js",document.body.appendChild(o),window.ga=window.ga||function(){(window.ga.q=window.ga.q||[]).push(arguments)},window.ga.l=Number(new Date),window.ga("create",n,"auto")}function o(){window.ga||n($docsify.ga),window.ga("set","page",location.hash),window.ga("send","pageview")}$docsify.plugins=[].concat(function(n){$docsify.ga?n.beforeEach(o):console.error("[Docsify] ga is required.")},$docsify.plugins)}();

20
lib/plugins/gitalk.js Normal file
View file

@ -0,0 +1,20 @@
(function () {
function install(hook) {
var dom = Docsify.dom;
hook.mounted(function (_) {
var div = dom.create('div');
div.id = 'gitalk-container';
var main = dom.getNode('#main');
div.style = "width: " + (main.clientWidth) + "px; margin: 0 auto 20px;";
dom.appendTo(dom.find('.content'), div);
var script = dom.create('script');
var content = "gitalk.render('gitalk-container')";
script.textContent = content;
dom.appendTo(dom.body, script);
});
}
$docsify.plugins = [].concat(install, $docsify.plugins);
}());

1
lib/plugins/gitalk.min.js vendored Normal file
View file

@ -0,0 +1 @@
$docsify.plugins=[].concat(function(t){var a=Docsify.dom;t.mounted(function(t){var n=a.create("div");n.id="gitalk-container";var i=a.getNode("#main");n.style="width: "+i.clientWidth+"px; margin: 0 auto 20px;",a.appendTo(a.find(".content"),n);var e=a.create("script");e.textContent="gitalk.render('gitalk-container')",a.appendTo(a.body,e)})},$docsify.plugins);

364
lib/plugins/search.js Normal file
View file

@ -0,0 +1,364 @@
(function () {
var INDEXS = {};
var LOCAL_STORAGE = {
EXPIRE_KEY: 'docsify.search.expires',
INDEX_KEY: 'docsify.search.index'
};
function resolveExpireKey(namespace) {
return namespace ? ((LOCAL_STORAGE.EXPIRE_KEY) + "/" + namespace) : LOCAL_STORAGE.EXPIRE_KEY
}
function resolveIndexKey(namespace) {
return namespace ? ((LOCAL_STORAGE.INDEX_KEY) + "/" + namespace) : LOCAL_STORAGE.INDEX_KEY
}
function escapeHtml(string) {
var entityMap = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
'\'': '&#39;',
'/': '&#x2F;'
};
return String(string).replace(/[&<>"'/]/g, function (s) { return entityMap[s]; })
}
function getAllPaths(router) {
var paths = [];
Docsify.dom.findAll('.sidebar-nav a:not(.section-link):not([data-nosearch])').forEach(function (node) {
var href = node.href;
var originHref = node.getAttribute('href');
var path = router.parse(href).path;
if (
path &&
paths.indexOf(path) === -1 &&
!Docsify.util.isAbsolutePath(originHref)
) {
paths.push(path);
}
});
return paths
}
function saveData(maxAge, expireKey, indexKey) {
localStorage.setItem(expireKey, Date.now() + maxAge);
localStorage.setItem(indexKey, JSON.stringify(INDEXS));
}
function genIndex(path, content, router, depth) {
if ( content === void 0 ) content = '';
var tokens = window.marked.lexer(content);
var slugify = window.Docsify.slugify;
var index = {};
var slug;
tokens.forEach(function (token) {
if (token.type === 'heading' && token.depth <= depth) {
slug = router.toURL(path, {id: slugify(token.text)});
index[slug] = {slug: slug, title: token.text, body: ''};
} else {
if (!slug) {
return
}
if (!index[slug]) {
index[slug] = {slug: slug, title: '', body: ''};
} else if (index[slug].body) {
index[slug].body += '\n' + (token.text || '');
} else {
index[slug].body = token.text;
}
}
});
slugify.clear();
return index
}
/**
* @param {String} query
* @returns {Array}
*/
function search(query) {
var matchingResults = [];
var data = [];
Object.keys(INDEXS).forEach(function (key) {
data = data.concat(Object.keys(INDEXS[key]).map(function (page) { return INDEXS[key][page]; }));
});
query = query.trim();
var keywords = query.split(/[\s\-\\/]+/);
if (keywords.length !== 1) {
keywords = [].concat(query, keywords);
}
var loop = function ( i ) {
var post = data[i];
var isMatch = false;
var resultStr = '';
var postTitle = post.title && post.title.trim();
var postContent = post.body && post.body.trim();
var postUrl = post.slug || '';
if (postTitle && postContent) {
keywords.forEach(function (keyword) {
// From https://github.com/sindresorhus/escape-string-regexp
var regEx = new RegExp(
keyword.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&'),
'gi'
);
var indexTitle = -1;
var indexContent = -1;
indexTitle = postTitle && postTitle.search(regEx);
indexContent = postContent && postContent.search(regEx);
if (indexTitle < 0 && indexContent < 0) {
isMatch = false;
} else {
isMatch = true;
if (indexContent < 0) {
indexContent = 0;
}
var start = 0;
var end = 0;
start = indexContent < 11 ? 0 : indexContent - 10;
end = start === 0 ? 70 : indexContent + keyword.length + 60;
if (end > postContent.length) {
end = postContent.length;
}
var matchContent =
'...' +
escapeHtml(postContent)
.substring(start, end)
.replace(regEx, ("<em class=\"search-keyword\">" + keyword + "</em>")) +
'...';
resultStr += matchContent;
}
});
if (isMatch) {
var matchingPost = {
title: escapeHtml(postTitle),
content: resultStr,
url: postUrl
};
matchingResults.push(matchingPost);
}
}
};
for (var i = 0; i < data.length; i++) loop( i );
return matchingResults
}
function init$1(config, vm) {
var isAuto = config.paths === 'auto';
var expireKey = resolveExpireKey(config.namespace);
var indexKey = resolveIndexKey(config.namespace);
var isExpired = localStorage.getItem(expireKey) < Date.now();
INDEXS = JSON.parse(localStorage.getItem(indexKey));
if (isExpired) {
INDEXS = {};
} else if (!isAuto) {
return
}
var paths = isAuto ? getAllPaths(vm.router) : config.paths;
var len = paths.length;
var count = 0;
paths.forEach(function (path) {
if (INDEXS[path]) {
return count++
}
Docsify
.get(vm.router.getFile(path), false, vm.config.requestHeaders)
.then(function (result) {
INDEXS[path] = genIndex(path, result, vm.router, config.depth);
len === ++count && saveData(config.maxAge, expireKey, indexKey);
});
});
}
var NO_DATA_TEXT = '';
var options;
function style() {
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}\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}";
Docsify.dom.style(code);
}
function tpl(defaultValue) {
if ( defaultValue === void 0 ) defaultValue = '';
var html =
"<div class=\"input-wrap\">\n <input type=\"search\" value=\"" + defaultValue + "\" />\n <div class=\"clear-button\">\n <svg width=\"26\" height=\"24\">\n <circle cx=\"12\" cy=\"12\" r=\"11\" fill=\"#ccc\" />\n <path stroke=\"white\" stroke-width=\"2\" d=\"M8.25,8.25,15.75,15.75\" />\n <path stroke=\"white\" stroke-width=\"2\"d=\"M8.25,15.75,15.75,8.25\" />\n </svg>\n </div>\n </div>\n <div class=\"results-panel\"></div>\n </div>";
var el = Docsify.dom.create('div', html);
var aside = Docsify.dom.find('aside');
Docsify.dom.toggleClass(el, 'search');
Docsify.dom.before(aside, el);
}
function doSearch(value) {
var $search = Docsify.dom.find('div.search');
var $panel = Docsify.dom.find($search, '.results-panel');
var $clearBtn = Docsify.dom.find($search, '.clear-button');
var $sidebarNav = Docsify.dom.find('.sidebar-nav');
var $appName = Docsify.dom.find('.app-name');
if (!value) {
$panel.classList.remove('show');
$clearBtn.classList.remove('show');
$panel.innerHTML = '';
if (options.hideOtherSidebarContent) {
$sidebarNav.classList.remove('hide');
$appName.classList.remove('hide');
}
return
}
var matchs = search(value);
var html = '';
matchs.forEach(function (post) {
html += "<div class=\"matching-post\">\n<a href=\"" + (post.url) + "\">\n<h2>" + (post.title) + "</h2>\n<p>" + (post.content) + "</p>\n</a>\n</div>";
});
$panel.classList.add('show');
$clearBtn.classList.add('show');
$panel.innerHTML = html || ("<p class=\"empty\">" + NO_DATA_TEXT + "</p>");
if (options.hideOtherSidebarContent) {
$sidebarNav.classList.add('hide');
$appName.classList.add('hide');
}
}
function bindEvents() {
var $search = Docsify.dom.find('div.search');
var $input = Docsify.dom.find($search, 'input');
var $inputWrap = Docsify.dom.find($search, '.input-wrap');
var timeId;
// Prevent to Fold sidebar
Docsify.dom.on(
$search,
'click',
function (e) { return e.target.tagName !== 'A' && e.stopPropagation(); }
);
Docsify.dom.on($input, 'input', function (e) {
clearTimeout(timeId);
timeId = setTimeout(function (_) { return doSearch(e.target.value.trim()); }, 100);
});
Docsify.dom.on($inputWrap, 'click', function (e) {
// Click input outside
if (e.target.tagName !== 'INPUT') {
$input.value = '';
doSearch();
}
});
}
function updatePlaceholder(text, path) {
var $input = Docsify.dom.getNode('.search input[type="search"]');
if (!$input) {
return
}
if (typeof text === 'string') {
$input.placeholder = text;
} else {
var match = Object.keys(text).filter(function (key) { return path.indexOf(key) > -1; })[0];
$input.placeholder = text[match];
}
}
function updateNoData(text, path) {
if (typeof text === 'string') {
NO_DATA_TEXT = text;
} else {
var match = Object.keys(text).filter(function (key) { return path.indexOf(key) > -1; })[0];
NO_DATA_TEXT = text[match];
}
}
function updateOptions(opts) {
options = opts;
}
function init(opts, vm) {
var keywords = vm.router.parse().query.s;
updateOptions(opts);
style();
tpl(keywords);
bindEvents();
keywords && setTimeout(function (_) { return doSearch(keywords); }, 500);
}
function update(opts, vm) {
updateOptions(opts);
updatePlaceholder(opts.placeholder, vm.route.path);
updateNoData(opts.noData, vm.route.path);
}
var CONFIG = {
placeholder: 'Type to search',
noData: 'No Results!',
paths: 'auto',
depth: 2,
maxAge: 86400000, // 1 day
hideOtherSidebarContent: false,
namespace: undefined
};
var install = function (hook, vm) {
var util = Docsify.util;
var opts = vm.config.search || CONFIG;
if (Array.isArray(opts)) {
CONFIG.paths = opts;
} else if (typeof opts === 'object') {
CONFIG.paths = Array.isArray(opts.paths) ? opts.paths : 'auto';
CONFIG.maxAge = util.isPrimitive(opts.maxAge) ? opts.maxAge : CONFIG.maxAge;
CONFIG.placeholder = opts.placeholder || CONFIG.placeholder;
CONFIG.noData = opts.noData || CONFIG.noData;
CONFIG.depth = opts.depth || CONFIG.depth;
CONFIG.hideOtherSidebarContent = opts.hideOtherSidebarContent || CONFIG.hideOtherSidebarContent;
CONFIG.namespace = opts.namespace || CONFIG.namespace;
}
var isAuto = CONFIG.paths === 'auto';
hook.mounted(function (_) {
init(CONFIG, vm);
!isAuto && init$1(CONFIG, vm);
});
hook.doneEach(function (_) {
update(CONFIG, vm);
isAuto && init$1(CONFIG, vm);
});
};
$docsify.plugins = [].concat(install, $docsify.plugins);
}());

1
lib/plugins/search.min.js vendored Normal file

File diff suppressed because one or more lines are too long

40
lib/plugins/zoom-image.js Normal file

File diff suppressed because one or more lines are too long

1
lib/plugins/zoom-image.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1
lib/themes/buble.css Normal file

File diff suppressed because one or more lines are too long

1
lib/themes/dark.css Normal file

File diff suppressed because one or more lines are too long

1
lib/themes/dolphin.css Normal file

File diff suppressed because one or more lines are too long

1
lib/themes/pure.css Normal file

File diff suppressed because one or more lines are too long

1
lib/themes/vue.css Normal file

File diff suppressed because one or more lines are too long

8
package-lock.json generated
View file

@ -1,6 +1,6 @@
{
"name": "docsify",
"version": "4.9.4",
"version": "4.9.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -8791,6 +8791,12 @@
"async-limiter": "~1.0.0"
}
},
"xhr2": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/xhr2/-/xhr2-0.1.4.tgz",
"integrity": "sha1-f4dliEdxbbUCYyOBL4GMras4el8=",
"dev": true
},
"xml-name-validator": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz",

View file

@ -1,6 +1,6 @@
{
"name": "docsify",
"version": "4.9.4",
"version": "4.9.1",
"description": "A magical documentation generator.",
"author": {
"name": "qingwei-li",
@ -27,16 +27,16 @@
"dev": "run-p serve watch:*",
"dev:ssr": "run-p serve:ssr watch:*",
"lint": "eslint {src,packages} --fix",
"test": "mocha test/*/**",
"test": "mocha",
"css": "stylus src/themes/*.styl -u autoprefixer-stylus",
"watch:css": "run-p 'css -- -o themes -w'",
"watch:js": "node build/build.js",
"build:css:min": "mkdir lib/themes && run-p 'css -- -o lib/themes' && node build/mincss.js",
"build:css": "mkdir -p themes && run-p 'css -- -o themes'",
"build:css": "mkdir themes && run-p 'css -- -o themes'",
"build:js": "cross-env NODE_ENV=production node build/build.js",
"build:ssr": "node build/ssr.js",
"build:cover": "node build/cover.js",
"build": "rimraf lib themes/* && run-s build:js build:css build:css:min build:ssr build:cover",
"build": "rimraf lib themes && run-s build:js build:css build:css:min build:ssr build:cover",
"pub:next": "cross-env RELEASE_TAG=next sh build/release.sh",
"pub": "sh build/release.sh",
"postinstall": "opencollective postinstall"
@ -72,7 +72,8 @@
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-uglify": "^2.0.1",
"stylus": "^0.54.5"
"stylus": "^0.54.5",
"xhr2": "^0.1.4"
},
"keywords": [
"doc",

View file

@ -37,5 +37,5 @@
"integrity": "sha1-6DWIAbhrg7F1YNTjw4LXrvIQCUQ="
}
},
"version": "4.9.4"
"version": "4.9.1"
}

View file

@ -1,6 +1,6 @@
{
"name": "docsify-server-renderer",
"version": "4.9.4",
"version": "4.9.1",
"description": "docsify server renderer",
"author": {
"name": "qingwei-li",

View file

@ -25,8 +25,7 @@ export default function () {
formatUpdated: '',
externalLinkTarget: '_blank',
routerMode: 'hash',
noCompileLinks: [],
relativePath: false
noCompileLinks: []
},
window.$docsify
)

View file

@ -329,25 +329,13 @@ export class Compiler {
* Compile sidebar
*/
sidebar(text, level) {
const {toc} = this
const currentPath = this.router.getCurrentPath()
let html = ''
if (text) {
html = this.compile(text)
} else {
for (let i = 0; i < toc.length; i++) {
if (toc[i].ignoreSubHeading) {
const deletedHeaderLevel = toc[i].level
toc.splice(i, 1)
// Remove headers who are under current header
for (let j = i; deletedHeaderLevel < toc[j].level && j < toc.length; j++) {
toc.splice(j, 1) && j-- && i++
}
i--
}
}
const tree = this.cacheTree[currentPath] || genTree(toc, level)
const tree = this.cacheTree[currentPath] || genTree(this.toc, level)
html = treeTpl(tree, '<ul>{inner}</ul>')
this.cacheTree[currentPath] = tree
}
@ -372,6 +360,7 @@ export class Compiler {
for (let i = 0; i < toc.length; i++) {
toc[i].ignoreSubHeading && toc.splice(i, 1) && i--
}
const tree = cacheTree[currentPath] || genTree(toc, level)
cacheTree[currentPath] = tree

View file

@ -3,8 +3,7 @@ import {
isAbsolutePath,
stringifyQuery,
cleanPath,
replaceSlug,
resolvePath
replaceSlug
} from '../util'
import {noop, merge} from '../../util/core'
@ -74,13 +73,9 @@ export class History {
if (local) {
const idIndex = currentRoute.indexOf('?')
path =
(idIndex > 0 ? currentRoute.substring(0, idIndex) : currentRoute) + path
(idIndex > 0 ? currentRoute.substr(0, idIndex) : currentRoute) + path
}
if (this.config.relativePath && path.indexOf('/') !== 0) {
const currentDir = currentRoute.substring(0, currentRoute.lastIndexOf('/') + 1)
return cleanPath(resolvePath(currentDir + path))
}
return cleanPath('/' + path)
}
}

View file

@ -53,20 +53,6 @@ export const cleanPath = cached(path => {
return path.replace(/^\/+/, '/').replace(/([^:])\/{2,}/g, '$1/')
})
export const resolvePath = cached(path => {
const segments = path.replace(/^\//, '').split('/')
let resolved = []
for (let i = 0, len = segments.length; i < len; i++) {
const segment = segments[i]
if (segment === '..') {
resolved.pop()
} else if (segment !== '.') {
resolved.push(segment)
}
}
return '/' + resolved.join('/')
})
export function getPath(...args) {
return cleanPath(args.join('/'))
}

View file

@ -7,16 +7,10 @@ function install(hook) {
const main = dom.getNode('#main')
div.style = `width: ${main.clientWidth}px; margin: 0 auto 20px;`
dom.appendTo(dom.find('.content'), div)
})
hook.doneEach(_ => {
const el = document.getElementById('gitalk-container')
while (el.hasChildNodes()) {
el.removeChild(el.firstChild)
}
// eslint-disable-next-line
gitalk.render('gitalk-container')
const script = dom.create('script')
const content = `gitalk.render('gitalk-container')`
script.textContent = content
dom.appendTo(dom.body, script)
})
}

View file

@ -1,37 +0,0 @@
function appendScript(options) {
const script = document.createElement('script')
script.async = true
script.src = options.host + '/matomo.js'
document.body.appendChild(script)
}
function init(options) {
window._paq = window._paq || []
window._paq.push(['trackPageView'])
window._paq.push(['enableLinkTracking'])
setTimeout(function() {
appendScript(options)
window._paq.push(['setTrackerUrl', options.host + '/matomo.php'])
window._paq.push(['setSiteId', options.id + ''])
}, 0)
}
function collect() {
if (!window._paq) {
init($docsify.matomo)
}
window._paq.push(['setCustomUrl', window.location.hash.substr(1)])
window._paq.push(['setDocumentTitle', document.title])
window._paq.push(['trackPageView'])
}
const install = function (hook) {
if (!$docsify.matomo) {
console.error('[Docsify] matomo is required.')
return
}
hook.beforeEach(collect)
}
$docsify.plugins = [].concat(install, $docsify.plugins)

View file

@ -96,27 +96,29 @@ export function search(query) {
for (let i = 0; i < data.length; i++) {
const post = data[i]
let matchesScore = 0
let isMatch = false
let resultStr = ''
const postTitle = post.title && post.title.trim()
const postContent = post.body && post.body.trim()
const postUrl = post.slug || ''
if (postTitle) {
keywords.forEach( keyword => {
if (postTitle && postContent) {
keywords.forEach(keyword => {
// From https://github.com/sindresorhus/escape-string-regexp
const regEx = new RegExp(
keyword.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&'),
'gi'
);
)
let indexTitle = -1
let indexContent = -1
indexTitle = postTitle ? postTitle.search(regEx) : -1
indexContent = postContent ? postContent.search(regEx) : -1
indexTitle = postTitle && postTitle.search(regEx)
indexContent = postContent && postContent.search(regEx)
if (indexTitle >= 0 || indexContent >= 0) {
matchesScore += indexTitle >= 0 ? 3 : indexContent >= 0 ? 2 : 0;
if (indexTitle < 0 && indexContent < 0) {
isMatch = false
} else {
isMatch = true
if (indexContent < 0) {
indexContent = 0
}
@ -142,12 +144,11 @@ export function search(query) {
}
})
if (matchesScore > 0) {
if (isMatch) {
const matchingPost = {
title: escapeHtml(postTitle),
content: postContent ? resultStr : '',
url: postUrl,
score: matchesScore
content: resultStr,
url: postUrl
}
matchingResults.push(matchingPost)
@ -155,7 +156,7 @@ export function search(query) {
}
}
return matchingResults.sort((r1, r2) => r2.score - r1.score);
return matchingResults
}
export function init(config, vm) {

View file

@ -1,10 +1,45 @@
// load ES6 modules in Node.js on the fly
require = require('esm')(module/*, options*/)
const path = require('path')
const {expect} = require('chai')
const {JSDOM} = require('jsdom')
const XMLHttpRequest = require('xhr2') // JSDOM doesn't support XMLHttpRequest
// TODO: try to fix tests when using `<div id="app"></div>` in body
const markup = `<!DOCTYPE html>
<html>
<head></head>
<body></body>
</html>`
// TODO: this may not work if tests are mutate the DOM, instead a new instance needs to be created
// for every test case but that will slow down the tests
const dom = new JSDOM(markup)
global.window = dom.window
global.document = dom.window.document
global.navigator = dom.window.navigator
global.location = dom.window.location
global.XMLHttpRequest = XMLHttpRequest
const {initMixin} = require('../src/core/init')
const {routerMixin} = require('../src/core//router')
const {renderMixin} = require('../src/core//render')
const {fetchMixin} = require('../src/core/fetch')
const {eventMixin} = require('../src/core//event')
// mimic src/core/index.js but for Node.js
function Docsify() {
this._init()
}
const proto = Docsify.prototype
initMixin(proto)
routerMixin(proto)
renderMixin(proto)
fetchMixin(proto)
eventMixin(proto)
function ready(callback) {
const state = document.readyState
@ -15,64 +50,16 @@ function ready(callback) {
document.addEventListener('DOMContentLoaded', callback)
}
module.exports.init = function(fixture = 'default', config = {}, markup) {
if (markup == null) {
markup = `<!DOCTYPE html>
<html>
<head></head>
<body>
<div id="app"></div>
<script>
window.$docsify = ${JSON.stringify(config, null, 2)}
</script>
</body>
</html>`
}
const rootPath = path.join(__dirname, 'fixtures', fixture)
const dom = new JSDOM(markup)
dom.reconfigure({ url: 'file:///' + rootPath })
global.window = dom.window
global.document = dom.window.document
global.navigator = dom.window.navigator
global.location = dom.window.location
global.XMLHttpRequest = dom.window.XMLHttpRequest
// mimic src/core/index.js but for Node.js
function Docsify() {
this._init()
}
const proto = Docsify.prototype
const {initMixin} = require('../src/core/init')
const {routerMixin} = require('../src/core//router')
const {renderMixin} = require('../src/core//render')
const {fetchMixin} = require('../src/core/fetch')
const {eventMixin} = require('../src/core//event')
initMixin(proto)
routerMixin(proto)
renderMixin(proto)
fetchMixin(proto)
eventMixin(proto)
const NOT_INIT_PATTERN = '<!--main-->'
let docsify = null
module.exports.init = function(callback) {
return new Promise((resolve, reject) => {
ready(() => {
const docsify = new Docsify()
// NOTE: I was not able to get it working with a callback, but polling works usually at the first time
const id = setInterval(() => {
if (dom.window.document.body.innerHTML.indexOf(NOT_INIT_PATTERN) == -1) {
clearInterval(id)
return resolve({
docsify: docsify,
dom: dom
})
}
}, 10)
// return cached version / TODO: see above: this might not scale, new instance of JSDOM is reqiured
if (docsify != null) {
return resolve(docsify)
}
ready(_ => {
docsify = new Docsify()
return resolve(docsify)
})
})

View file

@ -1,6 +0,0 @@
<!--
create your own fixture directory
if you need a custom README.md or sidebar
-->

View file

@ -1,18 +0,0 @@
# Heading
[another page](other.md)
## II 1
### III 1
#### IV 1
##### V 1
## II 2
### III 2
#### IV 2

View file

@ -1,16 +0,0 @@
# Other
## two 1
### three 1
#### four 1
##### five 1
## two 2
### three 2
#### four 2

View file

@ -1,14 +0,0 @@
const path = require('path')
const {expect} = require('chai')
const {init, expectSameDom} = require('../_helper')
describe('full docsify initialization', function() {
it('TODO: check generated markup', async function() {
const {docsify, dom} = await init('simple', {loadSidebar: true})
console.log(dom.window.document.body.innerHTML)
// TODO: add some expectations
})
})

View file

@ -1,14 +0,0 @@
const path = require('path')
const {expect} = require('chai')
const {init, expectSameDom} = require('../_helper')
describe('router', function() {
it('TODO: trigger to load another page', async function() {
const {docsify} = await init()
window.location = '/?foo=bar'
// TODO: add some expectations
})
})

View file

@ -2,18 +2,18 @@ const path = require('path')
const {expect} = require('chai')
const {init, expectSameDom} = require('../_helper')
const {init, expectSameDom} = require('./_helper')
describe('render', function() {
it('important content (tips)', async function() {
const {docsify, dom} = await init()
docsify = await init()
const output = docsify.compiler.compile('!> **Time** is money, my friend!')
expect(output).equal('<p class="tip"><strong>Time</strong> is money, my friend!</p>')
})
describe('lists', function() {
it('as unordered task list', async function() {
const {docsify, dom} = await init()
docsify = await init()
const output = docsify.compiler.compile(`
- [x] Task 1
- [ ] Task 2
@ -26,7 +26,7 @@ describe('render', function() {
})
it('as ordered task list', async function() {
const {docsify, dom} = await init()
docsify = await init()
const output = docsify.compiler.compile(`
1. [ ] Task 1
2. [x] Task 2`)
@ -37,7 +37,7 @@ describe('render', function() {
})
it('normal unordered', async function() {
const {docsify, dom} = await init()
docsify = await init()
const output = docsify.compiler.compile(`
- [linktext](link)
- just text`)
@ -48,7 +48,7 @@ describe('render', function() {
})
it('unordered with custom start', async function() {
const {docsify, dom} = await init()
docsify = await init()
const output = docsify.compiler.compile(`
1. first
2. second
@ -67,7 +67,7 @@ text
})
it('nested', async function() {
const {docsify, dom} = await init()
docsify = await init()
const output = docsify.compiler.compile(`
- 1
- 2

View file

@ -1,62 +0,0 @@
/* eslint-env node, chai, mocha */
require = require('esm')(module/*, options*/)
const {expect} = require('chai')
const {History} = require('../../src/core/router/history/base')
class MockHistory extends History {
parse(path) {
return {path}
}
}
describe('router/history/base', function () {
describe('relativePath true', function () {
var history
beforeEach(function () {
history = new MockHistory({relativePath: true})
})
it('toURL', function () {
// WHEN
const url = history.toURL('guide.md', {}, '/zh-ch/')
// THEN
expect(url).equal('/zh-ch/guide')
})
it('toURL with double dot', function () {
// WHEN
const url = history.toURL('../README.md', {}, '/zh-ch/')
// THEN
expect(url).equal('/README')
})
it('toURL child path', function () {
// WHEN
const url = history.toURL('config/example.md', {}, '/zh-ch/')
// THEN
expect(url).equal('/zh-ch/config/example')
})
it('toURL absolute path', function () {
// WHEN
const url = history.toURL('/README', {}, '/zh-ch/')
// THEN
expect(url).equal('/README')
})
})
it('toURL without relative path', function () {
const history = new MockHistory({relativePath: false})
// WHEN
const url = history.toURL('README', {}, '/zh-ch/')
// THEN
expect(url).equal('/README')
})
})

View file

@ -1,30 +0,0 @@
/* eslint-env node, chai, mocha */
require = require('esm')(module/*, options*/)
const {expect} = require('chai')
const {resolvePath} = require('../../src/core/router/util')
describe('router/util', function () {
it('resolvePath', async function () {
// WHEN
const result = resolvePath('hello.md')
// THEN
expect(result).equal('/hello.md')
})
it('resolvePath with dot', async function () {
// WHEN
const result = resolvePath('./hello.md')
// THEN
expect(result).equal('/hello.md')
})
it('resolvePath with two dots', async function () {
// WHEN
const result = resolvePath('test/../hello.md')
// THEN
expect(result).equal('/hello.md')
})
})

View file

@ -1 +0,0 @@