Skip to content

Commit bafde18

Browse files
authored
Merge branch 'develop' into fix-embed-mermaid
2 parents ff6e3f2 + 9d7dcd5 commit bafde18

File tree

7 files changed

+85
-82
lines changed

7 files changed

+85
-82
lines changed

docs/embed-files.md

Lines changed: 1 addition & 1 deletion
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

docs/write-a-plugin.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ window.$docsify = {
8787
editHtml +
8888
html +
8989
'\n----\n' +
90-
'Last modified {docsify-updated} ' +
90+
'Last modified {docsify-updated}' +
9191
editHtml
9292
);
9393
});
@@ -108,4 +108,5 @@ Current version: <span id='tip-version'>loading</span>
108108

109109
<script>
110110
document.getElementById('tip-version').innerText = Docsify.version
111+
document.getElementsByClassName("lang-js")[2].innerHTML = document.getElementsByClassName("lang-js")[2].innerHTML.replace(/Last modified .*'/,"Last modified {docsify-updated<span>}'</span>")
111112
</script>

package-lock.json

Lines changed: 32 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"*.js": "eslint --fix"
5555
},
5656
"dependencies": {
57-
"dompurify": "^2.2.8",
57+
"dompurify": "^2.2.9",
5858
"marked": "^1.2.9",
5959
"medium-zoom": "^1.0.6",
6060
"opencollective-postinstall": "^2.0.2",

packages/docsify-server-renderer/package-lock.json

Lines changed: 3 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/render/utils.js

Lines changed: 2 additions & 2 deletions
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(/&quot;/g, '')) || true;

test/unit/render-util.test.js

Lines changed: 44 additions & 1 deletion
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)