Skip to content

Commit b0b2d48

Browse files
authored
Merge branch 'develop' into docsify-updated
2 parents a0189cc + 74f17a0 commit b0b2d48

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

Diff for: docs/embed-files.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Then the content of `example.md` will be displayed directly here;
1616

1717
You can check the original content for [example.md](_media/example.md ':ignore').
1818

19-
Normally, this will compiled into a link, but in docsify, if you add `:include` it will be embedded.
19+
Normally, this will compiled into a link, but in docsify, if you add `:include` it will be embedded. You can use single or double quotation marks around as you like.
2020

2121
External links can be used too - just replace the target. If you want to use a gist URL, see [Embed a gist](#embed-a-gist) section.
2222

Diff for: src/core/render/utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export function getAndRemoveConfig(str = '') {
2323

2424
if (str) {
2525
str = str
26-
.replace(/^'/, '')
27-
.replace(/'$/, '')
26+
.replace(/^('|")/, '')
27+
.replace(/('|")$/, '')
2828
.replace(/(?:^|\s):([\w-]+:?)=?([\w-%]+)?/g, (m, key, value) => {
2929
if (key.indexOf(':') === -1) {
3030
config[key] = (value && value.replace(/"/g, '')) || true;

Diff for: test/unit/render-util.test.js

+44-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
const { removeAtag } = require('../../src/core/render/utils');
1+
const {
2+
removeAtag,
3+
getAndRemoveConfig,
4+
} = require('../../src/core/render/utils');
25

36
const { tree } = require(`../../src/core/render/tpl`);
47

@@ -16,6 +19,46 @@ describe('core/render/utils', () => {
1619
expect(result).toEqual('content');
1720
});
1821
});
22+
23+
// getAndRemoveConfig()
24+
// ---------------------------------------------------------------------------
25+
describe('getAndRemoveConfig()', () => {
26+
test('parse simple config', () => {
27+
const result = getAndRemoveConfig(
28+
`[filename](_media/example.md ':include')`
29+
);
30+
31+
expect(result).toMatchObject({
32+
config: {},
33+
str: `[filename](_media/example.md ':include')`,
34+
});
35+
});
36+
37+
test('parse config with arguments', () => {
38+
const result = getAndRemoveConfig(
39+
`[filename](_media/example.md ':include :foo=bar :baz test')`
40+
);
41+
42+
expect(result).toMatchObject({
43+
config: {
44+
foo: 'bar',
45+
baz: true,
46+
},
47+
str: `[filename](_media/example.md ':include test')`,
48+
});
49+
});
50+
51+
test('parse config with double quotes', () => {
52+
const result = getAndRemoveConfig(
53+
`[filename](_media/example.md ":include")`
54+
);
55+
56+
expect(result).toMatchObject({
57+
config: {},
58+
str: `[filename](_media/example.md ":include")`,
59+
});
60+
});
61+
});
1962
});
2063

2164
describe('core/render/tpl', () => {

0 commit comments

Comments
 (0)