first commit
This commit is contained in:
7
node_modules/hexo-util/LICENSE
generated
vendored
Normal file
7
node_modules/hexo-util/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright (c) 2014 Tommy Chen
|
||||
|
||||
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.
|
||||
758
node_modules/hexo-util/README.md
generated
vendored
Normal file
758
node_modules/hexo-util/README.md
generated
vendored
Normal file
@@ -0,0 +1,758 @@
|
||||
# hexo-util
|
||||
|
||||
[](https://github.com/hexojs/hexo-util/actions?query=workflow%3ATester)
|
||||
[](https://www.npmjs.com/package/hexo-util)
|
||||
[](https://coveralls.io/github/hexojs/hexo-util?branch=master)
|
||||
|
||||
Utilities for [Hexo].
|
||||
|
||||
## Table of contents
|
||||
|
||||
- [Installation](#installation)
|
||||
- [Usage](#usage)
|
||||
- [Cache](#cache)
|
||||
- [CacheStream](#cachestream)
|
||||
- [camelCaseKeys](#camelcasekeysobj-options)
|
||||
- [createSha1Hash](#createsha1hash)
|
||||
- [decodeURL](#decodeurlstr)
|
||||
- [deepMerge](#deepmergetarget-source)
|
||||
- [encodeURL](#encodeurlstr)
|
||||
- [escapeDiacritic](#escapediacriticstr)
|
||||
- [escapeHTML](#escapehtmlstr)
|
||||
- [escapeRegex](#escaperegexstr)
|
||||
- [full_url_for](#full_url_forpath)
|
||||
- [gravatar](#gravatarstr-options)
|
||||
- [hash](#hashstr)
|
||||
- [highlight](#highlightstr-options)
|
||||
- [htmlTag](#htmltagtag-attrs-text-escape)
|
||||
- [isExternalLink](#isexternallinkurl-sitehost-exclude)
|
||||
- [Pattern](#patternrule)
|
||||
- [Permalink](#permalinkrule-options)
|
||||
- [prettyUrls](#prettyurlsurl-options)
|
||||
- [prismHighlight](#prismhighlightstr-options)
|
||||
- [relative_url](#relative_urlfrom-to)
|
||||
- [slugize](#slugizestr-options)
|
||||
- [spawn](#spawncommand-args-options)
|
||||
- [stripHTML](#striphtmlstr)
|
||||
- [wordWrap](#wordwrapstr-options)
|
||||
- [tocObj](#tocobjstr-options)
|
||||
- [truncate](#truncatestr-options)
|
||||
- [unescapeHTML](#unescapehtmlstr)
|
||||
- [url_for](#url_forpath-option)
|
||||
- [bind(hexo)](#bindhexo)
|
||||
|
||||
## Installation
|
||||
|
||||
``` bash
|
||||
$ npm install hexo-util --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
``` js
|
||||
var util = require('hexo-util');
|
||||
```
|
||||
|
||||
### Cache()
|
||||
|
||||
A simple plain object cache
|
||||
|
||||
``` js
|
||||
const cache = new Cache();
|
||||
|
||||
// set(key, value)
|
||||
cache.set('foo', 'bar');
|
||||
|
||||
// get(key) => value
|
||||
cache.get('foo');
|
||||
// 'bar'
|
||||
|
||||
// has(key) => Boolean
|
||||
cache.has('foo');
|
||||
// true
|
||||
cache.has('bar');
|
||||
// false
|
||||
|
||||
// apply(key. value)
|
||||
cache.apply('baz', () => 123);
|
||||
// 123
|
||||
cache.apply('baz', () => 456);
|
||||
// 123
|
||||
cache.apply('qux', 456);
|
||||
// 456
|
||||
cache.apply('qux', '789');
|
||||
// 456
|
||||
|
||||
// size()
|
||||
cache.size();
|
||||
// 3
|
||||
|
||||
// dump()
|
||||
cache.dump();
|
||||
/*
|
||||
{
|
||||
foo: 'bar',
|
||||
baz: 123,
|
||||
qux: 456
|
||||
}
|
||||
*/
|
||||
|
||||
// del(key)
|
||||
cache.del('baz');
|
||||
cache.has('baz');
|
||||
// false
|
||||
|
||||
// flush()
|
||||
cache.flush();
|
||||
cache.has('foo');
|
||||
// false
|
||||
cache.size();
|
||||
// 0
|
||||
```
|
||||
|
||||
### CacheStream()
|
||||
|
||||
Caches contents piped to the stream.
|
||||
|
||||
``` js
|
||||
var stream = new CacheStream();
|
||||
|
||||
fs.createReadStream('/path/to/file').pipe(stream);
|
||||
|
||||
stream.on('finish', function(){
|
||||
// Read cache piped to the stream
|
||||
console.log(stream.getCache());
|
||||
|
||||
// Destroy cache
|
||||
stream.destroy();
|
||||
});
|
||||
```
|
||||
|
||||
### camelCaseKeys(obj, options)
|
||||
|
||||
Convert object keys to camelCase. Original keys will be converted to getter/setter and sync to the camelCase keys.
|
||||
|
||||
``` js
|
||||
camelCaseKeys({
|
||||
foo_bar: 'test'
|
||||
});
|
||||
// { fooBar: 'test', foo_bar: 'test' }
|
||||
```
|
||||
|
||||
### createSha1Hash()
|
||||
return SHA1 hash object.
|
||||
This is the same as calling `createHash('utf8')` in the node.js native module crypto.
|
||||
``` js
|
||||
const sha1 = createSha1Hash();
|
||||
fs.createReadStream('/path/to/file')
|
||||
.pipe(sha1)
|
||||
.on('finish', () => {
|
||||
console.log(sha1.read());
|
||||
});
|
||||
```
|
||||
|
||||
### decodeURL(str)
|
||||
|
||||
Decode [encoded](https://en.wikipedia.org/wiki/Percent-encoding) URL or path. An alternative to the native [`decodeURI()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI) function, with added ability to decode [punycoded](https://en.wikipedia.org/wiki/Punycode) domain.
|
||||
|
||||
``` js
|
||||
decodeURL('http://foo.com/b%C3%A1r')
|
||||
// http://foo.com/bár
|
||||
|
||||
decodeURL('http://xn--br-mia.com/baz')
|
||||
// http://bár.com/baz
|
||||
|
||||
decodeURL('/foo/b%C3%A1r/')
|
||||
// /foo/bár/
|
||||
|
||||
/* Alternatively, Node 10+ offers native API to decode punycoded domain */
|
||||
const {format} = require('url')
|
||||
decodeURI(format(new URL('http://xn--br-mia.com.com/b%C3%A1r'), {unicode: true}))
|
||||
// http://bár.com/báz
|
||||
```
|
||||
|
||||
### deepMerge(target, source)
|
||||
|
||||
Merges the enumerable properties of two objects deeply. `target` and `source` remain untouched.
|
||||
|
||||
``` js
|
||||
// Merge deeply
|
||||
const obj1 = {a: {b: 1, c: 1, d: {e: 1, f: 1}}};
|
||||
const obj2 = {a: {b: 2, d: {f: 'f'} }};
|
||||
|
||||
deepMerge(obj1, obj2);
|
||||
// {a: {b: 2, c: 1, d: {e: 1, f: 'f'} }}
|
||||
```
|
||||
|
||||
``` js
|
||||
// Arrays will be combined in the same property, similar to lodash.merge
|
||||
const obj1 = { 'a': [{ 'b': 2 }, { 'd': 4 }] };
|
||||
const obj2 = { 'a': [{ 'c': 3 }, { 'e': 5 }] };
|
||||
|
||||
deepMerge(obj1, obj2);
|
||||
// { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] };
|
||||
```
|
||||
|
||||
### encodeURL(str)
|
||||
|
||||
Encode URL or path into a [safe format](https://en.wikipedia.org/wiki/Percent-encoding).
|
||||
|
||||
``` js
|
||||
encodeURL('http://foo.com/bár')
|
||||
// http://foo.com/b%C3%A1r
|
||||
|
||||
encodeURL('/foo/bár/')
|
||||
// /foo/b%C3%A1r/
|
||||
```
|
||||
|
||||
### escapeDiacritic(str)
|
||||
|
||||
Escapes diacritic characters in a string.
|
||||
|
||||
### escapeHTML(str)
|
||||
|
||||
Escapes HTML entities in a string.
|
||||
|
||||
``` js
|
||||
escapeHTML('<p>Hello "world".</p>')
|
||||
// <p>Hello "world".</p>
|
||||
|
||||
/* support escaped characters */
|
||||
escapeHTML('<foo>bar</foo>')
|
||||
// <foo>bar</foo>
|
||||
```
|
||||
|
||||
### escapeRegex(str)
|
||||
|
||||
Escapes special characters in a regular expression.
|
||||
|
||||
### full_url_for(path)
|
||||
|
||||
Returns a url with the config.url prefixed. Output is [encoded](#encodeurlstr) automatically. Requires [`bind(hexo)`](#bindhexo).
|
||||
|
||||
``` yml
|
||||
_config.yml
|
||||
url: https://example.com/blog # example
|
||||
```
|
||||
|
||||
``` js
|
||||
full_url_for('/a/path')
|
||||
// https://example.com/blog/a/path
|
||||
```
|
||||
|
||||
### gravatar(str, [options])
|
||||
|
||||
Returns the gravatar image url from an email.
|
||||
|
||||
If you didn't specify the [options] parameter, the default options will apply. Otherwise, you can set it to a number which will then be passed on as the size parameter to Gravatar. Finally, if you set it to an object, it will be converted into a query string of parameters for Gravatar.
|
||||
|
||||
Option | Description | Default
|
||||
--- | --- | ---
|
||||
`s` | Output image size | 80
|
||||
`d` | Default image |
|
||||
`f` | Force default |
|
||||
`r` | Rating |
|
||||
|
||||
More info: [Gravatar](https://en.gravatar.com/site/implement/images/)
|
||||
|
||||
``` js
|
||||
gravatar('a@abc.com')
|
||||
// https://www.gravatar.com/avatar/b9b00e66c6b8a70f88c73cb6bdb06787
|
||||
gravatar('a@abc.com', 40)
|
||||
// https://www.gravatar.com/avatar/b9b00e66c6b8a70f88c73cb6bdb06787?s=40
|
||||
gravatar('a@abc.com' {s: 40, d: 'https://via.placeholder.com/150'})
|
||||
// https://www.gravatar.com/avatar/b9b00e66c6b8a70f88c73cb6bdb06787?s=40&d=https%3A%2F%2Fvia.placeholder.com%2F150
|
||||
```
|
||||
|
||||
### hash(str)
|
||||
|
||||
Generates SHA1 hash.
|
||||
|
||||
``` js
|
||||
hash('123456');
|
||||
// <Buffer 7c 4a 8d 09 ca 37 62 af 61 e5 95 20 94 3d c2 64 94 f8 94 1b>
|
||||
```
|
||||
|
||||
### highlight(str, [options])
|
||||
|
||||
Syntax highlighting for a code block.
|
||||
|
||||
Option | Description | Default
|
||||
--- | --- | ---
|
||||
`gutter` | Whether to show line numbers | true
|
||||
`wrap` | Whether to wrap the code block in [`<table>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table) | true
|
||||
`firstLine` | First line number | 1
|
||||
`hljs` | Whether to use the `hljs-*` prefix for CSS classes | false
|
||||
`lang` | Language |
|
||||
`caption` | Caption |
|
||||
`tab`| Replace tabs |
|
||||
`autoDetect` | Detect language automatically (warning: slow)<br>_Sublanguage highlight requires `autoDetect` to be enabled and `lang` to be unset_ | false
|
||||
`mark` | Line highlight specific line(s) |
|
||||
`languageAttr` | Output code language into `data-language` attr | false
|
||||
`stripIndent`| Whether to strip leading whitespace via [strip-indent](https://www.npmjs.com/package/strip-indent) | true
|
||||
|
||||
### htmlTag(tag, attrs, text, escape)
|
||||
|
||||
Creates a html tag.
|
||||
|
||||
Option | Description | Default
|
||||
--- | --- | ---
|
||||
`tag` | Tag / element name |
|
||||
`attrs` | Attribute(s) and its value.<br>Value is always [escaped](#escapehtmlstr), URL is always [encoded](#encodeurlstr). |
|
||||
`text` | Text, the value is always escaped<br>_(except for `<style>` tag)_ |
|
||||
`escape` | Whether to escape the text | true
|
||||
|
||||
``` js
|
||||
htmlTag('img', {src: 'example.png'})
|
||||
// <img src="example.png">
|
||||
|
||||
htmlTag('a', {href: 'http://hexo.io/'}, 'Hexo')
|
||||
// <a href="http://hexo.io/">Hexo</a>
|
||||
|
||||
htmlTag('link', {href: 'http://foo.com/'}, '<a>bar</a>')
|
||||
// <a href="http://foo.com/"><bar></a>
|
||||
|
||||
htmlTag('a', {href: 'http://foo.com/'}, '<b>bold</b>', false)
|
||||
// <a href="http://foo.com/"><b>bold</b></a>
|
||||
|
||||
/* text value of <style> won't be escaped, url is still encoded */
|
||||
htmlTag('style', {}, 'p { content: "<"; background: url("bár.jpg"); }')
|
||||
// <style>p { content: "<"; background: url("b%C3%A1r.jpg"); }</style>
|
||||
|
||||
/* support script tag with async/defer */
|
||||
htmlTag('script', {src: '/foo.js', async: true}, '')
|
||||
// <script src="/foo.js" async></script>
|
||||
```
|
||||
|
||||
### isExternalLink(url, sitehost, [exclude])
|
||||
|
||||
Option | Description | Default
|
||||
--- | --- | ---
|
||||
`url` | The input URL. |
|
||||
`sitehost` | The hostname / url of website. You can also pass `hexo.config.url`. |
|
||||
`exclude` | Exclude hostnames. Specific subdomain is required when applicable, including www. | `[]`
|
||||
|
||||
Returns if a given url is external link relative to given `sitehost` and `[exclude]`.
|
||||
|
||||
``` js
|
||||
// 'sitehost' can be a domain or url
|
||||
isExternalLink('https://example.com', 'example.com');
|
||||
// false
|
||||
isExternalLink('https://example.com', 'https://example.com');
|
||||
// false
|
||||
isExternalLink('https://example.com', '//example.com/blog/');
|
||||
// false
|
||||
```
|
||||
|
||||
``` js
|
||||
isExternalLink('/archives/foo.html', 'example.com');
|
||||
// false
|
||||
isExternalLink('https://foo.com/', 'example.com');
|
||||
// true
|
||||
```
|
||||
|
||||
``` js
|
||||
isExternalLink('https://foo.com', 'example.com', ['foo.com', 'bar.com']);
|
||||
// false
|
||||
isExternalLink('https://bar.com', 'example.com', ['foo.com', 'bar.com']);
|
||||
// false
|
||||
isExternalLink('https://baz.com/', 'example.com', ['foo.com', 'bar.com']);
|
||||
// true
|
||||
```
|
||||
|
||||
|
||||
### Pattern(rule)
|
||||
|
||||
Parses the string and tests if the string matches the rule. `rule` can be a string, a regular expression or a function.
|
||||
|
||||
``` js
|
||||
var pattern = new Pattern('posts/:id');
|
||||
|
||||
pattern.match('posts/89');
|
||||
// {0: 'posts/89', 1: '89', id: '89'}
|
||||
```
|
||||
|
||||
``` js
|
||||
var pattern = new Pattern('posts/*path');
|
||||
|
||||
pattern.match('posts/2013/hello-world');
|
||||
// {0: 'posts/2013/hello-world', 1: '2013/hello-world', path: '2013/hello-world'}
|
||||
```
|
||||
|
||||
### Permalink(rule, [options])
|
||||
|
||||
Parses a permalink.
|
||||
|
||||
Option | Description
|
||||
--- | ---
|
||||
`segments` | Customize the rule of a segment in the permalink
|
||||
|
||||
``` js
|
||||
var permalink = new Permalink(':year/:month/:day/:title', {
|
||||
segments: {
|
||||
year: /(\d{4})/,
|
||||
month: /(\d{2})/,
|
||||
day: /(\d{2})/
|
||||
}
|
||||
});
|
||||
|
||||
permalink.parse('2014/01/31/test');
|
||||
// {year: '2014', month: '01', day: '31', title: 'test'}
|
||||
|
||||
permalink.test('2014/01/31/test');
|
||||
// true
|
||||
|
||||
permalink.stringify({year: '2014', month: '01', day: '31', title: 'test'})
|
||||
// 2014/01/31/test
|
||||
```
|
||||
|
||||
### prettyUrls(url, [options])
|
||||
|
||||
Rewrite urls to pretty URLs.
|
||||
|
||||
Option | Description | Default
|
||||
--- | --- | ---
|
||||
`trailing_index` | `/about/index.html -> /about/` when `false` | `true`
|
||||
`trailing_html` | `/about.html -> /about` when `false` | `true`
|
||||
|
||||
Note: `trailing_html` ignores any link with a trailing `index.html`. (will not be rewritten to `index`).
|
||||
|
||||
``` js
|
||||
prettyUrls('/foo/bar.html');
|
||||
// /foo/bar.html
|
||||
prettyUrls('/foo/bar/index.html');
|
||||
// /foo/bar/index.html
|
||||
|
||||
prettyUrls('/foo/bar.html', { trailing_index: false });
|
||||
// /foo/bar.html
|
||||
prettyUrls('/foo/bar/index.html', { trailing_index: false });
|
||||
// /foo/bar/
|
||||
|
||||
prettyUrls('/foo/bar.html', { trailing_html: false });
|
||||
// /foo/bar
|
||||
prettyUrls('/foo/bar/index.html', { trailing_html: false });
|
||||
// /foo/bar/index.html
|
||||
|
||||
prettyUrls('/foo/bar.html', { trailing_index: false, trailing_html: false });
|
||||
// /foo/bar
|
||||
prettyUrls('/foo/bar/index.html', { trailing_index: false, trailing_html: false });
|
||||
// /foo/bar/
|
||||
```
|
||||
|
||||
### prismHighlight(str, [options])
|
||||
|
||||
Syntax highlighting for a code block using PrismJS.
|
||||
|
||||
Option | Description | Default
|
||||
--- | --- | ---
|
||||
`lineNumber` | Whether to show line numbers | true
|
||||
`lang` | Language | `'none'`
|
||||
`tab`| Replace tabs |
|
||||
`isPreprocess` | Enable preprocess or not | true
|
||||
`mark` | Highlight specific line |
|
||||
`firstLine` | First line number |
|
||||
`caption` | Caption |
|
||||
`stripIndent`| Whether to strip leading whitespace via [strip-indent](https://www.npmjs.com/package/strip-indent) | true
|
||||
|
||||
|
||||
When `isPreprocess` is enabled, `prismHighlight()` will return PrismJS processed HTML snippet. Otherwise `str` will only be escaped and `prismHighlight()` will return the HTML snippet that is suitable for `prism.js` working in the Browser.
|
||||
|
||||
`mark` and `firstLine` options will have effect only when `isPreprocess` is disabled.
|
||||
|
||||
### relative_url(from, to)
|
||||
|
||||
Returns the relative URL from `from` to `to`. Output is [encoded](#encodeurlstr) automatically. Requires [`bind(hexo)`](#bindhexo).
|
||||
|
||||
``` js
|
||||
relative_url('foo/bar/', 'css/style.css')
|
||||
// ../../css/style.css
|
||||
```
|
||||
|
||||
### slugize(str, [options])
|
||||
|
||||
Transforms a string into a clean URL-friendly string.
|
||||
|
||||
Option | Description | Default
|
||||
--- | --- | ---
|
||||
`separator` | Separator | -
|
||||
`transform` | Transform the string into lower case (`1`) or upper case (`2`) |
|
||||
|
||||
``` js
|
||||
slugize('Hello World') = 'Hello-World'
|
||||
slugize('Hellô Wòrld') = 'Hello-World'
|
||||
slugize('Hello World', {separator: '_'}) = 'Hello_World'
|
||||
slugize('Hello World', {transform: 1}) = 'hello-world'
|
||||
slugize('Hello World', {transform: 2}) = 'HELLO-WORLD'
|
||||
```
|
||||
|
||||
### spawn(command, [args], [options])
|
||||
|
||||
Launches a new process with the given `command`. This method returns a promise.
|
||||
|
||||
Option | Description | Default
|
||||
--- | --- | ---
|
||||
`cwd` | Current working directory of the child process |
|
||||
`env` | Environment key-value pairs |
|
||||
`stdio` | Child's stdio configuration | `pipe`
|
||||
`detached` | The child will be a process group leader |
|
||||
`uid` | Sets the user identity of the process |
|
||||
`gid` | Sets the group identity of the process |
|
||||
`verbose` | Display messages on the console | `false`
|
||||
`encoding` | Sets the encoding of the output string | `utf8`
|
||||
|
||||
More info: [`child_process.spawn()`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)
|
||||
|
||||
``` js
|
||||
spawn('cat', 'test.txt').then((content) => {
|
||||
console.log(content);
|
||||
});
|
||||
|
||||
// $ cd "/target/folder"
|
||||
// $ cat "foo.txt" "bar.txt"
|
||||
spawn('cat', ['foo.txt', 'bar.txt'], { cwd: '/target/folder' }).then((content) => {
|
||||
console.log(content);
|
||||
});
|
||||
```
|
||||
|
||||
### stripHTML(str)
|
||||
|
||||
Removes HTML tags in a string.
|
||||
|
||||
### stripIndent(str)
|
||||
|
||||
Strip leading whitespace from each line in a string. The line with the least number of leading whitespace, ignoring empty lines, determines the number to remove. Useful for removing redundant indentation.
|
||||
|
||||
### wordWrap(str, [options])
|
||||
|
||||
Wraps the string no longer than line width. This method breaks on the first whitespace character that does not exceed line width.
|
||||
|
||||
Option | Description | Default
|
||||
--- | --- | ---
|
||||
`width` | Line width | 80
|
||||
|
||||
``` js
|
||||
wordWrap('Once upon a time')
|
||||
// Once upon a time
|
||||
|
||||
wordWrap('Once upon a time, in a kingdom called Far Far Away, a king fell ill, and finding a successor to the throne turned out to be more trouble than anyone could have imagined...')
|
||||
// Once upon a time, in a kingdom called Far Far Away, a king fell ill, and finding\na successor to the throne turned out to be more trouble than anyone could have\nimagined...
|
||||
|
||||
wordWrap('Once upon a time', {width: 8})
|
||||
// Once\nupon a\ntime
|
||||
|
||||
wordWrap('Once upon a time', {width: 1})
|
||||
// Once\nupon\na\ntime
|
||||
```
|
||||
|
||||
### tocObj(str, [options])
|
||||
|
||||
Generate a table of contents in JSON format based on the given html string. Headings with attribute `data-toc-unnumbered="true"` will be marked as unnumbered.
|
||||
|
||||
Option | Description | Default
|
||||
--- | --- | ---
|
||||
`min_depth` | The minimum level of TOC | 1
|
||||
`max_depth` | The maximum level of TOC | 6
|
||||
|
||||
|
||||
``` js
|
||||
const html = [
|
||||
'<h1 id="title_1">Title 1</h1>',
|
||||
'<div id="title_1_1"><h2>Title 1.1</h2></div>',
|
||||
'<h3 id="title_1_1_1">Title 1.1.1</h3>',
|
||||
'<h2 id="title_1_2">Title 1.2</h2>',
|
||||
'<h2 id="title_1_3">Title 1.3</h2>',
|
||||
'<h3 id="title_1_3_1">Title 1.3.1</h3>',
|
||||
'<h1 id="title_2">Title 2</h1>',
|
||||
'<h2 id="title_2_1">Title 2.1</h2>'
|
||||
].join('\n');
|
||||
|
||||
tocObj(html);
|
||||
/*
|
||||
[
|
||||
{ text: 'Title 1', id: 'title_1', level: 1 },
|
||||
{ text: 'Title 1.1', id: 'title_1_1', level: 2 },
|
||||
{ text: 'Title 1.1.1', id: 'title_1_1_1', level: 3 },
|
||||
{ text: 'Title 1.2', id: 'title_1_2', level: 2 },
|
||||
{ text: 'Title 1.3', id: 'title_1_3', level: 2 },
|
||||
{ text: 'Title 1.3.1', id: 'title_1_3_1', level: 3 },
|
||||
{ text: 'Title 2', id: 'title_2', level: 1 },
|
||||
{ text: 'Title 2.1', id: 'title_2_1', level: 2 },
|
||||
]
|
||||
*/
|
||||
|
||||
tocObj(html, { min_depth: 2 });
|
||||
/*
|
||||
[
|
||||
{ text: 'Title 1.1', id: 'title_1_1', level: 2 },
|
||||
{ text: 'Title 1.1.1', id: 'title_1_1_1', level: 3 },
|
||||
{ text: 'Title 1.2', id: 'title_1_2', level: 2 },
|
||||
{ text: 'Title 1.3', id: 'title_1_3', level: 2 },
|
||||
{ text: 'Title 1.3.1', id: 'title_1_3_1', level: 3 },
|
||||
{ text: 'Title 2.1', id: 'title_2_1', level: 2 },
|
||||
]
|
||||
*/
|
||||
|
||||
tocObj(html, { max_depth: 2 });
|
||||
/*
|
||||
[
|
||||
{ text: 'Title 1', id: 'title_1', level: 1 },
|
||||
{ text: 'Title 1.1', id: 'title_1_1', level: 2 },
|
||||
{ text: 'Title 1.2', id: 'title_1_2', level: 2 },
|
||||
{ text: 'Title 1.3', id: 'title_1_3', level: 2 },
|
||||
{ text: 'Title 2', id: 'title_2', level: 1 },
|
||||
{ text: 'Title 2.1', id: 'title_2_1', level: 2 },
|
||||
]
|
||||
*/
|
||||
|
||||
tocObj('<h1 id="reference" data-toc-unnumbered="true">Reference</h1>')
|
||||
/*
|
||||
[
|
||||
{ text: 'Reference', id: 'reference', level: 1, unnumbered: true }
|
||||
]
|
||||
*/
|
||||
```
|
||||
|
||||
### truncate(str, [options])
|
||||
|
||||
Truncates a given text after a given `length` if text is longer than `length`. The last characters will be replaced with the `omission` option for a total length not exceeding `length`.
|
||||
|
||||
Option | Description | Default
|
||||
--- | --- | ---
|
||||
`length` | Max length of the string | 30
|
||||
`omission` | Omission text | ...
|
||||
`separator` | truncate text at a natural break |
|
||||
|
||||
``` js
|
||||
truncate('Once upon a time in a world far far away')
|
||||
// "Once upon a time in a world..."
|
||||
|
||||
truncate('Once upon a time in a world far far away', {length: 17})
|
||||
// "Once upon a ti..."
|
||||
|
||||
truncate('Once upon a time in a world far far away', {length: 17, separator: ' '})
|
||||
// "Once upon a..."
|
||||
|
||||
truncate('And they found that many people were sleeping better.', {length: 25, omission: '... (continued)'})
|
||||
// "And they f... (continued)"
|
||||
```
|
||||
|
||||
### unescapeHTML(str)
|
||||
|
||||
Unescapes HTML entities in a string.
|
||||
|
||||
``` js
|
||||
unescapeHTML('<p>Hello "world".</p>')
|
||||
// <p>Hello "world".</p>
|
||||
```
|
||||
|
||||
### url_for(path, [option])
|
||||
|
||||
Returns a url with the root path prefixed. Output is [encoded](#encodeurlstr) automatically. Requires [`bind(hexo)`](#bindhexo).
|
||||
|
||||
Option | Description | Default
|
||||
--- | --- | ---
|
||||
`relative` | Output relative link | Value of `config.relative_link`
|
||||
|
||||
``` yml
|
||||
_config.yml
|
||||
root: /blog/ # example
|
||||
```
|
||||
|
||||
``` js
|
||||
url_for('/a/path')
|
||||
// /blog/a/path
|
||||
```
|
||||
|
||||
Relative link, follows `relative_link` option by default
|
||||
e.g. post/page path is '/foo/bar/index.html'
|
||||
|
||||
``` yml
|
||||
_config.yml
|
||||
relative_link: true
|
||||
```
|
||||
|
||||
``` js
|
||||
url_for('/css/style.css')
|
||||
// ../../css/style.css
|
||||
|
||||
/* Override option
|
||||
* you could also disable it to output a non-relative link,
|
||||
* even when `relative_link` is enabled and vice versa.
|
||||
*/
|
||||
url_for('/css/style.css', {relative: false})
|
||||
// /css/style.css
|
||||
```
|
||||
|
||||
## bind(hexo)
|
||||
|
||||
Following utilities require `bind(hexo)` / `bind(this)` / `call(hexo, input)` / `call(this, input)` to parse the user config when initializing:
|
||||
- [`full_url_for()`](#full_url_forpath)
|
||||
- [`url_for()`](#url_forpath)
|
||||
- [`relative_url()`](#relative_urlfrom-to)
|
||||
|
||||
Below examples demonstrate different approaches to creating a [helper](https://hexo.io/api/helper) (each example is separated by `/******/`),
|
||||
|
||||
``` js
|
||||
// Single function
|
||||
const url_for = require('hexo-util').url_for.bind(hexo);
|
||||
|
||||
hexo.extend.helper.register('test_url', (str) => {
|
||||
return url_for(str);
|
||||
})
|
||||
|
||||
|
||||
/******/
|
||||
// Multiple functions
|
||||
const url_for = require('hexo-util').url_for.bind(hexo)
|
||||
|
||||
function testurlHelper(str) {
|
||||
return url_for(str);
|
||||
}
|
||||
|
||||
hexo.extend.helper.register('test_url', testurlHelper);
|
||||
|
||||
|
||||
/******/
|
||||
// Functions separated into different files.
|
||||
// test_url.js
|
||||
module.exports = function(str) {
|
||||
const url_for = require('hexo-util').url_for.bind(this);
|
||||
return url_for(str);
|
||||
}
|
||||
|
||||
// index.js
|
||||
hexo.extend.helper.register('test_url', require('./test_url'));
|
||||
|
||||
|
||||
/******/
|
||||
// Function.call() approach also works
|
||||
const {url_for} = require('hexo-util');
|
||||
module.exports = function(str) {
|
||||
return url_for.call(this, str);
|
||||
}
|
||||
|
||||
hexo.extend.helper.register('test_url', require('./test_url'));
|
||||
|
||||
|
||||
/******/
|
||||
// Separating functions into individual files
|
||||
// Each file has multiple functions
|
||||
// test_url.js
|
||||
function testurlHelper(str) {
|
||||
const url_for = require('hexo-util').url_for.bind(this);
|
||||
return url_for(str);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
testurlHelper: testurlHelper
|
||||
}
|
||||
|
||||
// index.js
|
||||
hexo.extend.helper.register('test_url', require('./test_url').testurlHelper);
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
[Hexo]: http://hexo.io/
|
||||
16
node_modules/hexo-util/dist/cache.d.ts
generated
vendored
Normal file
16
node_modules/hexo-util/dist/cache.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
declare const _default: {
|
||||
new <T>(): {
|
||||
cache: Map<string, T>;
|
||||
set(id: string, value: T): void;
|
||||
has(id: string): boolean;
|
||||
get(id: string): T;
|
||||
del(id: string): void;
|
||||
apply(id: string, value: any): T;
|
||||
flush(): void;
|
||||
size(): number;
|
||||
dump(): {
|
||||
[k: string]: T;
|
||||
};
|
||||
};
|
||||
};
|
||||
export = _default;
|
||||
36
node_modules/hexo-util/dist/cache.js
generated
vendored
Normal file
36
node_modules/hexo-util/dist/cache.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
module.exports = class Cache {
|
||||
constructor() {
|
||||
this.cache = new Map();
|
||||
}
|
||||
set(id, value) {
|
||||
this.cache.set(id, value);
|
||||
}
|
||||
has(id) {
|
||||
return this.cache.has(id);
|
||||
}
|
||||
get(id) {
|
||||
return this.cache.get(id);
|
||||
}
|
||||
del(id) {
|
||||
this.cache.delete(id);
|
||||
}
|
||||
apply(id, value) {
|
||||
if (this.has(id))
|
||||
return this.get(id);
|
||||
if (typeof value === 'function')
|
||||
value = value();
|
||||
this.set(id, value);
|
||||
return value;
|
||||
}
|
||||
flush() {
|
||||
this.cache.clear();
|
||||
}
|
||||
size() {
|
||||
return this.cache.size;
|
||||
}
|
||||
dump() {
|
||||
return Object.fromEntries(this.cache);
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=cache.js.map
|
||||
1
node_modules/hexo-util/dist/cache.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/cache.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../lib/cache.ts"],"names":[],"mappings":";AAAA,iBAAS,MAAM,KAAK;IAGlB;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;IACzB,CAAC;IAED,GAAG,CAAC,EAAU,EAAE,KAAQ;QACtB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,GAAG,CAAC,EAAU;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED,GAAG,CAAC,EAAU;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED,GAAG,CAAC,EAAU;QACZ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,EAAU,EAAE,KAAK;QACrB,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAEtC,IAAI,OAAO,KAAK,KAAK,UAAU;YAAE,KAAK,GAAG,KAAK,EAAE,CAAC;QAEjD,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACpB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,IAAI;QACF,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;CACF,CAAC"}
|
||||
10
node_modules/hexo-util/dist/cache_stream.d.ts
generated
vendored
Normal file
10
node_modules/hexo-util/dist/cache_stream.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
import { Transform } from 'stream';
|
||||
declare class CacheStream extends Transform {
|
||||
_cache: Buffer[];
|
||||
constructor();
|
||||
_transform(chunk: any, enc: any, callback: any): void;
|
||||
getCache(): Buffer;
|
||||
}
|
||||
export = CacheStream;
|
||||
19
node_modules/hexo-util/dist/cache_stream.js
generated
vendored
Normal file
19
node_modules/hexo-util/dist/cache_stream.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
const stream_1 = require("stream");
|
||||
class CacheStream extends stream_1.Transform {
|
||||
constructor() {
|
||||
super();
|
||||
this._cache = [];
|
||||
}
|
||||
_transform(chunk, enc, callback) {
|
||||
const buf = chunk instanceof Buffer ? chunk : Buffer.from(chunk, enc);
|
||||
this._cache.push(buf);
|
||||
this.push(buf);
|
||||
callback();
|
||||
}
|
||||
getCache() {
|
||||
return Buffer.concat(this._cache);
|
||||
}
|
||||
}
|
||||
module.exports = CacheStream;
|
||||
//# sourceMappingURL=cache_stream.js.map
|
||||
1
node_modules/hexo-util/dist/cache_stream.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/cache_stream.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cache_stream.js","sourceRoot":"","sources":["../lib/cache_stream.ts"],"names":[],"mappings":";AAAA,mCAAmC;AAEnC,MAAM,WAAY,SAAQ,kBAAS;IAGjC;QACE,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAED,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ;QAC7B,MAAM,GAAG,GAAG,KAAK,YAAY,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACtE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACf,QAAQ,EAAE,CAAC;IACb,CAAC;IAED,QAAQ;QACN,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACF;AAED,iBAAS,WAAW,CAAC"}
|
||||
2
node_modules/hexo-util/dist/camel_case_keys.d.ts
generated
vendored
Normal file
2
node_modules/hexo-util/dist/camel_case_keys.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare function camelCaseKeys(obj: object): Record<string, any>;
|
||||
export = camelCaseKeys;
|
||||
42
node_modules/hexo-util/dist/camel_case_keys.js
generated
vendored
Normal file
42
node_modules/hexo-util/dist/camel_case_keys.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
const camel_case_1 = require("camel-case");
|
||||
function getter(key) {
|
||||
return function () {
|
||||
return this[key];
|
||||
};
|
||||
}
|
||||
function setter(key) {
|
||||
return function (value) {
|
||||
this[key] = value;
|
||||
};
|
||||
}
|
||||
function toCamelCase(str) {
|
||||
let prefixLength = -1;
|
||||
while (str[++prefixLength] === '_')
|
||||
;
|
||||
if (!prefixLength) {
|
||||
return (0, camel_case_1.camelCase)(str);
|
||||
}
|
||||
return str.substring(0, prefixLength) + (0, camel_case_1.camelCase)(str.substring(prefixLength));
|
||||
}
|
||||
function camelCaseKeys(obj) {
|
||||
if (typeof obj !== 'object')
|
||||
throw new TypeError('obj must be an object!');
|
||||
const keys = Object.keys(obj);
|
||||
const result = {};
|
||||
for (const oldKey of keys) {
|
||||
const newKey = toCamelCase(oldKey);
|
||||
result[newKey] = obj[oldKey];
|
||||
if (newKey !== oldKey) {
|
||||
Object.defineProperty(result, oldKey, {
|
||||
get: getter(newKey),
|
||||
set: setter(newKey),
|
||||
configurable: true,
|
||||
enumerable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
module.exports = camelCaseKeys;
|
||||
//# sourceMappingURL=camel_case_keys.js.map
|
||||
1
node_modules/hexo-util/dist/camel_case_keys.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/camel_case_keys.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"camel_case_keys.js","sourceRoot":"","sources":["../lib/camel_case_keys.ts"],"names":[],"mappings":";AAAA,2CAAuC;AAEvC,SAAS,MAAM,CAAC,GAAW;IACzB,OAAO;QACL,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CAAC,GAAW;IACzB,OAAO,UAAS,KAAK;QACnB,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;IAC9B,IAAI,YAAY,GAAG,CAAC,CAAC,CAAC;IAEtB,OAAO,GAAG,CAAC,EAAE,YAAY,CAAC,KAAK,GAAG;QAAC,CAAC;IAEpC,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO,IAAA,sBAAS,EAAC,GAAG,CAAC,CAAC;KACvB;IACD,OAAO,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,YAAY,CAAC,GAAG,IAAA,sBAAS,EAAC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC;AACjF,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,wBAAwB,CAAC,CAAC;IAE3E,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9B,MAAM,MAAM,GAAwB,EAAE,CAAC;IAEvC,KAAK,MAAM,MAAM,IAAI,IAAI,EAAE;QACzB,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;QAEnC,MAAM,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;QAE7B,IAAI,MAAM,KAAK,MAAM,EAAE;YACrB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE;gBACpC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC;gBACnB,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC;gBACnB,YAAY,EAAE,IAAI;gBAClB,UAAU,EAAE,IAAI;aACjB,CAAC,CAAC;SACJ;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,iBAAS,aAAa,CAAC"}
|
||||
27
node_modules/hexo-util/dist/color.d.ts
generated
vendored
Normal file
27
node_modules/hexo-util/dist/color.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
interface RGBA {
|
||||
r: number;
|
||||
g: number;
|
||||
b: number;
|
||||
a: number;
|
||||
}
|
||||
declare class Color {
|
||||
r: number;
|
||||
g: number;
|
||||
b: number;
|
||||
a: number;
|
||||
/**
|
||||
* @param {string|{ r: number; g: number; b: number; a: number;}} color
|
||||
*/
|
||||
constructor(color: string | Partial<RGBA>);
|
||||
/**
|
||||
* @param {string} color
|
||||
*/
|
||||
_parse(color: string): void;
|
||||
toString(): string;
|
||||
/**
|
||||
* @param {string|{ r: number; g: number; b: number; a: number;}} color
|
||||
* @param {number} ratio
|
||||
*/
|
||||
mix(color: RGBA, ratio: number): Color;
|
||||
}
|
||||
export = Color;
|
||||
305
node_modules/hexo-util/dist/color.js
generated
vendored
Normal file
305
node_modules/hexo-util/dist/color.js
generated
vendored
Normal file
@@ -0,0 +1,305 @@
|
||||
"use strict";
|
||||
// https://github.com/imathis/hsl-picker/blob/master/assets/javascripts/modules/color.coffee
|
||||
const rHex3 = /^#[0-9a-f]{3}$/;
|
||||
const rHex6 = /^#[0-9a-f]{6}$/;
|
||||
const rRGB = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,?\s*(0?\.?\d+)?\s*\)$/;
|
||||
const rHSL = /^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*,?\s*(0?\.?\d+)?\s*\)$/;
|
||||
// https://www.w3.org/TR/css3-color/#svg-color
|
||||
const colorNames = {
|
||||
aliceblue: { r: 240, g: 248, b: 255, a: 1 },
|
||||
antiquewhite: { r: 250, g: 235, b: 215, a: 1 },
|
||||
aqua: { r: 0, g: 255, b: 255, a: 1 },
|
||||
aquamarine: { r: 127, g: 255, b: 212, a: 1 },
|
||||
azure: { r: 240, g: 255, b: 255, a: 1 },
|
||||
beige: { r: 245, g: 245, b: 220, a: 1 },
|
||||
bisque: { r: 255, g: 228, b: 196, a: 1 },
|
||||
black: { r: 0, g: 0, b: 0, a: 1 },
|
||||
blanchedalmond: { r: 255, g: 235, b: 205, a: 1 },
|
||||
blue: { r: 0, g: 0, b: 255, a: 1 },
|
||||
blueviolet: { r: 138, g: 43, b: 226, a: 1 },
|
||||
brown: { r: 165, g: 42, b: 42, a: 1 },
|
||||
burlywood: { r: 222, g: 184, b: 135, a: 1 },
|
||||
cadetblue: { r: 95, g: 158, b: 160, a: 1 },
|
||||
chartreuse: { r: 127, g: 255, b: 0, a: 1 },
|
||||
chocolate: { r: 210, g: 105, b: 30, a: 1 },
|
||||
coral: { r: 255, g: 127, b: 80, a: 1 },
|
||||
cornflowerblue: { r: 100, g: 149, b: 237, a: 1 },
|
||||
cornsilk: { r: 255, g: 248, b: 220, a: 1 },
|
||||
crimson: { r: 220, g: 20, b: 60, a: 1 },
|
||||
cyan: { r: 0, g: 255, b: 255, a: 1 },
|
||||
darkblue: { r: 0, g: 0, b: 139, a: 1 },
|
||||
darkcyan: { r: 0, g: 139, b: 139, a: 1 },
|
||||
darkgoldenrod: { r: 184, g: 134, b: 11, a: 1 },
|
||||
darkgray: { r: 169, g: 169, b: 169, a: 1 },
|
||||
darkgreen: { r: 0, g: 100, b: 0, a: 1 },
|
||||
darkgrey: { r: 169, g: 169, b: 169, a: 1 },
|
||||
darkkhaki: { r: 189, g: 183, b: 107, a: 1 },
|
||||
darkmagenta: { r: 139, g: 0, b: 139, a: 1 },
|
||||
darkolivegreen: { r: 85, g: 107, b: 47, a: 1 },
|
||||
darkorange: { r: 255, g: 140, b: 0, a: 1 },
|
||||
darkorchid: { r: 153, g: 50, b: 204, a: 1 },
|
||||
darkred: { r: 139, g: 0, b: 0, a: 1 },
|
||||
darksalmon: { r: 233, g: 150, b: 122, a: 1 },
|
||||
darkseagreen: { r: 143, g: 188, b: 143, a: 1 },
|
||||
darkslateblue: { r: 72, g: 61, b: 139, a: 1 },
|
||||
darkslategray: { r: 47, g: 79, b: 79, a: 1 },
|
||||
darkslategrey: { r: 47, g: 79, b: 79, a: 1 },
|
||||
darkturquoise: { r: 0, g: 206, b: 209, a: 1 },
|
||||
darkviolet: { r: 148, g: 0, b: 211, a: 1 },
|
||||
deeppink: { r: 255, g: 20, b: 147, a: 1 },
|
||||
deepskyblue: { r: 0, g: 191, b: 255, a: 1 },
|
||||
dimgray: { r: 105, g: 105, b: 105, a: 1 },
|
||||
dimgrey: { r: 105, g: 105, b: 105, a: 1 },
|
||||
dodgerblue: { r: 30, g: 144, b: 255, a: 1 },
|
||||
firebrick: { r: 178, g: 34, b: 34, a: 1 },
|
||||
floralwhite: { r: 255, g: 250, b: 240, a: 1 },
|
||||
forestgreen: { r: 34, g: 139, b: 34, a: 1 },
|
||||
fuchsia: { r: 255, g: 0, b: 255, a: 1 },
|
||||
gainsboro: { r: 220, g: 220, b: 220, a: 1 },
|
||||
ghostwhite: { r: 248, g: 248, b: 255, a: 1 },
|
||||
gold: { r: 255, g: 215, b: 0, a: 1 },
|
||||
goldenrod: { r: 218, g: 165, b: 32, a: 1 },
|
||||
gray: { r: 128, g: 128, b: 128, a: 1 },
|
||||
green: { r: 0, g: 128, b: 0, a: 1 },
|
||||
greenyellow: { r: 173, g: 255, b: 47, a: 1 },
|
||||
grey: { r: 128, g: 128, b: 128, a: 1 },
|
||||
honeydew: { r: 240, g: 255, b: 240, a: 1 },
|
||||
hotpink: { r: 255, g: 105, b: 180, a: 1 },
|
||||
indianred: { r: 205, g: 92, b: 92, a: 1 },
|
||||
indigo: { r: 75, g: 0, b: 130, a: 1 },
|
||||
ivory: { r: 255, g: 255, b: 240, a: 1 },
|
||||
khaki: { r: 240, g: 230, b: 140, a: 1 },
|
||||
lavender: { r: 230, g: 230, b: 250, a: 1 },
|
||||
lavenderblush: { r: 255, g: 240, b: 245, a: 1 },
|
||||
lawngreen: { r: 124, g: 252, b: 0, a: 1 },
|
||||
lemonchiffon: { r: 255, g: 250, b: 205, a: 1 },
|
||||
lightblue: { r: 173, g: 216, b: 230, a: 1 },
|
||||
lightcoral: { r: 240, g: 128, b: 128, a: 1 },
|
||||
lightcyan: { r: 224, g: 255, b: 255, a: 1 },
|
||||
lightgoldenrodyellow: { r: 250, g: 250, b: 210, a: 1 },
|
||||
lightgray: { r: 211, g: 211, b: 211, a: 1 },
|
||||
lightgreen: { r: 144, g: 238, b: 144, a: 1 },
|
||||
lightgrey: { r: 211, g: 211, b: 211, a: 1 },
|
||||
lightpink: { r: 255, g: 182, b: 193, a: 1 },
|
||||
lightsalmon: { r: 255, g: 160, b: 122, a: 1 },
|
||||
lightseagreen: { r: 32, g: 178, b: 170, a: 1 },
|
||||
lightskyblue: { r: 135, g: 206, b: 250, a: 1 },
|
||||
lightslategray: { r: 119, g: 136, b: 153, a: 1 },
|
||||
lightslategrey: { r: 119, g: 136, b: 153, a: 1 },
|
||||
lightsteelblue: { r: 176, g: 196, b: 222, a: 1 },
|
||||
lightyellow: { r: 255, g: 255, b: 224, a: 1 },
|
||||
lime: { r: 0, g: 255, b: 0, a: 1 },
|
||||
limegreen: { r: 50, g: 205, b: 50, a: 1 },
|
||||
linen: { r: 250, g: 240, b: 230, a: 1 },
|
||||
magenta: { r: 255, g: 0, b: 255, a: 1 },
|
||||
maroon: { r: 128, g: 0, b: 0, a: 1 },
|
||||
mediumaquamarine: { r: 102, g: 205, b: 170, a: 1 },
|
||||
mediumblue: { r: 0, g: 0, b: 205, a: 1 },
|
||||
mediumorchid: { r: 186, g: 85, b: 211, a: 1 },
|
||||
mediumpurple: { r: 147, g: 112, b: 219, a: 1 },
|
||||
mediumseagreen: { r: 60, g: 179, b: 113, a: 1 },
|
||||
mediumslateblue: { r: 123, g: 104, b: 238, a: 1 },
|
||||
mediumspringgreen: { r: 0, g: 250, b: 154, a: 1 },
|
||||
mediumturquoise: { r: 72, g: 209, b: 204, a: 1 },
|
||||
mediumvioletred: { r: 199, g: 21, b: 133, a: 1 },
|
||||
midnightblue: { r: 25, g: 25, b: 112, a: 1 },
|
||||
mintcream: { r: 245, g: 255, b: 250, a: 1 },
|
||||
mistyrose: { r: 255, g: 228, b: 225, a: 1 },
|
||||
moccasin: { r: 255, g: 228, b: 181, a: 1 },
|
||||
navajowhite: { r: 255, g: 222, b: 173, a: 1 },
|
||||
navy: { r: 0, g: 0, b: 128, a: 1 },
|
||||
oldlace: { r: 253, g: 245, b: 230, a: 1 },
|
||||
olive: { r: 128, g: 128, b: 0, a: 1 },
|
||||
olivedrab: { r: 107, g: 142, b: 35, a: 1 },
|
||||
orange: { r: 255, g: 165, b: 0, a: 1 },
|
||||
orangered: { r: 255, g: 69, b: 0, a: 1 },
|
||||
orchid: { r: 218, g: 112, b: 214, a: 1 },
|
||||
palegoldenrod: { r: 238, g: 232, b: 170, a: 1 },
|
||||
palegreen: { r: 152, g: 251, b: 152, a: 1 },
|
||||
paleturquoise: { r: 175, g: 238, b: 238, a: 1 },
|
||||
palevioletred: { r: 219, g: 112, b: 147, a: 1 },
|
||||
papayawhip: { r: 255, g: 239, b: 213, a: 1 },
|
||||
peachpuff: { r: 255, g: 218, b: 185, a: 1 },
|
||||
peru: { r: 205, g: 133, b: 63, a: 1 },
|
||||
pink: { r: 255, g: 192, b: 203, a: 1 },
|
||||
plum: { r: 221, g: 160, b: 221, a: 1 },
|
||||
powderblue: { r: 176, g: 224, b: 230, a: 1 },
|
||||
purple: { r: 128, g: 0, b: 128, a: 1 },
|
||||
red: { r: 255, g: 0, b: 0, a: 1 },
|
||||
rosybrown: { r: 188, g: 143, b: 143, a: 1 },
|
||||
royalblue: { r: 65, g: 105, b: 225, a: 1 },
|
||||
saddlebrown: { r: 139, g: 69, b: 19, a: 1 },
|
||||
salmon: { r: 250, g: 128, b: 114, a: 1 },
|
||||
sandybrown: { r: 244, g: 164, b: 96, a: 1 },
|
||||
seagreen: { r: 46, g: 139, b: 87, a: 1 },
|
||||
seashell: { r: 255, g: 245, b: 238, a: 1 },
|
||||
sienna: { r: 160, g: 82, b: 45, a: 1 },
|
||||
silver: { r: 192, g: 192, b: 192, a: 1 },
|
||||
skyblue: { r: 135, g: 206, b: 235, a: 1 },
|
||||
slateblue: { r: 106, g: 90, b: 205, a: 1 },
|
||||
slategray: { r: 112, g: 128, b: 144, a: 1 },
|
||||
slategrey: { r: 112, g: 128, b: 144, a: 1 },
|
||||
snow: { r: 255, g: 250, b: 250, a: 1 },
|
||||
springgreen: { r: 0, g: 255, b: 127, a: 1 },
|
||||
steelblue: { r: 70, g: 130, b: 180, a: 1 },
|
||||
tan: { r: 210, g: 180, b: 140, a: 1 },
|
||||
teal: { r: 0, g: 128, b: 128, a: 1 },
|
||||
thistle: { r: 216, g: 191, b: 216, a: 1 },
|
||||
tomato: { r: 255, g: 99, b: 71, a: 1 },
|
||||
turquoise: { r: 64, g: 224, b: 208, a: 1 },
|
||||
violet: { r: 238, g: 130, b: 238, a: 1 },
|
||||
wheat: { r: 245, g: 222, b: 179, a: 1 },
|
||||
white: { r: 255, g: 255, b: 255, a: 1 },
|
||||
whitesmoke: { r: 245, g: 245, b: 245, a: 1 },
|
||||
yellow: { r: 255, g: 255, b: 0, a: 1 },
|
||||
yellowgreen: { r: 154, g: 205, b: 50, a: 1 }
|
||||
};
|
||||
const convertHue = (p, q, h) => {
|
||||
if (h < 0)
|
||||
h++;
|
||||
if (h > 1)
|
||||
h--;
|
||||
let color;
|
||||
if (h * 6 < 1) {
|
||||
color = p + ((q - p) * h * 6);
|
||||
}
|
||||
else if (h * 2 < 1) {
|
||||
color = q;
|
||||
}
|
||||
else if (h * 3 < 2) {
|
||||
color = p + ((q - p) * ((2 / 3) - h) * 6);
|
||||
}
|
||||
else {
|
||||
color = p;
|
||||
}
|
||||
return Math.round(color * 255);
|
||||
};
|
||||
const convertRGB = (value) => {
|
||||
const str = value.toString(16);
|
||||
if (value < 16)
|
||||
return `0${str}`;
|
||||
return str;
|
||||
};
|
||||
const mixValue = (a, b, ratio) => a + ((b - a) * ratio);
|
||||
class Color {
|
||||
/**
|
||||
* @param {string|{ r: number; g: number; b: number; a: number;}} color
|
||||
*/
|
||||
constructor(color) {
|
||||
if (typeof color === 'string') {
|
||||
this._parse(color);
|
||||
}
|
||||
else if (color != null && typeof color === 'object') {
|
||||
this.r = color.r | 0;
|
||||
this.g = color.g | 0;
|
||||
this.b = color.b | 0;
|
||||
this.a = +color.a;
|
||||
}
|
||||
else {
|
||||
throw new TypeError('color is required!');
|
||||
}
|
||||
if (this.r < 0 || this.r > 255
|
||||
|| this.g < 0 || this.g > 255
|
||||
|| this.b < 0 || this.b > 255
|
||||
|| this.a < 0 || this.a > 1) {
|
||||
throw new RangeError(`{r: ${this.r}, g: ${this.g}, b: ${this.b}, a: ${this.a}} is invalid.`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param {string} color
|
||||
*/
|
||||
_parse(color) {
|
||||
color = color.toLowerCase();
|
||||
if (Object.prototype.hasOwnProperty.call(colorNames, color)) {
|
||||
const obj = colorNames[color];
|
||||
this.r = obj.r;
|
||||
this.g = obj.g;
|
||||
this.b = obj.b;
|
||||
this.a = obj.a;
|
||||
return;
|
||||
}
|
||||
if (rHex3.test(color)) {
|
||||
const txt = color.substring(1);
|
||||
const code = parseInt(txt, 16);
|
||||
this.r = ((code & 0xF00) >> 8) * 17;
|
||||
this.g = ((code & 0xF0) >> 4) * 17;
|
||||
this.b = (code & 0xF) * 17;
|
||||
this.a = 1;
|
||||
return;
|
||||
}
|
||||
if (rHex6.test(color)) {
|
||||
const txt = color.substring(1);
|
||||
const code = parseInt(txt, 16);
|
||||
this.r = (code & 0xFF0000) >> 16;
|
||||
this.g = (code & 0xFF00) >> 8;
|
||||
this.b = code & 0xFF;
|
||||
this.a = 1;
|
||||
return;
|
||||
}
|
||||
let match = color.match(rRGB);
|
||||
if (match) {
|
||||
this.r = Number(match[1]) | 0;
|
||||
this.g = Number(match[2]) | 0;
|
||||
this.b = Number(match[3]) | 0;
|
||||
this.a = match[4] ? +match[4] : 1;
|
||||
return;
|
||||
}
|
||||
match = color.match(rHSL);
|
||||
if (match) {
|
||||
const h = +match[1] / 360;
|
||||
const s = +match[2] / 100;
|
||||
const l = +match[3] / 100;
|
||||
this.a = match[4] ? +match[4] : 1;
|
||||
if (!s) {
|
||||
this.r = l * 255;
|
||||
this.g = this.r;
|
||||
this.b = this.r;
|
||||
}
|
||||
const q = l < 0.5 ? l * (1 + s) : l + s - (l * s);
|
||||
const p = (2 * l) - q;
|
||||
const rt = h + (1 / 3);
|
||||
const gt = h;
|
||||
const bt = h - (1 / 3);
|
||||
this.r = convertHue(p, q, rt);
|
||||
this.g = convertHue(p, q, gt);
|
||||
this.b = convertHue(p, q, bt);
|
||||
return;
|
||||
}
|
||||
throw new Error(`${color} is not a supported color format.`);
|
||||
}
|
||||
toString() {
|
||||
if (this.a === 1) {
|
||||
const r = convertRGB(this.r);
|
||||
const g = convertRGB(this.g);
|
||||
const b = convertRGB(this.b);
|
||||
if (this.r % 17 || this.g % 17 || this.b % 17) {
|
||||
return `#${r}${g}${b}`;
|
||||
}
|
||||
return `#${r[0]}${g[0]}${b[0]}`;
|
||||
}
|
||||
return `rgba(${this.r}, ${this.g}, ${this.b}, ${parseFloat(this.a.toFixed(2))})`;
|
||||
}
|
||||
/**
|
||||
* @param {string|{ r: number; g: number; b: number; a: number;}} color
|
||||
* @param {number} ratio
|
||||
*/
|
||||
mix(color, ratio) {
|
||||
if (ratio > 1 || ratio < 0) {
|
||||
throw new RangeError('Valid numbers is only between 0 and 1.');
|
||||
}
|
||||
switch (ratio) {
|
||||
case 0:
|
||||
return new Color(this);
|
||||
case 1:
|
||||
return new Color(color);
|
||||
}
|
||||
return new Color({
|
||||
r: Math.round(mixValue(this.r, color.r, ratio)),
|
||||
g: Math.round(mixValue(this.g, color.g, ratio)),
|
||||
b: Math.round(mixValue(this.b, color.b, ratio)),
|
||||
a: mixValue(this.a, color.a, ratio)
|
||||
});
|
||||
}
|
||||
}
|
||||
module.exports = Color;
|
||||
//# sourceMappingURL=color.js.map
|
||||
1
node_modules/hexo-util/dist/color.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/color.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/hexo-util/dist/decode_url.d.ts
generated
vendored
Normal file
2
node_modules/hexo-util/dist/decode_url.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare const decodeURL: (str: string) => string;
|
||||
export = decodeURL;
|
||||
16
node_modules/hexo-util/dist/decode_url.js
generated
vendored
Normal file
16
node_modules/hexo-util/dist/decode_url.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
const url_1 = require("url");
|
||||
const querystring_1 = require("querystring");
|
||||
const decodeURL = (str) => {
|
||||
if ((0, url_1.parse)(str).protocol) {
|
||||
const parsed = new URL(str);
|
||||
// Exit if input is a data url
|
||||
if (parsed.origin === 'null')
|
||||
return str;
|
||||
const url = (0, url_1.format)(parsed, { unicode: true });
|
||||
return (0, querystring_1.unescape)(url);
|
||||
}
|
||||
return (0, querystring_1.unescape)(str);
|
||||
};
|
||||
module.exports = decodeURL;
|
||||
//# sourceMappingURL=decode_url.js.map
|
||||
1
node_modules/hexo-util/dist/decode_url.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/decode_url.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"decode_url.js","sourceRoot":"","sources":["../lib/decode_url.ts"],"names":[],"mappings":";AAAA,6BAAoC;AACpC,6CAAuC;AAEvC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE;IAChC,IAAI,IAAA,WAAK,EAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;QACvB,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAE5B,8BAA8B;QAC9B,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM;YAAE,OAAO,GAAG,CAAC;QAEzC,MAAM,GAAG,GAAG,IAAA,YAAM,EAAC,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,OAAO,IAAA,sBAAQ,EAAC,GAAG,CAAC,CAAC;KACtB;IAED,OAAO,IAAA,sBAAQ,EAAC,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC;AAEF,iBAAS,SAAS,CAAC"}
|
||||
2
node_modules/hexo-util/dist/deep_merge.d.ts
generated
vendored
Normal file
2
node_modules/hexo-util/dist/deep_merge.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare function deepMerge<T>(target: Partial<T>, source: Partial<T>): T;
|
||||
export = deepMerge;
|
||||
25
node_modules/hexo-util/dist/deep_merge.js
generated
vendored
Normal file
25
node_modules/hexo-util/dist/deep_merge.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const deepmerge_1 = __importDefault(require("deepmerge"));
|
||||
const arrayMerge = (target, source, options) => {
|
||||
const destination = target.slice();
|
||||
source.forEach((item, index) => {
|
||||
if (typeof destination[index] === 'undefined') {
|
||||
destination[index] = options.cloneUnlessOtherwiseSpecified(item, options);
|
||||
}
|
||||
else if (options.isMergeableObject(item)) {
|
||||
destination[index] = (0, deepmerge_1.default)(target[index], item, options);
|
||||
}
|
||||
else if (!target.includes(item)) {
|
||||
destination.push(item);
|
||||
}
|
||||
});
|
||||
return destination;
|
||||
};
|
||||
function deepMerge(target, source) {
|
||||
return (0, deepmerge_1.default)(target, source, { arrayMerge });
|
||||
}
|
||||
module.exports = deepMerge;
|
||||
//# sourceMappingURL=deep_merge.js.map
|
||||
1
node_modules/hexo-util/dist/deep_merge.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/deep_merge.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"deep_merge.js","sourceRoot":"","sources":["../lib/deep_merge.ts"],"names":[],"mappings":";;;;AAAA,0DAAkC;AAElC,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;IAC7C,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;IAEnC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC7B,IAAI,OAAO,WAAW,CAAC,KAAK,CAAC,KAAK,WAAW,EAAE;YAC7C,WAAW,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,6BAA6B,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;SAC3E;aAAM,IAAI,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE;YAC1C,WAAW,CAAC,KAAK,CAAC,GAAG,IAAA,mBAAS,EAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;SAC9D;aAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACjC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACxB;IACH,CAAC,CAAC,CAAC;IACH,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,SAAS,SAAS,CAAI,MAAkB,EAAE,MAAkB;IAC1D,OAAO,IAAA,mBAAS,EAAC,MAAM,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,iBAAS,SAAS,CAAC"}
|
||||
2
node_modules/hexo-util/dist/encode_url.d.ts
generated
vendored
Normal file
2
node_modules/hexo-util/dist/encode_url.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare const encodeURL: (str: string) => string;
|
||||
export = encodeURL;
|
||||
17
node_modules/hexo-util/dist/encode_url.js
generated
vendored
Normal file
17
node_modules/hexo-util/dist/encode_url.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
const url_1 = require("url");
|
||||
const querystring_1 = require("querystring");
|
||||
const encodeURL = (str) => {
|
||||
if ((0, url_1.parse)(str).protocol) {
|
||||
const parsed = new URL(str);
|
||||
// Exit if input is a data url
|
||||
if (parsed.origin === 'null')
|
||||
return str;
|
||||
parsed.search = encodeURI((0, querystring_1.unescape)(parsed.search));
|
||||
// preserve IDN
|
||||
return (0, url_1.format)(parsed, { unicode: true });
|
||||
}
|
||||
return encodeURI((0, querystring_1.unescape)(str));
|
||||
};
|
||||
module.exports = encodeURL;
|
||||
//# sourceMappingURL=encode_url.js.map
|
||||
1
node_modules/hexo-util/dist/encode_url.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/encode_url.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"encode_url.js","sourceRoot":"","sources":["../lib/encode_url.ts"],"names":[],"mappings":";AAAA,6BAAoC;AACpC,6CAAuC;AAEvC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE;IAChC,IAAI,IAAA,WAAK,EAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;QACvB,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAE5B,8BAA8B;QAC9B,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM;YAAE,OAAO,GAAG,CAAC;QAEzC,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC,IAAA,sBAAQ,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QACnD,eAAe;QACf,OAAO,IAAA,YAAM,EAAC,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;KAC1C;IAED,OAAO,SAAS,CAAC,IAAA,sBAAQ,EAAC,GAAG,CAAC,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF,iBAAS,SAAS,CAAC"}
|
||||
2
node_modules/hexo-util/dist/escape_diacritic.d.ts
generated
vendored
Normal file
2
node_modules/hexo-util/dist/escape_diacritic.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare function escapeDiacritic(str: string): string;
|
||||
export = escapeDiacritic;
|
||||
105
node_modules/hexo-util/dist/escape_diacritic.js
generated
vendored
Normal file
105
node_modules/hexo-util/dist/escape_diacritic.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
"use strict";
|
||||
const defaultDiacriticsRemovalap = [
|
||||
{ 'base': 'A', 'letters': '\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F' },
|
||||
{ 'base': 'AA', 'letters': '\uA732' },
|
||||
{ 'base': 'AE', 'letters': '\u00C6\u01FC\u01E2' },
|
||||
{ 'base': 'AO', 'letters': '\uA734' },
|
||||
{ 'base': 'AU', 'letters': '\uA736' },
|
||||
{ 'base': 'AV', 'letters': '\uA738\uA73A' },
|
||||
{ 'base': 'AY', 'letters': '\uA73C' },
|
||||
{ 'base': 'B', 'letters': '\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181' },
|
||||
{ 'base': 'C', 'letters': '\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E' },
|
||||
{ 'base': 'D', 'letters': '\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779' },
|
||||
{ 'base': 'DZ', 'letters': '\u01F1\u01C4' },
|
||||
{ 'base': 'Dz', 'letters': '\u01F2\u01C5' },
|
||||
{ 'base': 'E', 'letters': '\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E' },
|
||||
{ 'base': 'F', 'letters': '\u0046\u24BB\uFF26\u1E1E\u0191\uA77B' },
|
||||
{ 'base': 'G', 'letters': '\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E' },
|
||||
{ 'base': 'H', 'letters': '\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D' },
|
||||
{ 'base': 'I', 'letters': '\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197' },
|
||||
{ 'base': 'J', 'letters': '\u004A\u24BF\uFF2A\u0134\u0248' },
|
||||
{ 'base': 'K', 'letters': '\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2' },
|
||||
{ 'base': 'L', 'letters': '\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780' },
|
||||
{ 'base': 'LJ', 'letters': '\u01C7' },
|
||||
{ 'base': 'Lj', 'letters': '\u01C8' },
|
||||
{ 'base': 'M', 'letters': '\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C' },
|
||||
{ 'base': 'N', 'letters': '\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4' },
|
||||
{ 'base': 'NJ', 'letters': '\u01CA' },
|
||||
{ 'base': 'Nj', 'letters': '\u01CB' },
|
||||
{ 'base': 'O', 'letters': '\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C' },
|
||||
{ 'base': 'OI', 'letters': '\u01A2' },
|
||||
{ 'base': 'OO', 'letters': '\uA74E' },
|
||||
{ 'base': 'OU', 'letters': '\u0222' },
|
||||
{ 'base': 'OE', 'letters': '\u008C\u0152' },
|
||||
{ 'base': 'oe', 'letters': '\u009C\u0153' },
|
||||
{ 'base': 'P', 'letters': '\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754' },
|
||||
{ 'base': 'Q', 'letters': '\u0051\u24C6\uFF31\uA756\uA758\u024A' },
|
||||
{ 'base': 'R', 'letters': '\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782' },
|
||||
{ 'base': 'S', 'letters': '\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784' },
|
||||
{ 'base': 'T', 'letters': '\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786' },
|
||||
{ 'base': 'TZ', 'letters': '\uA728' },
|
||||
{ 'base': 'U', 'letters': '\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244' },
|
||||
{ 'base': 'V', 'letters': '\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245' },
|
||||
{ 'base': 'VY', 'letters': '\uA760' },
|
||||
{ 'base': 'W', 'letters': '\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72' },
|
||||
{ 'base': 'X', 'letters': '\u0058\u24CD\uFF38\u1E8A\u1E8C' },
|
||||
{ 'base': 'Y', 'letters': '\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE' },
|
||||
{ 'base': 'Z', 'letters': '\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762' },
|
||||
{ 'base': 'a', 'letters': '\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250' },
|
||||
{ 'base': 'aa', 'letters': '\uA733' },
|
||||
{ 'base': 'ae', 'letters': '\u00E6\u01FD\u01E3' },
|
||||
{ 'base': 'ao', 'letters': '\uA735' },
|
||||
{ 'base': 'au', 'letters': '\uA737' },
|
||||
{ 'base': 'av', 'letters': '\uA739\uA73B' },
|
||||
{ 'base': 'ay', 'letters': '\uA73D' },
|
||||
{ 'base': 'b', 'letters': '\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253' },
|
||||
{ 'base': 'c', 'letters': '\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184' },
|
||||
{ 'base': 'd', 'letters': '\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A' },
|
||||
{ 'base': 'dz', 'letters': '\u01F3\u01C6' },
|
||||
{ 'base': 'e', 'letters': '\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD' },
|
||||
{ 'base': 'f', 'letters': '\u0066\u24D5\uFF46\u1E1F\u0192\uA77C' },
|
||||
{ 'base': 'g', 'letters': '\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F' },
|
||||
{ 'base': 'h', 'letters': '\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265' },
|
||||
{ 'base': 'hv', 'letters': '\u0195' },
|
||||
{ 'base': 'i', 'letters': '\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131' },
|
||||
{ 'base': 'j', 'letters': '\u006A\u24D9\uFF4A\u0135\u01F0\u0249' },
|
||||
{ 'base': 'k', 'letters': '\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3' },
|
||||
{ 'base': 'l', 'letters': '\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747' },
|
||||
{ 'base': 'lj', 'letters': '\u01C9' },
|
||||
{ 'base': 'm', 'letters': '\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F' },
|
||||
{ 'base': 'n', 'letters': '\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5' },
|
||||
{ 'base': 'nj', 'letters': '\u01CC' },
|
||||
{ 'base': 'o', 'letters': '\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275' },
|
||||
{ 'base': 'oi', 'letters': '\u01A3' },
|
||||
{ 'base': 'ou', 'letters': '\u0223' },
|
||||
{ 'base': 'oo', 'letters': '\uA74F' },
|
||||
{ 'base': 'p', 'letters': '\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755' },
|
||||
{ 'base': 'q', 'letters': '\u0071\u24E0\uFF51\u024B\uA757\uA759' },
|
||||
{ 'base': 'r', 'letters': '\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783' },
|
||||
{ 'base': 's', 'letters': '\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B' },
|
||||
{ 'base': 't', 'letters': '\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787' },
|
||||
{ 'base': 'tz', 'letters': '\uA729' },
|
||||
{ 'base': 'u', 'letters': '\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289' },
|
||||
{ 'base': 'v', 'letters': '\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C' },
|
||||
{ 'base': 'vy', 'letters': '\uA761' },
|
||||
{ 'base': 'w', 'letters': '\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73' },
|
||||
{ 'base': 'x', 'letters': '\u0078\u24E7\uFF58\u1E8B\u1E8D' },
|
||||
{ 'base': 'y', 'letters': '\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF' },
|
||||
{ 'base': 'z', 'letters': '\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763' }
|
||||
];
|
||||
const diacriticsMap = {};
|
||||
for (const i of defaultDiacriticsRemovalap) {
|
||||
const letters = i.letters.split('');
|
||||
for (const letter of letters) {
|
||||
diacriticsMap[letter] = i.base;
|
||||
}
|
||||
}
|
||||
function escapeDiacritic(str) {
|
||||
if (typeof str !== 'string')
|
||||
throw new TypeError('str must be a string!');
|
||||
// http://stackoverflow.com/a/18391901
|
||||
// eslint-disable-next-line no-control-regex
|
||||
return str.replace(/[^\u0000-\u007E]/g, a => diacriticsMap[a] || a);
|
||||
}
|
||||
module.exports = escapeDiacritic;
|
||||
//# sourceMappingURL=escape_diacritic.js.map
|
||||
1
node_modules/hexo-util/dist/escape_diacritic.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/escape_diacritic.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/hexo-util/dist/escape_html.d.ts
generated
vendored
Normal file
2
node_modules/hexo-util/dist/escape_html.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare function escapeHTML(str: string): string;
|
||||
export = escapeHTML;
|
||||
25
node_modules/hexo-util/dist/escape_html.js
generated
vendored
Normal file
25
node_modules/hexo-util/dist/escape_html.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
const escapeTestNoEncode = /[<>"'`/=]|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
|
||||
const escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, 'g');
|
||||
const escapeReplacements = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
'\'': ''',
|
||||
'`': '`',
|
||||
'/': '/',
|
||||
'=': '='
|
||||
};
|
||||
const getEscapeReplacement = (ch) => escapeReplacements[ch];
|
||||
function escapeHTML(str) {
|
||||
if (typeof str !== 'string')
|
||||
throw new TypeError('str must be a string!');
|
||||
// https://github.com/markedjs/marked/blob/master/src/helpers.js
|
||||
if (escapeTestNoEncode.test(str)) {
|
||||
return str.replace(escapeReplaceNoEncode, getEscapeReplacement);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
module.exports = escapeHTML;
|
||||
//# sourceMappingURL=escape_html.js.map
|
||||
1
node_modules/hexo-util/dist/escape_html.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/escape_html.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"escape_html.js","sourceRoot":"","sources":["../lib/escape_html.ts"],"names":[],"mappings":";AAAA,MAAM,kBAAkB,GAAG,sDAAsD,CAAC;AAClF,MAAM,qBAAqB,GAAG,IAAI,MAAM,CAAC,kBAAkB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACzE,MAAM,kBAAkB,GAAG;IACzB,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,QAAQ;IACb,IAAI,EAAE,OAAO;IACb,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,QAAQ;CACd,CAAC;AACF,MAAM,oBAAoB,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;AAEpE,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,uBAAuB,CAAC,CAAC;IAE1E,gEAAgE;IAChE,IAAI,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAChC,OAAO,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,oBAAoB,CAAC,CAAC;KACjE;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,iBAAS,UAAU,CAAC"}
|
||||
2
node_modules/hexo-util/dist/escape_regexp.d.ts
generated
vendored
Normal file
2
node_modules/hexo-util/dist/escape_regexp.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare function escapeRegExp(str: string): string;
|
||||
export = escapeRegExp;
|
||||
9
node_modules/hexo-util/dist/escape_regexp.js
generated
vendored
Normal file
9
node_modules/hexo-util/dist/escape_regexp.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
function escapeRegExp(str) {
|
||||
if (typeof str !== 'string')
|
||||
throw new TypeError('str must be a string!');
|
||||
// http://stackoverflow.com/a/6969486
|
||||
return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
|
||||
}
|
||||
module.exports = escapeRegExp;
|
||||
//# sourceMappingURL=escape_regexp.js.map
|
||||
1
node_modules/hexo-util/dist/escape_regexp.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/escape_regexp.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"escape_regexp.js","sourceRoot":"","sources":["../lib/escape_regexp.ts"],"names":[],"mappings":";AAAA,SAAS,YAAY,CAAC,GAAW;IAC/B,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,uBAAuB,CAAC,CAAC;IAE1E,qCAAqC;IACrC,OAAO,GAAG,CAAC,OAAO,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC;AAED,iBAAS,YAAY,CAAC"}
|
||||
2
node_modules/hexo-util/dist/full_url_for.d.ts
generated
vendored
Normal file
2
node_modules/hexo-util/dist/full_url_for.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare function fullUrlForHelper(path?: string): string;
|
||||
export = fullUrlForHelper;
|
||||
31
node_modules/hexo-util/dist/full_url_for.js
generated
vendored
Normal file
31
node_modules/hexo-util/dist/full_url_for.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const url_1 = require("url");
|
||||
const encode_url_1 = __importDefault(require("./encode_url"));
|
||||
const pretty_urls_1 = __importDefault(require("./pretty_urls"));
|
||||
const cache_1 = __importDefault(require("./cache"));
|
||||
const cache = new cache_1.default();
|
||||
function fullUrlForHelper(path = '/') {
|
||||
const { config } = this;
|
||||
const prettyUrlsOptions = Object.assign({
|
||||
trailing_index: true,
|
||||
trailing_html: true
|
||||
}, config.pretty_urls);
|
||||
// cacheId is designed to works across different hexo.config & options
|
||||
return cache.apply(`${config.url}-${prettyUrlsOptions.trailing_index}-${prettyUrlsOptions.trailing_html}-${path}`, () => {
|
||||
if (/^(\/\/|http(s)?:)/.test(path))
|
||||
return path;
|
||||
const sitehost = (0, url_1.parse)(config.url).hostname || config.url;
|
||||
const data = new URL(path, `http://${sitehost}`);
|
||||
// Exit if input is an external link or a data url
|
||||
if (data.hostname !== sitehost || data.origin === 'null')
|
||||
return path;
|
||||
path = (0, encode_url_1.default)(config.url + `/${path}`.replace(/\/{2,}/g, '/'));
|
||||
path = (0, pretty_urls_1.default)(path, prettyUrlsOptions);
|
||||
return path;
|
||||
});
|
||||
}
|
||||
module.exports = fullUrlForHelper;
|
||||
//# sourceMappingURL=full_url_for.js.map
|
||||
1
node_modules/hexo-util/dist/full_url_for.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/full_url_for.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"full_url_for.js","sourceRoot":"","sources":["../lib/full_url_for.ts"],"names":[],"mappings":";;;;AAAA,6BAA4B;AAC5B,8DAAqC;AACrC,gEAAuC;AACvC,oDAA4B;AAC5B,MAAM,KAAK,GAAG,IAAI,eAAK,EAAU,CAAC;AAElC,SAAS,gBAAgB,CAAC,IAAI,GAAG,GAAG;IAClC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxB,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;QACtC,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,IAAI;KACpB,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAEvB,sEAAsE;IACtE,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,GAAG,IAAI,iBAAiB,CAAC,cAAc,IAAI,iBAAiB,CAAC,aAAa,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE;QACtH,IAAI,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QAEhD,MAAM,QAAQ,GAAG,IAAA,WAAK,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,IAAI,MAAM,CAAC,GAAG,CAAC;QAC1D,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,UAAU,QAAQ,EAAE,CAAC,CAAC;QAEjD,kDAAkD;QAClD,IAAI,IAAI,CAAC,QAAQ,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM;YAAE,OAAO,IAAI,CAAC;QAEtE,IAAI,GAAG,IAAA,oBAAS,EAAC,MAAM,CAAC,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC;QAClE,IAAI,GAAG,IAAA,qBAAU,EAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;QAE3C,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED,iBAAS,gBAAgB,CAAC"}
|
||||
4
node_modules/hexo-util/dist/gravatar.d.ts
generated
vendored
Normal file
4
node_modules/hexo-util/dist/gravatar.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/// <reference types="node" />
|
||||
import { ParsedUrlQueryInput } from 'querystring';
|
||||
declare function gravatarHelper(email: string, options?: ParsedUrlQueryInput | number): string;
|
||||
export = gravatarHelper;
|
||||
25
node_modules/hexo-util/dist/gravatar.js
generated
vendored
Normal file
25
node_modules/hexo-util/dist/gravatar.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const crypto_1 = require("crypto");
|
||||
const querystring_1 = require("querystring");
|
||||
const cache_1 = __importDefault(require("./cache"));
|
||||
const cache = new cache_1.default();
|
||||
function md5(str) {
|
||||
return (0, crypto_1.createHash)('md5').update(str).digest('hex');
|
||||
}
|
||||
function gravatarHelper(email, options) {
|
||||
if (typeof options === 'number') {
|
||||
options = { s: options };
|
||||
}
|
||||
const hash = cache.has(email) ? cache.get(email) : md5(email.toLowerCase());
|
||||
let str = `https://www.gravatar.com/avatar/${hash}`;
|
||||
const qs = (0, querystring_1.stringify)(options);
|
||||
if (qs)
|
||||
str += `?${qs}`;
|
||||
cache.set('email', hash);
|
||||
return str;
|
||||
}
|
||||
module.exports = gravatarHelper;
|
||||
//# sourceMappingURL=gravatar.js.map
|
||||
1
node_modules/hexo-util/dist/gravatar.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/gravatar.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"gravatar.js","sourceRoot":"","sources":["../lib/gravatar.ts"],"names":[],"mappings":";;;;AAAA,mCAAgD;AAChD,6CAA6D;AAC7D,oDAA4B;AAC5B,MAAM,KAAK,GAAG,IAAI,eAAK,EAAE,CAAC;AAE1B,SAAS,GAAG,CAAC,GAAe;IAC1B,OAAO,IAAA,mBAAU,EAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,cAAc,CAAC,KAAa,EAAE,OAAsC;IAC3E,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,OAAO,GAAG,EAAC,CAAC,EAAE,OAAO,EAAC,CAAC;KACxB;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5E,IAAI,GAAG,GAAG,mCAAmC,IAAI,EAAE,CAAC;IAEpD,MAAM,EAAE,GAAG,IAAA,uBAAS,EAAC,OAAO,CAAC,CAAC;IAE9B,IAAI,EAAE;QAAE,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC;IAExB,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAEzB,OAAO,GAAG,CAAC;AACb,CAAC;AAED,iBAAS,cAAc,CAAC"}
|
||||
6
node_modules/hexo-util/dist/hash.d.ts
generated
vendored
Normal file
6
node_modules/hexo-util/dist/hash.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
import crypto from 'crypto';
|
||||
declare function createSha1Hash(): crypto.Hash;
|
||||
declare function hash(content: crypto.BinaryLike): Buffer;
|
||||
export { hash, createSha1Hash };
|
||||
19
node_modules/hexo-util/dist/hash.js
generated
vendored
Normal file
19
node_modules/hexo-util/dist/hash.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createSha1Hash = exports.hash = void 0;
|
||||
const crypto_1 = __importDefault(require("crypto"));
|
||||
const ALGORITHM = 'sha1';
|
||||
function createSha1Hash() {
|
||||
return crypto_1.default.createHash(ALGORITHM);
|
||||
}
|
||||
exports.createSha1Hash = createSha1Hash;
|
||||
function hash(content) {
|
||||
const hash = createSha1Hash();
|
||||
hash.update(content);
|
||||
return hash.digest();
|
||||
}
|
||||
exports.hash = hash;
|
||||
//# sourceMappingURL=hash.js.map
|
||||
1
node_modules/hexo-util/dist/hash.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/hash.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../lib/hash.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B,MAAM,SAAS,GAAG,MAAM,CAAC;AAEzB,SAAS,cAAc;IACrB,OAAO,gBAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AACtC,CAAC;AAQc,wCAAc;AAN7B,SAAS,IAAI,CAAC,OAA0B;IACtC,MAAM,IAAI,GAAG,cAAc,EAAE,CAAC;IAC9B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACrB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;AACvB,CAAC;AAEQ,oBAAI"}
|
||||
15
node_modules/hexo-util/dist/highlight.d.ts
generated
vendored
Normal file
15
node_modules/hexo-util/dist/highlight.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
interface Options {
|
||||
autoDetect?: boolean;
|
||||
caption?: string;
|
||||
firstLine?: number;
|
||||
gutter?: boolean;
|
||||
hljs?: boolean;
|
||||
lang?: string;
|
||||
languageAttr?: boolean;
|
||||
mark?: number[];
|
||||
tab?: string;
|
||||
wrap?: boolean;
|
||||
stripIndent?: boolean;
|
||||
}
|
||||
declare function highlightUtil(str: string, options?: Options): string;
|
||||
export = highlightUtil;
|
||||
115
node_modules/hexo-util/dist/highlight.js
generated
vendored
Normal file
115
node_modules/hexo-util/dist/highlight.js
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const strip_indent_1 = __importDefault(require("strip-indent"));
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const alias = require('../highlight_alias.json');
|
||||
let hljs;
|
||||
function highlightUtil(str, options = {}) {
|
||||
if (typeof str !== 'string')
|
||||
throw new TypeError('str must be a string!');
|
||||
const useHljs = Object.prototype.hasOwnProperty.call(options, 'hljs') ? options.hljs : false;
|
||||
const { gutter = true, firstLine = 1, caption, mark = [], languageAttr = false, tab, stripIndent: enableStripIndent = true } = options;
|
||||
let { wrap = true } = options;
|
||||
if (enableStripIndent) {
|
||||
str = (0, strip_indent_1.default)(str);
|
||||
}
|
||||
if (!hljs) {
|
||||
hljs = require('highlight.js');
|
||||
}
|
||||
hljs.configure({ classPrefix: useHljs ? 'hljs-' : '' });
|
||||
const data = highlight(str, options);
|
||||
const lang = options.lang || data.language || '';
|
||||
const classNames = (useHljs ? 'hljs' : 'highlight') + (lang ? ` ${lang}` : '');
|
||||
if (gutter && !wrap)
|
||||
wrap = true; // arbitrate conflict ("gutter:true" takes priority over "wrap:false")
|
||||
const before = useHljs ? `<pre><code class="${classNames}"${languageAttr && lang ? ` data-language="${lang}"` : ''}>` : '<pre>';
|
||||
const after = useHljs ? '</code></pre>' : '</pre>';
|
||||
const lines = data.value.split('\n');
|
||||
let numbers = '';
|
||||
let content = '';
|
||||
for (let i = 0, len = lines.length; i < len; i++) {
|
||||
let line = lines[i];
|
||||
if (tab)
|
||||
line = replaceTabs(line, tab);
|
||||
numbers += `<span class="line">${Number(firstLine) + i}</span><br>`;
|
||||
content += formatLine(line, Number(firstLine) + i, mark, options, wrap);
|
||||
}
|
||||
let codeCaption = '';
|
||||
if (caption) {
|
||||
codeCaption = wrap ? `<figcaption>${caption}</figcaption>` : `<div class="caption">${caption}</div>`;
|
||||
}
|
||||
if (!wrap) {
|
||||
// if original content has one trailing newline, replace it only once, else remove all trailing newlines
|
||||
content = /\r?\n$/.test(data.value) ? content.replace(/\n$/, '') : content.trimEnd();
|
||||
return `<pre>${codeCaption}<code class="${classNames}"${languageAttr && lang ? ` data-language="${lang}"` : ''}>${content}</code></pre>`;
|
||||
}
|
||||
let result = `<figure class="highlight${data.language ? ` ${data.language}` : ''}"${languageAttr && lang ? ` data-language="${lang}"` : ''}>`;
|
||||
result += codeCaption;
|
||||
result += '<table><tr>';
|
||||
if (gutter) {
|
||||
result += `<td class="gutter"><pre>${numbers}</pre></td>`;
|
||||
}
|
||||
result += `<td class="code">${before}${content}${after}</td>`;
|
||||
result += '</tr></table></figure>';
|
||||
return result;
|
||||
}
|
||||
function formatLine(line, lineno, marked, options, wrap) {
|
||||
const useHljs = (options.hljs || false) || !wrap;
|
||||
const br = wrap ? '<br>' : '\n';
|
||||
let res = useHljs ? '' : '<span class="line';
|
||||
if (marked.includes(lineno)) {
|
||||
// Handle marked lines.
|
||||
res += useHljs ? `<mark>${line}</mark>` : ` marked">${line}</span>`;
|
||||
}
|
||||
else {
|
||||
res += useHljs ? line : `">${line}</span>`;
|
||||
}
|
||||
res += br;
|
||||
return res;
|
||||
}
|
||||
function replaceTabs(str, tab) {
|
||||
return str.replace(/\t+/, match => tab.repeat(match.length));
|
||||
}
|
||||
function highlight(str, options) {
|
||||
let { lang } = options;
|
||||
const { autoDetect = false } = options;
|
||||
if (!hljs) {
|
||||
hljs = require('highlight.js');
|
||||
}
|
||||
if (lang) {
|
||||
lang = lang.toLowerCase();
|
||||
}
|
||||
else if (autoDetect) {
|
||||
const result = hljs.highlightAuto(str);
|
||||
return closeTags(result);
|
||||
}
|
||||
if (!lang || !alias.aliases[lang]) {
|
||||
lang = 'plaintext';
|
||||
}
|
||||
const res = hljs.highlight(str, {
|
||||
language: lang,
|
||||
ignoreIllegals: true
|
||||
});
|
||||
return closeTags(res);
|
||||
}
|
||||
// https://github.com/hexojs/hexo-util/issues/10
|
||||
function closeTags(res) {
|
||||
const tokenStack = [];
|
||||
res.value = res.value.split('\n').map(line => {
|
||||
const prepend = tokenStack.map(token => `<span class="${token}">`).join('');
|
||||
const matches = line.matchAll(/(<span class="(.*?)">|<\/span>)/g);
|
||||
for (const match of matches) {
|
||||
if (match[0] === '</span>')
|
||||
tokenStack.shift();
|
||||
else
|
||||
tokenStack.unshift(match[2]);
|
||||
}
|
||||
const append = '</span>'.repeat(tokenStack.length);
|
||||
return prepend + line + append;
|
||||
}).join('\n');
|
||||
return res;
|
||||
}
|
||||
module.exports = highlightUtil;
|
||||
//# sourceMappingURL=highlight.js.map
|
||||
1
node_modules/hexo-util/dist/highlight.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/highlight.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"highlight.js","sourceRoot":"","sources":["../lib/highlight.ts"],"names":[],"mappings":";;;;AACA,gEAAuC;AACvC,8DAA8D;AAC9D,MAAM,KAAK,GAAG,OAAO,CAAC,yBAAyB,CAAC,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,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QAC3C,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,gBAAgB,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5E,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,kCAAkC,CAAC,CAAC;QAClE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;YAC3B,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS;gBAAE,UAAU,CAAC,KAAK,EAAE,CAAC;;gBAC1C,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SACnC;QACD,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACnD,OAAO,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC;IACjC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,OAAO,GAAG,CAAC;AACb,CAAC;AAED,iBAAS,aAAa,CAAC"}
|
||||
4
node_modules/hexo-util/dist/html_tag.d.ts
generated
vendored
Normal file
4
node_modules/hexo-util/dist/html_tag.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
declare function htmlTag(tag: string, attrs?: {
|
||||
[key: string]: string | boolean | number | null | undefined;
|
||||
}, text?: string, escape?: boolean): string;
|
||||
export = htmlTag;
|
||||
53
node_modules/hexo-util/dist/html_tag.js
generated
vendored
Normal file
53
node_modules/hexo-util/dist/html_tag.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const encode_url_1 = __importDefault(require("./encode_url"));
|
||||
const escape_html_1 = __importDefault(require("./escape_html"));
|
||||
const regexUrl = /(cite|download|href|src|url)$/i;
|
||||
const regexMeta = /^(og:|twitter:)(audio|image|url|video|player)(:secure_url)?$/i;
|
||||
function encSrcset(str) {
|
||||
str.split(' ')
|
||||
.forEach(subStr => {
|
||||
if (subStr.match(/\S/)) {
|
||||
subStr = subStr.trim();
|
||||
str = str.replace(subStr, (0, encode_url_1.default)(subStr));
|
||||
}
|
||||
});
|
||||
return str;
|
||||
}
|
||||
function htmlTag(tag, attrs, text, escape = true) {
|
||||
if (!tag)
|
||||
throw new TypeError('tag is required!');
|
||||
let result = `<${(0, escape_html_1.default)(tag)}`;
|
||||
for (const i in attrs) {
|
||||
if (attrs[i] == null)
|
||||
result += '';
|
||||
else {
|
||||
if (i.match(regexUrl)
|
||||
|| (tag === 'meta' && !String(attrs[i]).match(regexMeta) && String(Object.values(attrs)[0]).match(regexMeta))) {
|
||||
result += ` ${(0, escape_html_1.default)(i)}="${(0, encode_url_1.default)(String(attrs[i]))}"`;
|
||||
}
|
||||
else if (attrs[i] === true || i === attrs[i])
|
||||
result += ` ${(0, escape_html_1.default)(i)}`;
|
||||
else if (i.match(/srcset$/i))
|
||||
result += ` ${(0, escape_html_1.default)(i)}="${encSrcset(String(attrs[i]))}"`;
|
||||
else
|
||||
result += ` ${(0, escape_html_1.default)(i)}="${(0, escape_html_1.default)(String(attrs[i]))}"`;
|
||||
}
|
||||
}
|
||||
if (escape && text && tag !== 'style')
|
||||
text = (0, escape_html_1.default)(String(text));
|
||||
if (text && tag === 'style') {
|
||||
text = text.replace(/url\(['"](.*?)['"]\)/gi, (urlAttr, url) => {
|
||||
return `url("${(0, encode_url_1.default)(url)}")`;
|
||||
});
|
||||
}
|
||||
if (text == null)
|
||||
result += '>';
|
||||
else
|
||||
result += `>${text}</${(0, escape_html_1.default)(tag)}>`;
|
||||
return result;
|
||||
}
|
||||
module.exports = htmlTag;
|
||||
//# sourceMappingURL=html_tag.js.map
|
||||
1
node_modules/hexo-util/dist/html_tag.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/html_tag.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"html_tag.js","sourceRoot":"","sources":["../lib/html_tag.ts"],"names":[],"mappings":";;;;AAAA,8DAAqC;AACrC,gEAAuC;AACvC,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AAClD,MAAM,SAAS,GAAG,+DAA+D,CAAC;AAElF,SAAS,SAAS,CAAC,GAAW;IAC5B,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;SACX,OAAO,CAAC,MAAM,CAAC,EAAE;QAChB,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;YACtB,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;YACvB,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,IAAA,oBAAS,EAAC,MAAM,CAAC,CAAC,CAAC;SAC9C;IACH,CAAC,CAAC,CAAC;IACL,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,OAAO,CAAC,GAAW,EAAE,KAE7B,EAAE,IAAa,EAAE,MAAM,GAAG,IAAI;IAC7B,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAElD,IAAI,MAAM,GAAG,IAAI,IAAA,qBAAU,EAAC,GAAG,CAAC,EAAE,CAAC;IAEnC,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;QACrB,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI;YAAE,MAAM,IAAI,EAAE,CAAC;aAC9B;YACH,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;mBAChB,CAAC,GAAG,KAAK,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,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AC;AAChB,CAAC;AAED,iBAAS,OAAO,CAAC"}
|
||||
30
node_modules/hexo-util/dist/index.d.ts
generated
vendored
Normal file
30
node_modules/hexo-util/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
export { default as Cache } from './cache';
|
||||
export { default as CacheStream } from './cache_stream';
|
||||
export { default as camelCaseKeys } from './camel_case_keys';
|
||||
export { default as Color } from './color';
|
||||
export { default as decodeURL } from './decode_url';
|
||||
export { default as deepMerge } from './deep_merge';
|
||||
export { default as encodeURL } from './encode_url';
|
||||
export { default as escapeDiacritic } from './escape_diacritic';
|
||||
export { default as escapeHTML } from './escape_html';
|
||||
export { default as escapeRegExp } from './escape_regexp';
|
||||
export { default as full_url_for } from './full_url_for';
|
||||
export { default as gravatar } from './gravatar';
|
||||
export { hash, createSha1Hash } from './hash';
|
||||
export { default as highlight } from './highlight';
|
||||
export { default as htmlTag } from './html_tag';
|
||||
export { default as isExternalLink } from './is_external_link';
|
||||
export { default as Pattern } from './pattern';
|
||||
export { default as Permalink } from './permalink';
|
||||
export { default as prettyUrls } from './pretty_urls';
|
||||
export { default as prismHighlight } from './prism';
|
||||
export { default as relative_url } from './relative_url';
|
||||
export { default as slugize } from './slugize';
|
||||
export { default as spawn } from './spawn';
|
||||
export { default as stripHTML } from './strip_html';
|
||||
export { default as stripIndent } from './strip_indent';
|
||||
export { default as tocObj } from './toc_obj';
|
||||
export { default as truncate } from './truncate';
|
||||
export { default as unescapeHTML } from './unescape_html';
|
||||
export { default as url_for } from './url_for';
|
||||
export { default as wordWrap } from './word_wrap';
|
||||
68
node_modules/hexo-util/dist/index.js
generated
vendored
Normal file
68
node_modules/hexo-util/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.wordWrap = exports.url_for = exports.unescapeHTML = exports.truncate = exports.tocObj = exports.stripIndent = exports.stripHTML = exports.spawn = exports.slugize = exports.relative_url = exports.prismHighlight = exports.prettyUrls = exports.Permalink = exports.Pattern = exports.isExternalLink = exports.htmlTag = exports.highlight = exports.createSha1Hash = exports.hash = exports.gravatar = exports.full_url_for = exports.escapeRegExp = exports.escapeHTML = exports.escapeDiacritic = exports.encodeURL = exports.deepMerge = exports.decodeURL = exports.Color = exports.camelCaseKeys = exports.CacheStream = exports.Cache = void 0;
|
||||
var cache_1 = require("./cache");
|
||||
Object.defineProperty(exports, "Cache", { enumerable: true, get: function () { return __importDefault(cache_1).default; } });
|
||||
var cache_stream_1 = require("./cache_stream");
|
||||
Object.defineProperty(exports, "CacheStream", { enumerable: true, get: function () { return __importDefault(cache_stream_1).default; } });
|
||||
var camel_case_keys_1 = require("./camel_case_keys");
|
||||
Object.defineProperty(exports, "camelCaseKeys", { enumerable: true, get: function () { return __importDefault(camel_case_keys_1).default; } });
|
||||
var color_1 = require("./color");
|
||||
Object.defineProperty(exports, "Color", { enumerable: true, get: function () { return __importDefault(color_1).default; } });
|
||||
var decode_url_1 = require("./decode_url");
|
||||
Object.defineProperty(exports, "decodeURL", { enumerable: true, get: function () { return __importDefault(decode_url_1).default; } });
|
||||
var deep_merge_1 = require("./deep_merge");
|
||||
Object.defineProperty(exports, "deepMerge", { enumerable: true, get: function () { return __importDefault(deep_merge_1).default; } });
|
||||
var encode_url_1 = require("./encode_url");
|
||||
Object.defineProperty(exports, "encodeURL", { enumerable: true, get: function () { return __importDefault(encode_url_1).default; } });
|
||||
var escape_diacritic_1 = require("./escape_diacritic");
|
||||
Object.defineProperty(exports, "escapeDiacritic", { enumerable: true, get: function () { return __importDefault(escape_diacritic_1).default; } });
|
||||
var escape_html_1 = require("./escape_html");
|
||||
Object.defineProperty(exports, "escapeHTML", { enumerable: true, get: function () { return __importDefault(escape_html_1).default; } });
|
||||
var escape_regexp_1 = require("./escape_regexp");
|
||||
Object.defineProperty(exports, "escapeRegExp", { enumerable: true, get: function () { return __importDefault(escape_regexp_1).default; } });
|
||||
var full_url_for_1 = require("./full_url_for");
|
||||
Object.defineProperty(exports, "full_url_for", { enumerable: true, get: function () { return __importDefault(full_url_for_1).default; } });
|
||||
var gravatar_1 = require("./gravatar");
|
||||
Object.defineProperty(exports, "gravatar", { enumerable: true, get: function () { return __importDefault(gravatar_1).default; } });
|
||||
var hash_1 = require("./hash");
|
||||
Object.defineProperty(exports, "hash", { enumerable: true, get: function () { return hash_1.hash; } });
|
||||
Object.defineProperty(exports, "createSha1Hash", { enumerable: true, get: function () { return hash_1.createSha1Hash; } });
|
||||
var highlight_1 = require("./highlight");
|
||||
Object.defineProperty(exports, "highlight", { enumerable: true, get: function () { return __importDefault(highlight_1).default; } });
|
||||
var html_tag_1 = require("./html_tag");
|
||||
Object.defineProperty(exports, "htmlTag", { enumerable: true, get: function () { return __importDefault(html_tag_1).default; } });
|
||||
var is_external_link_1 = require("./is_external_link");
|
||||
Object.defineProperty(exports, "isExternalLink", { enumerable: true, get: function () { return __importDefault(is_external_link_1).default; } });
|
||||
var pattern_1 = require("./pattern");
|
||||
Object.defineProperty(exports, "Pattern", { enumerable: true, get: function () { return __importDefault(pattern_1).default; } });
|
||||
var permalink_1 = require("./permalink");
|
||||
Object.defineProperty(exports, "Permalink", { enumerable: true, get: function () { return __importDefault(permalink_1).default; } });
|
||||
var pretty_urls_1 = require("./pretty_urls");
|
||||
Object.defineProperty(exports, "prettyUrls", { enumerable: true, get: function () { return __importDefault(pretty_urls_1).default; } });
|
||||
var prism_1 = require("./prism");
|
||||
Object.defineProperty(exports, "prismHighlight", { enumerable: true, get: function () { return __importDefault(prism_1).default; } });
|
||||
var relative_url_1 = require("./relative_url");
|
||||
Object.defineProperty(exports, "relative_url", { enumerable: true, get: function () { return __importDefault(relative_url_1).default; } });
|
||||
var slugize_1 = require("./slugize");
|
||||
Object.defineProperty(exports, "slugize", { enumerable: true, get: function () { return __importDefault(slugize_1).default; } });
|
||||
var spawn_1 = require("./spawn");
|
||||
Object.defineProperty(exports, "spawn", { enumerable: true, get: function () { return __importDefault(spawn_1).default; } });
|
||||
var strip_html_1 = require("./strip_html");
|
||||
Object.defineProperty(exports, "stripHTML", { enumerable: true, get: function () { return __importDefault(strip_html_1).default; } });
|
||||
var strip_indent_1 = require("./strip_indent");
|
||||
Object.defineProperty(exports, "stripIndent", { enumerable: true, get: function () { return __importDefault(strip_indent_1).default; } });
|
||||
var toc_obj_1 = require("./toc_obj");
|
||||
Object.defineProperty(exports, "tocObj", { enumerable: true, get: function () { return __importDefault(toc_obj_1).default; } });
|
||||
var truncate_1 = require("./truncate");
|
||||
Object.defineProperty(exports, "truncate", { enumerable: true, get: function () { return __importDefault(truncate_1).default; } });
|
||||
var unescape_html_1 = require("./unescape_html");
|
||||
Object.defineProperty(exports, "unescapeHTML", { enumerable: true, get: function () { return __importDefault(unescape_html_1).default; } });
|
||||
var url_for_1 = require("./url_for");
|
||||
Object.defineProperty(exports, "url_for", { enumerable: true, get: function () { return __importDefault(url_for_1).default; } });
|
||||
var word_wrap_1 = require("./word_wrap");
|
||||
Object.defineProperty(exports, "wordWrap", { enumerable: true, get: function () { return __importDefault(word_wrap_1).default; } });
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/hexo-util/dist/index.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;AAAA,iCAA2C;AAAlC,+GAAA,OAAO,OAAS;AACzB,+CAAwD;AAA/C,4HAAA,OAAO,OAAe;AAC/B,qDAA6D;AAApD,iIAAA,OAAO,OAAiB;AACjC,iCAA2C;AAAlC,+GAAA,OAAO,OAAS;AACzB,2CAAoD;AAA3C,wHAAA,OAAO,OAAa;AAC7B,2CAAoD;AAA3C,wHAAA,OAAO,OAAa;AAC7B,2CAAoD;AAA3C,wHAAA,OAAO,OAAa;AAC7B,uDAAgE;AAAvD,oIAAA,OAAO,OAAmB;AACnC,6CAAsD;AAA7C,0HAAA,OAAO,OAAc;AAC9B,iDAA0D;AAAjD,8HAAA,OAAO,OAAgB;AAChC,+CAAyD;AAAhD,6HAAA,OAAO,OAAgB;AAChC,uCAAiD;AAAxC,qHAAA,OAAO,OAAY;AAC5B,+BAA8C;AAArC,4FAAA,IAAI,OAAA;AAAE,sGAAA,cAAc,OAAA;AAC7B,yCAAmD;AAA1C,uHAAA,OAAO,OAAa;AAC7B,uCAAgD;AAAvC,oHAAA,OAAO,OAAW;AAC3B,uDAA+D;AAAtD,mIAAA,OAAO,OAAkB;AAClC,qCAA+C;AAAtC,mHAAA,OAAO,OAAW;AAC3B,yCAAmD;AAA1C,uHAAA,OAAO,OAAa;AAC7B,6CAAsD;AAA7C,0HAAA,OAAO,OAAc;AAC9B,iCAAoD;AAA3C,wHAAA,OAAO,OAAkB;AAClC,+CAAyD;AAAhD,6HAAA,OAAO,OAAgB;AAChC,qCAA+C;AAAtC,mHAAA,OAAO,OAAW;AAC3B,iCAA2C;AAAlC,+GAAA,OAAO,OAAS;AACzB,2CAAoD;AAA3C,wHAAA,OAAO,OAAa;AAC7B,+CAAwD;AAA/C,4HAAA,OAAO,OAAe;AAC/B,qCAA8C;AAArC,kHAAA,OAAO,OAAU;AAC1B,uCAAiD;AAAxC,qHAAA,OAAO,OAAY;AAC5B,iDAA0D;AAAjD,8HAAA,OAAO,OAAgB;AAChC,qCAA+C;AAAtC,mHAAA,OAAO,OAAW;AAC3B,yCAAkD;AAAzC,sHAAA,OAAO,OAAY"}
|
||||
9
node_modules/hexo-util/dist/is_external_link.d.ts
generated
vendored
Normal file
9
node_modules/hexo-util/dist/is_external_link.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Check whether the link is external
|
||||
* @param {String} input The url to check
|
||||
* @param {String} input The hostname / url of website
|
||||
* @param {Array} input Exclude hostnames. Specific subdomain is required when applicable, including www.
|
||||
* @returns {Boolean} True if the link doesn't have protocol or link has same host with config.url
|
||||
*/
|
||||
declare function isExternalLink(input: string, sitehost: string, exclude?: string | string[]): boolean;
|
||||
export = isExternalLink;
|
||||
51
node_modules/hexo-util/dist/is_external_link.js
generated
vendored
Normal file
51
node_modules/hexo-util/dist/is_external_link.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const url_1 = require("url");
|
||||
const cache_1 = __importDefault(require("./cache"));
|
||||
const cache = new cache_1.default();
|
||||
/**
|
||||
* Check whether the link is external
|
||||
* @param {String} input The url to check
|
||||
* @param {String} input The hostname / url of website
|
||||
* @param {Array} input Exclude hostnames. Specific subdomain is required when applicable, including www.
|
||||
* @returns {Boolean} True if the link doesn't have protocol or link has same host with config.url
|
||||
*/
|
||||
function isExternalLink(input, sitehost, exclude) {
|
||||
return cache.apply(`${input}-${sitehost}-${exclude}`, () => {
|
||||
// Return false early for internal link
|
||||
if (!/^(\/\/|http(s)?:)/.test(input))
|
||||
return false;
|
||||
sitehost = (0, url_1.parse)(sitehost).hostname || sitehost;
|
||||
if (!sitehost)
|
||||
return false;
|
||||
// handle relative url and invalid url
|
||||
let data;
|
||||
try {
|
||||
data = new URL(input, `http://${sitehost}`);
|
||||
}
|
||||
catch (e) { }
|
||||
// if input is invalid url, data should be undefined
|
||||
if (typeof data !== 'object')
|
||||
return false;
|
||||
// handle mailto: javascript: vbscript: and so on
|
||||
if (data.origin === 'null')
|
||||
return false;
|
||||
const host = data.hostname;
|
||||
if (exclude) {
|
||||
exclude = Array.isArray(exclude) ? exclude : [exclude];
|
||||
if (exclude && exclude.length) {
|
||||
for (const i of exclude) {
|
||||
if (host === i)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (host !== sitehost)
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
module.exports = isExternalLink;
|
||||
//# sourceMappingURL=is_external_link.js.map
|
||||
1
node_modules/hexo-util/dist/is_external_link.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/is_external_link.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"is_external_link.js","sourceRoot":"","sources":["../lib/is_external_link.ts"],"names":[],"mappings":";;;;AAAA,6BAA4B;AAC5B,oDAA4B;AAC5B,MAAM,KAAK,GAAG,IAAI,eAAK,EAAW,CAAC;AAEnC;;;;;;GAMG;AAEH,SAAS,cAAc,CAAC,KAAa,EAAE,QAAgB,EAAE,OAA2B;IAClF,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,QAAQ,IAAI,OAAO,EAAE,EAAE,GAAG,EAAE;QACzD,uCAAuC;QACvC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QAEnD,QAAQ,GAAG,IAAA,WAAK,EAAC,QAAQ,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC;QAEhD,IAAI,CAAC,QAAQ;YAAE,OAAO,KAAK,CAAC;QAE5B,sCAAsC;QACtC,IAAI,IAAI,CAAC;QACT,IAAI;YACF,IAAI,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE,UAAU,QAAQ,EAAE,CAAC,CAAC;SAC7C;QAAC,OAAO,CAAC,EAAE,GAAG;QAEf,oDAAoD;QACpD,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAE3C,iDAAiD;QACjD,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM;YAAE,OAAO,KAAK,CAAC;QAEzC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC;QAE3B,IAAI,OAAO,EAAE;YACX,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YAEvD,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE;gBAC7B,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE;oBACvB,IAAI,IAAI,KAAK,CAAC;wBAAE,OAAO,KAAK,CAAC;iBAC9B;aACF;SACF;QAED,IAAI,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QAEnC,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC;AAED,iBAAS,cAAc,CAAC"}
|
||||
6
node_modules/hexo-util/dist/pattern.d.ts
generated
vendored
Normal file
6
node_modules/hexo-util/dist/pattern.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
declare class Pattern {
|
||||
match: (str: string) => any;
|
||||
constructor(rule: Pattern | ((str: string) => any) | RegExp | string);
|
||||
test(str: string): boolean;
|
||||
}
|
||||
export = Pattern;
|
||||
68
node_modules/hexo-util/dist/pattern.js
generated
vendored
Normal file
68
node_modules/hexo-util/dist/pattern.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const escape_regexp_1 = __importDefault(require("./escape_regexp"));
|
||||
const rParam = /([:*])([\w?]*)?/g;
|
||||
class Pattern {
|
||||
constructor(rule) {
|
||||
if (rule instanceof Pattern) {
|
||||
return rule;
|
||||
}
|
||||
else if (typeof rule === 'function') {
|
||||
this.match = rule;
|
||||
}
|
||||
else if (rule instanceof RegExp) {
|
||||
this.match = regexFilter(rule);
|
||||
}
|
||||
else if (typeof rule === 'string') {
|
||||
this.match = stringFilter(rule);
|
||||
}
|
||||
else {
|
||||
throw new TypeError('rule must be a function, a string or a regular expression.');
|
||||
}
|
||||
}
|
||||
test(str) {
|
||||
return Boolean(this.match(str));
|
||||
}
|
||||
}
|
||||
function regexFilter(rule) {
|
||||
return (str) => str.match(rule);
|
||||
}
|
||||
function stringFilter(rule) {
|
||||
const params = [];
|
||||
const regex = (0, escape_regexp_1.default)(rule)
|
||||
.replace(/\\([*?])/g, '$1')
|
||||
.replace(rParam, (match, operator, name) => {
|
||||
let str = '';
|
||||
if (operator === '*') {
|
||||
str = '(.*)?';
|
||||
}
|
||||
else {
|
||||
str = '([^\\/]+)';
|
||||
}
|
||||
if (name) {
|
||||
if (name[name.length - 1] === '?') {
|
||||
name = name.slice(0, name.length - 1);
|
||||
str += '?';
|
||||
}
|
||||
params.push(name);
|
||||
}
|
||||
return str;
|
||||
});
|
||||
return (str) => {
|
||||
const match = str.match(regex);
|
||||
if (!match)
|
||||
return;
|
||||
const result = {};
|
||||
for (let i = 0, len = match.length; i < len; i++) {
|
||||
const name = params[i - 1];
|
||||
result[i] = match[i];
|
||||
if (name)
|
||||
result[name] = match[i];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
module.exports = Pattern;
|
||||
//# sourceMappingURL=pattern.js.map
|
||||
1
node_modules/hexo-util/dist/pattern.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/pattern.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pattern.js","sourceRoot":"","sources":["../lib/pattern.ts"],"names":[],"mappings":";;;;AAAA,oEAA2C;AAE3C,MAAM,MAAM,GAAG,kBAAkB,CAAC;AAElC,MAAM,OAAO;IAGX,YAAY,IAAwD;QAClE,IAAI,IAAI,YAAY,OAAO,EAAE;YAC3B,OAAO,IAAI,CAAC;SACb;aAAM,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;YACrC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;SACnB;aAAM,IAAI,IAAI,YAAY,MAAM,EAAE;YACjC,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;SAChC;aAAM,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YACnC,IAAI,CAAC,KAAK,GA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AM,GAAG,EAAE,CAAC;QAElB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YAChD,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC3B,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,IAAI,IAAI;gBAAE,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;SACnC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAED,iBAAS,OAAO,CAAC"}
|
||||
15
node_modules/hexo-util/dist/permalink.d.ts
generated
vendored
Normal file
15
node_modules/hexo-util/dist/permalink.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
interface Options {
|
||||
segments?: {
|
||||
[key: string]: RegExp | string;
|
||||
};
|
||||
}
|
||||
declare class Permalink {
|
||||
rule: string;
|
||||
regex: RegExp;
|
||||
params: string[];
|
||||
constructor(rule: string, options?: Options);
|
||||
test(str: string): boolean;
|
||||
parse(str: string): {};
|
||||
stringify(data: any): string;
|
||||
}
|
||||
export = Permalink;
|
||||
56
node_modules/hexo-util/dist/permalink.js
generated
vendored
Normal file
56
node_modules/hexo-util/dist/permalink.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const escape_regexp_1 = __importDefault(require("./escape_regexp"));
|
||||
const rParam = /:(\w*[^_\W])/g;
|
||||
class Permalink {
|
||||
constructor(rule, options = {}) {
|
||||
if (!rule) {
|
||||
throw new TypeError('rule is required!');
|
||||
}
|
||||
const segments = options.segments || {};
|
||||
const params = [];
|
||||
const regex = (0, escape_regexp_1.default)(rule)
|
||||
.replace(rParam, (match, name) => {
|
||||
params.push(name);
|
||||
if (Object.prototype.hasOwnProperty.call(segments, name)) {
|
||||
const segment = segments[name];
|
||||
if (segment instanceof RegExp) {
|
||||
return segment.source;
|
||||
}
|
||||
return segment;
|
||||
}
|
||||
return '(.+?)';
|
||||
});
|
||||
this.rule = rule;
|
||||
this.regex = new RegExp(`^${regex}$`);
|
||||
this.params = params;
|
||||
}
|
||||
test(str) {
|
||||
return this.regex.test(str);
|
||||
}
|
||||
parse(str) {
|
||||
const match = str.match(this.regex);
|
||||
const { params } = this;
|
||||
const result = {};
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
for (let i = 1, len = match.length; i < len; i++) {
|
||||
result[params[i - 1]] = match[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
stringify(data) {
|
||||
return this.rule.replace(rParam, (match, name) => {
|
||||
const descriptor = Object.getOwnPropertyDescriptor(data, name);
|
||||
if (descriptor && typeof descriptor.get === 'function') {
|
||||
throw new Error('Invalid permalink setting!');
|
||||
}
|
||||
return data[name];
|
||||
});
|
||||
}
|
||||
}
|
||||
module.exports = Permalink;
|
||||
//# sourceMappingURL=permalink.js.map
|
||||
1
node_modules/hexo-util/dist/permalink.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/permalink.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"permalink.js","sourceRoot":"","sources":["../lib/permalink.ts"],"names":[],"mappings":";;;;AAAA,oEAA2C;AAE3C,MAAM,MAAM,GAAG,eAAe,CAAC;AAQ/B,MAAM,SAAS;IAKb,YAAY,IAAY,EAAE,UAAmB,EAAE;QAC7C,IAAI,CAAC,IAAI,EAAE;YAAE,MAAM,IAAI,SAAS,CAAC,mBAAmB,CAAC,CAAC;SAAE;QACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,MAAM,KAAK,GAAG,IAAA,uBAAY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QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAC/C,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC/D,IAAI,UAAU,IAAI,OAAO,UAAU,CAAC,GAAG,KAAK,UAAU,EAAE;gBACtD,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;aAC/C;YACD,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,iBAAS,SAAS,CAAC"}
|
||||
6
node_modules/hexo-util/dist/pretty_urls.d.ts
generated
vendored
Normal file
6
node_modules/hexo-util/dist/pretty_urls.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
interface Options {
|
||||
trailing_index?: boolean;
|
||||
trailing_html?: boolean;
|
||||
}
|
||||
declare function prettyUrls(url: string, options?: Options): string;
|
||||
export = prettyUrls;
|
||||
16
node_modules/hexo-util/dist/pretty_urls.js
generated
vendored
Normal file
16
node_modules/hexo-util/dist/pretty_urls.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
function prettyUrls(url, options = {}) {
|
||||
options = Object.assign({
|
||||
trailing_index: true,
|
||||
trailing_html: true
|
||||
}, options);
|
||||
const indexPattern = /index\.html$/;
|
||||
if (options.trailing_index === false)
|
||||
url = url.replace(indexPattern, '');
|
||||
if (options.trailing_html === false && !indexPattern.test(url)) {
|
||||
url = url.replace(/\.html$/, '');
|
||||
}
|
||||
return url;
|
||||
}
|
||||
module.exports = prettyUrls;
|
||||
//# sourceMappingURL=pretty_urls.js.map
|
||||
1
node_modules/hexo-util/dist/pretty_urls.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/pretty_urls.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pretty_urls.js","sourceRoot":"","sources":["../lib/pretty_urls.ts"],"names":[],"mappings":";AAKA,SAAS,UAAU,CAAC,GAAW,EAAE,UAAmB,EAAE;IACpD,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;QACtB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,IAAI;KACpB,EAAE,OAAO,CAAC,CAAC;IAEZ,MAAM,YAAY,GAAG,cAAc,CAAC;IACpC,IAAI,OAAO,CAAC,cAAc,KAAK,KAAK;QAAE,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAC1E,IAAI,OAAO,CAAC,aAAa,KAAK,KAAK,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAC9D,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;KAClC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,iBAAS,UAAU,CAAC"}
|
||||
12
node_modules/hexo-util/dist/prism.d.ts
generated
vendored
Normal file
12
node_modules/hexo-util/dist/prism.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
interface Options {
|
||||
caption?: string;
|
||||
firstLine?: number;
|
||||
isPreprocess?: boolean;
|
||||
lang?: string;
|
||||
lineNumber?: boolean;
|
||||
mark?: string;
|
||||
tab?: string;
|
||||
stripIndent?: boolean;
|
||||
}
|
||||
declare function PrismUtil(str: string, options?: Options): string;
|
||||
export = PrismUtil;
|
||||
110
node_modules/hexo-util/dist/prism.js
generated
vendored
Normal file
110
node_modules/hexo-util/dist/prism.js
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const strip_indent_1 = __importDefault(require("strip-indent"));
|
||||
const components_1 = __importDefault(require("prismjs/components/"));
|
||||
let Prism;
|
||||
// https://github.com/PrismJS/prism/issues/2145
|
||||
const components_2 = __importDefault(require("prismjs/components"));
|
||||
const prismAlias = Object.entries(components_2.default.languages).reduce((acc, [key, value]) => {
|
||||
if (value.alias) {
|
||||
if (Array.isArray(value.alias)) {
|
||||
value.alias.forEach(alias => (acc[alias] = key));
|
||||
}
|
||||
else if (typeof value.alias === 'string') {
|
||||
acc[value.alias] = key;
|
||||
}
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
const prismSupportedLanguages = Object.keys(components_2.default.languages).concat(Object.keys(prismAlias));
|
||||
const escape_html_1 = __importDefault(require("./escape_html"));
|
||||
/**
|
||||
* Wrapper of Prism.highlight()
|
||||
* @param {String} code
|
||||
* @param {String} language
|
||||
*/
|
||||
function prismHighlight(code, language) {
|
||||
if (!Prism)
|
||||
Prism = require('prismjs');
|
||||
// Prism has not load the language pattern
|
||||
if (!Prism.languages[language] && prismSupportedLanguages.includes(language))
|
||||
(0, components_1.default)(language);
|
||||
if (Prism.languages[language]) {
|
||||
// Prism escapes output by default
|
||||
return Prism.highlight(code, Prism.languages[language], language);
|
||||
}
|
||||
// Current language is not supported by Prism, return origin code;
|
||||
return (0, escape_html_1.default)(code);
|
||||
}
|
||||
/**
|
||||
* Generate line number required HTML snippet
|
||||
* @param {String} code - Highlighted code
|
||||
*/
|
||||
function lineNumberUtil(code) {
|
||||
const matched = code.match(/\n(?!$)/g);
|
||||
const num = matched ? matched.length + 1 : 1;
|
||||
const lines = new Array(num + 1).join('<span></span>');
|
||||
return `<span aria-hidden="true" class="line-numbers-rows">${lines}</span>`;
|
||||
}
|
||||
function replaceTabs(str, tab) {
|
||||
return str.replace(/^\t+/gm, match => tab.repeat(match.length));
|
||||
}
|
||||
function PrismUtil(str, options = {}) {
|
||||
if (typeof str !== 'string')
|
||||
throw new TypeError('str must be a string!');
|
||||
const { lineNumber = true, lang = 'none', tab, mark, firstLine, isPreprocess = true, caption, stripIndent: enableStripIndent = true } = options;
|
||||
if (enableStripIndent) {
|
||||
str = (0, strip_indent_1.default)(str);
|
||||
}
|
||||
// To be consistent with highlight.js
|
||||
let language = lang === 'plaintext' || lang === 'none' ? 'none' : lang;
|
||||
if (prismAlias[language])
|
||||
language = prismAlias[language];
|
||||
const preTagClassArr = [];
|
||||
const preTagAttrArr = [];
|
||||
let preTagAttr = '';
|
||||
if (lineNumber)
|
||||
preTagClassArr.push('line-numbers');
|
||||
preTagClassArr.push(`language-${language}`);
|
||||
// Show Languages plugin
|
||||
// https://prismjs.com/plugins/show-language/
|
||||
if (language !== 'none')
|
||||
preTagAttrArr.push(`data-language="${language}"`);
|
||||
if (!isPreprocess) {
|
||||
// Shift Line Numbers ('firstLine' option) should only be added under non-preprocess mode
|
||||
// https://prismjs.com/plugins/line-numbers/
|
||||
if (lineNumber && firstLine)
|
||||
preTagAttrArr.push(`data-start="${firstLine}"`);
|
||||
// Line Highlight ('mark' option) should only be added under non-preprocess mode
|
||||
// https://prismjs.com/plugins/line-highlight/
|
||||
if (mark)
|
||||
preTagAttrArr.push(`data-line="${mark}"`);
|
||||
// Apply offset for 'mark' option
|
||||
// https://github.com/hexojs/hexo-util/pull/172#issuecomment-571882480
|
||||
if (firstLine && mark)
|
||||
preTagAttrArr.push(`data-line-offset="${firstLine - 1}"`);
|
||||
}
|
||||
if (preTagAttrArr.length)
|
||||
preTagAttr = ' ' + preTagAttrArr.join(' ');
|
||||
if (tab)
|
||||
str = replaceTabs(str, tab);
|
||||
const codeCaption = caption ? `<div class="caption">${caption}</div>` : '';
|
||||
const startTag = `<pre class="${preTagClassArr.join(' ')}"${preTagAttr}>${codeCaption}<code class="language-${language}">`;
|
||||
const endTag = '</code></pre>';
|
||||
let parsedCode = '';
|
||||
if (language === 'none' || !isPreprocess) {
|
||||
parsedCode = (0, escape_html_1.default)(str);
|
||||
}
|
||||
else {
|
||||
parsedCode = prismHighlight(str, language);
|
||||
}
|
||||
// lineNumberUtil() should be used only under preprocess mode
|
||||
if (lineNumber && isPreprocess) {
|
||||
parsedCode += lineNumberUtil(parsedCode);
|
||||
}
|
||||
return startTag + parsedCode + endTag;
|
||||
}
|
||||
module.exports = PrismUtil;
|
||||
//# sourceMappingURL=prism.js.map
|
||||
1
node_modules/hexo-util/dist/prism.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/prism.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"prism.js","sourceRoot":"","sources":["../lib/prism.ts"],"names":[],"mappings":";;;;AAAA,gEAAuC;AACvC,qEAAqD;AAErD,IAAI,KAA2C,CAAC;AAEhD,+CAA+C;AAC/C,oEAAiD;AAEjD,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,oBAAe,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;IACxF,IAAI,KAAK,CAAC,KAAK,EAAE;QACf,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;YAC9B,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;SAClD;aAAM,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,EAAE;YAC1C,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;SACxB;KACF;IACD,OAAO,GAAG,CAAC;AACb,CAAC,EAAE,EAAE,CAAC,CAAC;AAEP,MAAM,uBAAuB,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAe,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;AAEvG,gEAAuC;AAEvC;;;;GAIG;AACH,SAAS,cAAc,CAAC,IAAY,EAAE,QAAgB;IACpD,IAAI,CAAC,KAAK;QAAE,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAEvC,0CAA0C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AC,GAAG,CAAC,CAAC;IAErE,IAAI,GAAG;QAAE,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAErC,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,wBAAwB,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IAE3E,MAAM,QAAQ,GAAG,eAAe,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,UAAU,IAAI,WAAW,yBAAyB,QAAQ,IAAI,CAAC;IAC3H,MAAM,MAAM,GAAG,eAAe,CAAC;IAE/B,IAAI,UAAU,GAAG,EAAE,CAAC;IAEpB,IAAI,QAAQ,KAAK,MAAM,IAAI,CAAC,YAAY,EAAE;QACxC,UAAU,GAAG,IAAA,qBAAU,EAAC,GAAG,CAAC,CAAC;KAC9B;SAAM;QACL,UAAU,GAAG,cAAc,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;KAC5C;IAED,6DAA6D;IAC7D,IAAI,UAAU,IAAI,YAAY,EAAE;QAC9B,UAAU,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;KAC1C;IAED,OAAO,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;AACxC,CAAC;AAED,iBAAS,SAAS,CAAC"}
|
||||
2
node_modules/hexo-util/dist/relative_url.d.ts
generated
vendored
Normal file
2
node_modules/hexo-util/dist/relative_url.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare function relativeUrlHelper(from?: string, to?: string): string;
|
||||
export = relativeUrlHelper;
|
||||
31
node_modules/hexo-util/dist/relative_url.js
generated
vendored
Normal file
31
node_modules/hexo-util/dist/relative_url.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const encode_url_1 = __importDefault(require("./encode_url"));
|
||||
const cache_1 = __importDefault(require("./cache"));
|
||||
const cache = new cache_1.default();
|
||||
function relativeUrlHelper(from = '', to = '') {
|
||||
return cache.apply(`${from}-${to}`, () => {
|
||||
const fromParts = from.split('/');
|
||||
const toParts = to.split('/');
|
||||
const length = Math.min(fromParts.length, toParts.length);
|
||||
let i = 0;
|
||||
for (; i < length; i++) {
|
||||
if (fromParts[i] !== toParts[i])
|
||||
break;
|
||||
}
|
||||
let out = toParts.slice(i);
|
||||
for (let j = fromParts.length - i - 1; j > 0; j--) {
|
||||
out.unshift('..');
|
||||
}
|
||||
const outLength = out.length;
|
||||
// If the last 2 elements of `out` is empty strings, replace them with `index.html`.
|
||||
if (outLength > 1 && !out[outLength - 1] && !out[outLength - 2]) {
|
||||
out = out.slice(0, outLength - 2).concat('index.html');
|
||||
}
|
||||
return (0, encode_url_1.default)(out.join('/').replace(/\/{2,}/g, '/'));
|
||||
});
|
||||
}
|
||||
module.exports = relativeUrlHelper;
|
||||
//# sourceMappingURL=relative_url.js.map
|
||||
1
node_modules/hexo-util/dist/relative_url.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/relative_url.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"relative_url.js","sourceRoot":"","sources":["../lib/relative_url.ts"],"names":[],"mappings":";;;;AAAA,8DAAqC;AACrC,oDAA4B;AAC5B,MAAM,KAAK,GAAG,IAAI,eAAK,EAAU,CAAC;AAElC,SAAS,iBAAiB,CAAC,IAAI,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE;IAC3C,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE;QACvC,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAC1D,IAAI,CAAC,GAAG,CAAC,CAAC;QAEV,OAAO,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;YACtB,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC;gBAAE,MAAM;SACxC;QAED,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAE3B,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YACjD,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACnB;QAED,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC;QAE7B,oFAAoF;QACpF,IAAI,SAAS,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE;YAC/D,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;SACxD;QAED,OAAO,IAAA,oBAAS,EAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC;AAED,iBAAS,iBAAiB,CAAC"}
|
||||
6
node_modules/hexo-util/dist/slugize.d.ts
generated
vendored
Normal file
6
node_modules/hexo-util/dist/slugize.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
interface Options {
|
||||
separator?: string;
|
||||
transform?: number;
|
||||
}
|
||||
declare function slugize(str: string, options?: Options): string;
|
||||
export = slugize;
|
||||
34
node_modules/hexo-util/dist/slugize.js
generated
vendored
Normal file
34
node_modules/hexo-util/dist/slugize.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const escape_diacritic_1 = __importDefault(require("./escape_diacritic"));
|
||||
const escape_regexp_1 = __importDefault(require("./escape_regexp"));
|
||||
// eslint-disable-next-line no-control-regex
|
||||
const rControl = /[\u0000-\u001f]/g;
|
||||
const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'<>,.?/]+/g;
|
||||
function slugize(str, options = {}) {
|
||||
if (typeof str !== 'string')
|
||||
throw new TypeError('str must be a string!');
|
||||
const separator = options.separator || '-';
|
||||
const escapedSep = (0, escape_regexp_1.default)(separator);
|
||||
const result = (0, escape_diacritic_1.default)(str)
|
||||
// Remove control characters
|
||||
.replace(rControl, '')
|
||||
// Replace special characters
|
||||
.replace(rSpecial, separator)
|
||||
// Remove continous separators
|
||||
.replace(new RegExp(`${escapedSep}{2,}`, 'g'), separator)
|
||||
// Remove prefixing and trailing separtors
|
||||
.replace(new RegExp(`^${escapedSep}+|${escapedSep}+$`, 'g'), '');
|
||||
switch (options.transform) {
|
||||
case 1:
|
||||
return result.toLowerCase();
|
||||
case 2:
|
||||
return result.toUpperCase();
|
||||
default:
|
||||
return result;
|
||||
}
|
||||
}
|
||||
module.exports = slugize;
|
||||
//# sourceMappingURL=slugize.js.map
|
||||
1
node_modules/hexo-util/dist/slugize.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/slugize.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"slugize.js","sourceRoot":"","sources":["../lib/slugize.ts"],"names":[],"mappings":";;;;AAAA,0EAAiD;AACjD,oEAA2C;AAC3C,4CAA4C;AAC5C,MAAM,QAAQ,GAAG,kBAAkB,CAAC;AACpC,MAAM,QAAQ,GAAG,2CAA2C,CAAC;AAO7D,SAAS,OAAO,CAAC,GAAW,EAAE,UAAmB,EAAE;IACjD,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,uBAAuB,CAAC,CAAC;IAE1E,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,GAAG,CAAC;IAC3C,MAAM,UAAU,GAAG,IAAA,uBAAY,EAAC,SAAS,CAAC,CAAC;IAE3C,MAAM,MAAM,GAAG,IAAA,0BAAe,EAAC,GAAG,CAAC;QACjC,4BAA4B;SAC3B,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;QACtB,6BAA6B;SAC5B,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC;QAC7B,8BAA8B;SAC7B,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,UAAU,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,CAAC;QACzD,0CAA0C;SACzC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,UAAU,KAAK,UAAU,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IAEnE,QAAQ,OAAO,CAAC,SAAS,EAAE;QACzB,KAAK,CAAC;YACJ,OAAO,MAAM,CAAC,WAAW,EAAE,CAAC;QAE9B,KAAK,CAAC;YACJ,OAAO,MAAM,CAAC,WAAW,EAAE,CAAC;QAE9B;YACE,OAAO,MAAM,CAAC;KACjB;AACH,CAAC;AAED,iBAAS,OAAO,CAAC"}
|
||||
9
node_modules/hexo-util/dist/spawn.d.ts
generated
vendored
Normal file
9
node_modules/hexo-util/dist/spawn.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
import { SpawnOptions } from 'child_process';
|
||||
interface Options extends SpawnOptions {
|
||||
verbose?: boolean;
|
||||
encoding?: BufferEncoding;
|
||||
}
|
||||
declare function promiseSpawn(command: string, args?: string | string[] | Options, options?: Options): Promise<string | void | Buffer>;
|
||||
export = promiseSpawn;
|
||||
64
node_modules/hexo-util/dist/spawn.js
generated
vendored
Normal file
64
node_modules/hexo-util/dist/spawn.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const cross_spawn_1 = __importDefault(require("cross-spawn"));
|
||||
const cache_stream_1 = __importDefault(require("./cache_stream"));
|
||||
class StatusError extends Error {
|
||||
}
|
||||
function promiseSpawn(command, args = [], options = {}) {
|
||||
if (!command)
|
||||
throw new TypeError('command is required!');
|
||||
if (typeof args === 'string')
|
||||
args = [args];
|
||||
if (!Array.isArray(args)) {
|
||||
options = args;
|
||||
args = [];
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
const task = (0, cross_spawn_1.default)(command, args, options);
|
||||
const verbose = options.verbose;
|
||||
const { encoding = 'utf8' } = options;
|
||||
const stdoutCache = new cache_stream_1.default();
|
||||
const stderrCache = new cache_stream_1.default();
|
||||
if (task.stdout) {
|
||||
const stdout = task.stdout.pipe(stdoutCache);
|
||||
if (verbose)
|
||||
stdout.pipe(process.stdout);
|
||||
}
|
||||
if (task.stderr) {
|
||||
const stderr = task.stderr.pipe(stderrCache);
|
||||
if (verbose)
|
||||
stderr.pipe(process.stderr);
|
||||
}
|
||||
task.on('close', code => {
|
||||
if (code) {
|
||||
const e = new StatusError(getCache(stderrCache, encoding));
|
||||
e.code = code;
|
||||
return reject(e);
|
||||
}
|
||||
resolve(getCache(stdoutCache, encoding));
|
||||
});
|
||||
task.on('error', reject);
|
||||
// Listen to exit events if neither stdout and stderr exist (inherit stdio)
|
||||
if (!task.stdout && !task.stderr) {
|
||||
task.on('exit', code => {
|
||||
if (code) {
|
||||
const e = new StatusError('Spawn failed');
|
||||
e.code = code;
|
||||
return reject(e);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function getCache(stream, encoding) {
|
||||
const buf = stream.getCache();
|
||||
stream.destroy();
|
||||
if (!encoding)
|
||||
return buf;
|
||||
return buf.toString(encoding);
|
||||
}
|
||||
module.exports = promiseSpawn;
|
||||
//# sourceMappingURL=spawn.js.map
|
||||
1
node_modules/hexo-util/dist/spawn.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/spawn.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../lib/spawn.ts"],"names":[],"mappings":";;;;AAAA,8DAAgC;AAChC,kEAAyC;AAQzC,MAAM,WAAY,SAAQ,KAAK;CAE9B;AAED,SAAS,YAAY,CAAC,OAAe,EAAE,OAAoC,EAAE,EAAE,UAAmB,EAAE;IAClG,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,SAAS,CAAC,sBAAsB,CAAC,CAAC;IAE1D,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IAE5C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACxB,OAAO,GAAG,IAAI,CAAC;QACf,IAAI,GAAG,EAAE,CAAC;KACX;IAED,OAAO,IAAI,OAAO,CAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7D,MAAM,IAAI,GAAG,IAAA,qBAAK,EAAC,OAAO,EAAE,IAAgB,EAAE,OAAO,CAAC,CAAC;QACvD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAChC,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC;QACtC,MAAM,WAAW,GAAG,IAAI,sBAAW,EAAE,CAAC;QACtC,MAAM,WAAW,GAAG,IAAI,sBAAW,EAAE,CAAC;QAEtC,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC7C,IAAI,OAAO;gBAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,C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GAAG,CAAC;IAE1B,OAAO,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC;AAED,iBAAS,YAAY,CAAC"}
|
||||
2
node_modules/hexo-util/dist/strip_html.d.ts
generated
vendored
Normal file
2
node_modules/hexo-util/dist/strip_html.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare function striptags(html?: string | String): string;
|
||||
export = striptags;
|
||||
105
node_modules/hexo-util/dist/strip_html.js
generated
vendored
Normal file
105
node_modules/hexo-util/dist/strip_html.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
"use strict";
|
||||
const STATE_PLAINTEXT = Symbol('plaintext');
|
||||
const STATE_HTML = Symbol('html');
|
||||
const STATE_COMMENT = Symbol('comment');
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
function striptags(html = '') {
|
||||
// if not string, then safely return an empty string
|
||||
if (typeof html !== 'string' && !(html instanceof String)) {
|
||||
return '';
|
||||
}
|
||||
let state = STATE_PLAINTEXT;
|
||||
let tag_buffer = '';
|
||||
let depth = 0;
|
||||
let in_quote_char = '';
|
||||
let output = '';
|
||||
const { length } = html;
|
||||
for (let idx = 0; idx < length; idx++) {
|
||||
const char = html[idx];
|
||||
if (state === STATE_PLAINTEXT) {
|
||||
switch (char) {
|
||||
case '<':
|
||||
state = STATE_HTML;
|
||||
tag_buffer = tag_buffer + char;
|
||||
break;
|
||||
default:
|
||||
output += char;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (state === STATE_HTML) {
|
||||
switch (char) {
|
||||
case '<':
|
||||
// ignore '<' if inside a quote
|
||||
if (in_quote_char)
|
||||
break;
|
||||
// we're seeing a nested '<'
|
||||
depth++;
|
||||
break;
|
||||
case '>':
|
||||
// ignore '>' if inside a quote
|
||||
if (in_quote_char) {
|
||||
break;
|
||||
}
|
||||
// something like this is happening: '<<>>'
|
||||
if (depth) {
|
||||
depth--;
|
||||
break;
|
||||
}
|
||||
// this is closing the tag in tag_buffer
|
||||
in_quote_char = '';
|
||||
state = STATE_PLAINTEXT;
|
||||
// tag_buffer += '>';
|
||||
tag_buffer = '';
|
||||
break;
|
||||
case '"':
|
||||
case '\'':
|
||||
// catch both single and double quotes
|
||||
if (char === in_quote_char) {
|
||||
in_quote_char = '';
|
||||
}
|
||||
else {
|
||||
in_quote_char = in_quote_char || char;
|
||||
}
|
||||
tag_buffer = tag_buffer + char;
|
||||
break;
|
||||
case '-':
|
||||
if (tag_buffer === '<!-') {
|
||||
state = STATE_COMMENT;
|
||||
}
|
||||
tag_buffer = tag_buffer + char;
|
||||
break;
|
||||
case ' ':
|
||||
case '\n':
|
||||
if (tag_buffer === '<') {
|
||||
state = STATE_PLAINTEXT;
|
||||
output += '< ';
|
||||
tag_buffer = '';
|
||||
break;
|
||||
}
|
||||
tag_buffer = tag_buffer + char;
|
||||
break;
|
||||
default:
|
||||
tag_buffer = tag_buffer + char;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (state === STATE_COMMENT) {
|
||||
switch (char) {
|
||||
case '>':
|
||||
if (tag_buffer.slice(-2) === '--') {
|
||||
// close the comment
|
||||
state = STATE_PLAINTEXT;
|
||||
}
|
||||
tag_buffer = '';
|
||||
break;
|
||||
default:
|
||||
tag_buffer = tag_buffer + char;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
module.exports = striptags;
|
||||
//# sourceMappingURL=strip_html.js.map
|
||||
1
node_modules/hexo-util/dist/strip_html.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/strip_html.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"strip_html.js","sourceRoot":"","sources":["../lib/strip_html.ts"],"names":[],"mappings":";AAAA,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAC5C,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAClC,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,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ErB,UAAU,GAAG,EAAE,CAAC;oBAChB,MAAM;gBAER,KAAK,GAAG,CAAC;gBACT,KAAK,IAAI;oBACP,sCAAsC;oBAEtC,IAAI,IAAI,KAAK,aAAa,EAAE;wBAC1B,aAAa,GAAG,EAAE,CAAC;qBACpB;yBAAM;wBACL,aAAa,GAAG,aAAa,IAAI,IAAI,CAAC;qBACvC;oBAED,UAAU,GAAG,UAAU,GAAG,IAAI,CAAC;oBAC/B,MAAM;gBAER,KAAK,GAAG;oBACN,IAAI,UAAU,KAAK,KAAK,EAAE;wBACxB,KAAK,GAAG,aAAa,CAAC;qBACvB;oBAED,UAAU,GAAG,UAAU,GAAG,IAAI,CAAC;oBAC/B,MAAM;gBAER,KAAK,GAAG,CAAC;gBACT,KAAK,IAAI;oBACP,IAAI,UAAU,KAAK,GAAG,EAAE;wBACtB,KAAK,GAAG,eAAe,CAAC;wBACxB,MAAM,IAAI,IAAI,CAAC;wBACf,UAAU,GAAG,EAAE,CAAC;wBAEhB,MAAM;qBACP;oBAED,UAAU,GAAG,UAAU,GAAG,IAAI,CAAC;oBAC/B,MAAM;gBAER;oBACE,UAAU,GAAG,UAAU,GAAG,IAAI,CAAC;oBAC/B,MAAM;aACT;SACF;aAAM,IAAI,KAAK,KAAK,aAAa,EAAE;YAClC,QAAQ,IAAI,EAAE;gBACZ,KAAK,GAAG;oBACN,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;wBACjC,oBAAoB;wBACpB,KAAK,GAAG,eAAe,CAAC;qBACzB;oBAED,UAAU,GAAG,EAAE,CAAC;oBAChB,MAAM;gBAER;oBACE,UAAU,GAAG,UAAU,GAAG,IAAI,CAAC;oBAC/B,MAAM;aACT;SACF;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,iBAAS,SAAS,CAAC"}
|
||||
2
node_modules/hexo-util/dist/strip_indent.d.ts
generated
vendored
Normal file
2
node_modules/hexo-util/dist/strip_indent.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare const _default: any;
|
||||
export = _default;
|
||||
3
node_modules/hexo-util/dist/strip_indent.js
generated
vendored
Normal file
3
node_modules/hexo-util/dist/strip_indent.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
module.exports = require('strip-indent');
|
||||
//# sourceMappingURL=strip_indent.js.map
|
||||
1
node_modules/hexo-util/dist/strip_indent.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/strip_indent.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"strip_indent.js","sourceRoot":"","sources":["../lib/strip_indent.ts"],"names":[],"mappings":";AAAA,iBAAS,OAAO,CAAC,cAAc,CAAC,CAAC"}
|
||||
8
node_modules/hexo-util/dist/toc_obj.d.ts
generated
vendored
Normal file
8
node_modules/hexo-util/dist/toc_obj.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
interface Result {
|
||||
text: string;
|
||||
id: string;
|
||||
level: number;
|
||||
unnumbered?: boolean;
|
||||
}
|
||||
declare function tocObj(str: string, options?: {}): Result[];
|
||||
export = tocObj;
|
||||
58
node_modules/hexo-util/dist/toc_obj.js
generated
vendored
Normal file
58
node_modules/hexo-util/dist/toc_obj.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const htmlparser2_1 = require("htmlparser2");
|
||||
const escape_html_1 = __importDefault(require("./escape_html"));
|
||||
const nonWord = /^\s*[^a-zA-Z0-9]\s*$/;
|
||||
const parseHtml = (html) => {
|
||||
const handler = new htmlparser2_1.DomHandler(null, {});
|
||||
new htmlparser2_1.Parser(handler, {}).end(html);
|
||||
return handler.dom;
|
||||
};
|
||||
const getId = ({ attribs = {}, parent }) => {
|
||||
return attribs.id || (!parent ? '' : getId(parent));
|
||||
};
|
||||
/**
|
||||
* Identify a heading that to be unnumbered or not.
|
||||
*/
|
||||
const isUnnumbered = ({ attribs = {} }) => {
|
||||
return attribs['data-toc-unnumbered'] === 'true';
|
||||
};
|
||||
function tocObj(str, options = {}) {
|
||||
const { min_depth, max_depth } = Object.assign({
|
||||
min_depth: 1,
|
||||
max_depth: 6
|
||||
}, options);
|
||||
const headingsSelector = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].slice(min_depth - 1, max_depth);
|
||||
const headings = htmlparser2_1.DomUtils.find(element => 'tagName' in element && headingsSelector.includes(element.tagName), parseHtml(str), true, Infinity);
|
||||
const headingsLen = headings.length;
|
||||
if (!headingsLen)
|
||||
return [];
|
||||
const result = [];
|
||||
for (let i = 0; i < headingsLen; i++) {
|
||||
const el = headings[i];
|
||||
const level = +el.name[1];
|
||||
const id = getId(el);
|
||||
const unnumbered = isUnnumbered(el);
|
||||
let text = '';
|
||||
for (const element of el.children) {
|
||||
const elText = htmlparser2_1.DomUtils.textContent(element);
|
||||
// Skip permalink symbol wrapped in <a>
|
||||
// permalink is a single non-word character, word = [a-Z0-9]
|
||||
// permalink may be wrapped in whitespace(s)
|
||||
if (!('name' in element) || element.name !== 'a' || !nonWord.test(elText)) {
|
||||
text += (0, escape_html_1.default)(elText);
|
||||
}
|
||||
}
|
||||
if (!text)
|
||||
text = (0, escape_html_1.default)(htmlparser2_1.DomUtils.textContent(el));
|
||||
const res = { text, id, level };
|
||||
if (unnumbered)
|
||||
res.unnumbered = true;
|
||||
result.push(res);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
module.exports = tocObj;
|
||||
//# sourceMappingURL=toc_obj.js.map
|
||||
1
node_modules/hexo-util/dist/toc_obj.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/toc_obj.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"toc_obj.js","sourceRoot":"","sources":["../lib/toc_obj.ts"],"names":[],"mappings":";;;;AAAA,6CAA2D;AAG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ClB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,iBAAS,MAAM,CAAC"}
|
||||
7
node_modules/hexo-util/dist/truncate.d.ts
generated
vendored
Normal file
7
node_modules/hexo-util/dist/truncate.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
interface Options {
|
||||
length?: number;
|
||||
omission?: string;
|
||||
separator?: string;
|
||||
}
|
||||
declare function truncate(str: string, options?: Options): string;
|
||||
export = truncate;
|
||||
30
node_modules/hexo-util/dist/truncate.js
generated
vendored
Normal file
30
node_modules/hexo-util/dist/truncate.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
function truncate(str, options = {}) {
|
||||
if (typeof str !== 'string')
|
||||
throw new TypeError('str must be a string!');
|
||||
const length = options.length || 30;
|
||||
const omission = options.omission || '...';
|
||||
const { separator } = options;
|
||||
const omissionLength = omission.length;
|
||||
if (str.length < length)
|
||||
return str;
|
||||
if (separator) {
|
||||
const words = str.split(separator);
|
||||
let result = '';
|
||||
let resultLength = 0;
|
||||
for (const word of words) {
|
||||
if (resultLength + word.length + omissionLength < length) {
|
||||
result += word + separator;
|
||||
resultLength = result.length;
|
||||
}
|
||||
else {
|
||||
return result.substring(0, resultLength - 1) + omission;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return str.substring(0, length - omissionLength) + omission;
|
||||
}
|
||||
}
|
||||
module.exports = truncate;
|
||||
//# sourceMappingURL=truncate.js.map
|
||||
1
node_modules/hexo-util/dist/truncate.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/truncate.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"truncate.js","sourceRoot":"","sources":["../lib/truncate.ts"],"names":[],"mappings":";AAMA,SAAS,QAAQ,CAAC,GAAW,EAAE,UAAmB,EAAE;IAClD,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,uBAAuB,CAAC,CAAC;IAE1E,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;IACpC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC;IAC3C,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC;IAEvC,IAAI,GAAG,CAAC,MAAM,GAAG,MAAM;QAAE,OAAO,GAAG,CAAC;IAEpC,IAAI,SAAS,EAAE;QACb,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACnC,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,YAAY,GAAG,CAAC,CAAC;QAErB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,IAAI,YAAY,GAAG,IAAI,CAAC,MAAM,GAAG,cAAc,GAAG,MAAM,EAAE;gBACxD,MAAM,IAAI,IAAI,GAAG,SAAS,CAAC;gBAC3B,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;aAC9B;iBAAM;gBACL,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;aACzD;SACF;KACF;SAAM;QACL,OAAO,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC,GAAG,QAAQ,CAAC;KAC7D;AACH,CAAC;AAED,iBAAS,QAAQ,CAAC"}
|
||||
2
node_modules/hexo-util/dist/unescape_html.d.ts
generated
vendored
Normal file
2
node_modules/hexo-util/dist/unescape_html.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare const unescapeHTML: (str: string) => string;
|
||||
export = unescapeHTML;
|
||||
19
node_modules/hexo-util/dist/unescape_html.js
generated
vendored
Normal file
19
node_modules/hexo-util/dist/unescape_html.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
const htmlEntityMap = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
''': '\'',
|
||||
'`': '`',
|
||||
'/': '/',
|
||||
'=': '='
|
||||
};
|
||||
const regexHtml = new RegExp(Object.keys(htmlEntityMap).join('|'), 'g');
|
||||
const unescapeHTML = (str) => {
|
||||
if (typeof str !== 'string')
|
||||
throw new TypeError('str must be a string!');
|
||||
return str.replace(regexHtml, a => htmlEntityMap[a]);
|
||||
};
|
||||
module.exports = unescapeHTML;
|
||||
//# sourceMappingURL=unescape_html.js.map
|
||||
1
node_modules/hexo-util/dist/unescape_html.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/unescape_html.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"unescape_html.js","sourceRoot":"","sources":["../lib/unescape_html.ts"],"names":[],"mappings":";AAAA,MAAM,aAAa,GAAG;IACpB,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,QAAQ,EAAE,GAAG;IACb,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,GAAG;IACZ,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,GAAG;CACd,CAAC;AAEF,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AAExE,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,EAAE;IACnC,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,uBAAuB,CAAC,CAAC;IAE1E,OAAO,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,iBAAS,YAAY,CAAC"}
|
||||
21
node_modules/hexo-util/dist/url_for.d.ts
generated
vendored
Normal file
21
node_modules/hexo-util/dist/url_for.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* url_for options type
|
||||
* @example
|
||||
* // to call this type
|
||||
* type urlOpt = Parameters<typeof import('hexo-util')['url_for']>[1];
|
||||
*/
|
||||
interface UrlForOptions {
|
||||
relative?: boolean;
|
||||
}
|
||||
/**
|
||||
* get url relative to base URL (config_yml.url)
|
||||
* @param path relative path inside `source` folder (config_yml.source_dir)
|
||||
* @param options
|
||||
* @returns
|
||||
* @example
|
||||
* // global `hexo` must be exist when used this function inside plugin
|
||||
* const Hutil = require('hexo-util')
|
||||
* console.log(Hutil.url_for.bind(hexo)('path/to/file/inside/source.css')); // https://example.com/path/to/file/inside/source.css
|
||||
*/
|
||||
declare function urlForHelper(path?: string, options?: UrlForOptions | null): string;
|
||||
export = urlForHelper;
|
||||
54
node_modules/hexo-util/dist/url_for.js
generated
vendored
Normal file
54
node_modules/hexo-util/dist/url_for.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const url_1 = require("url");
|
||||
const encode_url_1 = __importDefault(require("./encode_url"));
|
||||
const relative_url_1 = __importDefault(require("./relative_url"));
|
||||
const pretty_urls_1 = __importDefault(require("./pretty_urls"));
|
||||
const cache_1 = __importDefault(require("./cache"));
|
||||
const cache = new cache_1.default();
|
||||
/**
|
||||
* get url relative to base URL (config_yml.url)
|
||||
* @param path relative path inside `source` folder (config_yml.source_dir)
|
||||
* @param options
|
||||
* @returns
|
||||
* @example
|
||||
* // global `hexo` must be exist when used this function inside plugin
|
||||
* const Hutil = require('hexo-util')
|
||||
* console.log(Hutil.url_for.bind(hexo)('path/to/file/inside/source.css')); // https://example.com/path/to/file/inside/source.css
|
||||
*/
|
||||
function urlForHelper(path = '/', options = {}) {
|
||||
if (/^(#|\/\/|http(s)?:)/.test(path))
|
||||
return path;
|
||||
const { config } = this;
|
||||
options = Object.assign({
|
||||
relative: config.relative_link
|
||||
},
|
||||
// fallback empty object when options filled with NULL
|
||||
options || {});
|
||||
// Resolve relative url
|
||||
if (options.relative) {
|
||||
return (0, relative_url_1.default)(this.path, path);
|
||||
}
|
||||
const { root } = config;
|
||||
const prettyUrlsOptions = Object.assign({
|
||||
trailing_index: true,
|
||||
trailing_html: true
|
||||
}, config.pretty_urls);
|
||||
// cacheId is designed to works across different hexo.config & options
|
||||
return cache.apply(`${config.url}-${root}-${prettyUrlsOptions.trailing_index}-${prettyUrlsOptions.trailing_html}-${path}`, () => {
|
||||
const sitehost = (0, url_1.parse)(config.url).hostname || config.url;
|
||||
const data = new URL(path, `http://${sitehost}`);
|
||||
// Exit if input is an external link or a data url
|
||||
if (data.hostname !== sitehost || data.origin === 'null') {
|
||||
return path;
|
||||
}
|
||||
// Prepend root path
|
||||
path = (0, encode_url_1.default)((root + path).replace(/\/{2,}/g, '/'));
|
||||
path = (0, pretty_urls_1.default)(path, prettyUrlsOptions);
|
||||
return path;
|
||||
});
|
||||
}
|
||||
module.exports = urlForHelper;
|
||||
//# sourceMappingURL=url_for.js.map
|
||||
1
node_modules/hexo-util/dist/url_for.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/url_for.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"url_for.js","sourceRoot":"","sources":["../lib/url_for.ts"],"names":[],"mappings":";;;;AAAA,6BAA4B;AAC5B,8DAAqC;AACrC,kEAA0C;AAC1C,gEAAuC;AACvC,oDAA4B;AAC5B,MAAM,KAAK,GAAG,IAAI,eAAK,EAAU,CAAC;AAYlC;;;;;;;;;GASG;AACH,SAAS,YAAY,CAAC,IAAI,GAAG,GAAG,EAAE,UAAgC,EAAE;IAClE,IAAI,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAElD,MAAM,EAAE,MAAM,EAAE,GAAG,IAA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AAS,YAAY,CAAC"}
|
||||
5
node_modules/hexo-util/dist/word_wrap.d.ts
generated
vendored
Normal file
5
node_modules/hexo-util/dist/word_wrap.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
interface Options {
|
||||
width?: number;
|
||||
}
|
||||
declare function wordWrap(str: string, options?: Options): string;
|
||||
export = wordWrap;
|
||||
18
node_modules/hexo-util/dist/word_wrap.js
generated
vendored
Normal file
18
node_modules/hexo-util/dist/word_wrap.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
// https://github.com/rails/rails/blob/v4.2.0/actionview/lib/action_view/helpers/text_helper.rb#L240
|
||||
function wordWrap(str, options = {}) {
|
||||
if (typeof str !== 'string')
|
||||
throw new TypeError('str must be a string!');
|
||||
const width = options.width || 80;
|
||||
const regex = new RegExp(`(.{1,${width}})(\\s+|$)`, 'g');
|
||||
const lines = str.split('\n');
|
||||
for (let i = 0, len = lines.length; i < len; i++) {
|
||||
const line = lines[i];
|
||||
if (line.length > width) {
|
||||
lines[i] = line.replace(regex, '$1\n').trim();
|
||||
}
|
||||
}
|
||||
return lines.join('\n');
|
||||
}
|
||||
module.exports = wordWrap;
|
||||
//# sourceMappingURL=word_wrap.js.map
|
||||
1
node_modules/hexo-util/dist/word_wrap.js.map
generated
vendored
Normal file
1
node_modules/hexo-util/dist/word_wrap.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"word_wrap.js","sourceRoot":"","sources":["../lib/word_wrap.ts"],"names":[],"mappings":";AAIA,oGAAoG;AACpG,SAAS,QAAQ,CAAC,GAAW,EAAE,UAAmB,EAAE;IAClD,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,uBAAuB,CAAC,CAAC;IAE1E,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;IAClC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,QAAQ,KAAK,YAAY,EAAE,GAAG,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QAChD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAEtB,IAAI,IAAI,CAAC,MAAM,GAAG,KAAK,EAAE;YACvB,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;SAC/C;KACF;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,iBAAS,QAAQ,CAAC"}
|
||||
1
node_modules/hexo-util/highlight_alias.json
generated
vendored
Normal file
1
node_modules/hexo-util/highlight_alias.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
70
node_modules/hexo-util/package.json
generated
vendored
Normal file
70
node_modules/hexo-util/package.json
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"name": "hexo-util",
|
||||
"version": "3.3.0",
|
||||
"description": "Utilities for Hexo.",
|
||||
"main": "dist/index",
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"prepublishOnly": "npm install && npm run clean && npm run build",
|
||||
"build": "tsc -b",
|
||||
"clean": "tsc -b --clean",
|
||||
"preeslint": "npm run clean && npm run build",
|
||||
"eslint": "eslint lib test",
|
||||
"pretest": "npm run clean && npm run build",
|
||||
"test": "mocha --require ts-node/register",
|
||||
"test-cov": "c8 --reporter=lcovonly npm run test",
|
||||
"build:highlight": "node scripts/build_highlight_alias.js",
|
||||
"postinstall": "npm run build:highlight"
|
||||
},
|
||||
"files": [
|
||||
"dist/**",
|
||||
"scripts/",
|
||||
"highlight_alias.json"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/hexojs/hexo-util.git"
|
||||
},
|
||||
"homepage": "https://hexo.io/",
|
||||
"keywords": [
|
||||
"hexo",
|
||||
"util",
|
||||
"utilities"
|
||||
],
|
||||
"author": "Tommy Chen <tommy351@gmail.com> (https://zespia.tw)",
|
||||
"maintainers": [
|
||||
"Abner Chou <hi@abnerchou.me> (https://abnerchou.me)"
|
||||
],
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.3.11",
|
||||
"@types/cross-spawn": "^6.0.2",
|
||||
"@types/mocha": "^10.0.6",
|
||||
"@types/node": "^18.11.8",
|
||||
"@types/prismjs": "^1.26.0",
|
||||
"@types/rewire": "^2.5.30",
|
||||
"c8": "^9.1.0",
|
||||
"chai": "^4.3.6",
|
||||
"domhandler": "^5.0.3",
|
||||
"eslint": "^8.23.0",
|
||||
"eslint-config-hexo": "^5.0.0",
|
||||
"html-entities": "^2.3.3",
|
||||
"html-tag-validator": "^1.6.0",
|
||||
"mocha": "^10.0.0",
|
||||
"rewire": "^6.0.0",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^5.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"camel-case": "^4.1.2",
|
||||
"cross-spawn": "^7.0.3",
|
||||
"deepmerge": "^4.2.2",
|
||||
"highlight.js": "^11.6.0",
|
||||
"htmlparser2": "^9.0.0",
|
||||
"prismjs": "^1.29.0",
|
||||
"strip-indent": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
}
|
||||
26
node_modules/hexo-util/scripts/build_highlight_alias.js
generated
vendored
Normal file
26
node_modules/hexo-util/scripts/build_highlight_alias.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
const hljs = require('highlight.js');
|
||||
const fs = require('fs');
|
||||
|
||||
const languages = hljs.listLanguages();
|
||||
const result = {
|
||||
languages: languages,
|
||||
aliases: {}
|
||||
};
|
||||
|
||||
languages.forEach(lang => {
|
||||
result.aliases[lang] = lang;
|
||||
|
||||
const aliases = hljs.getLanguage(lang).aliases;
|
||||
|
||||
if (aliases) {
|
||||
aliases.forEach(alias => {
|
||||
result.aliases[alias] = lang;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const stream = fs.createWriteStream('highlight_alias.json');
|
||||
stream.write(JSON.stringify(result));
|
||||
stream.on('end', () => {
|
||||
stream.end();
|
||||
});
|
||||
Reference in New Issue
Block a user