@diplodoc/transform 4.34.2-beta1 → 4.35.0-beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/_yfm-only.css +164 -0
- package/dist/css/_yfm-only.css.map +7 -0
- package/dist/css/_yfm-only.min.css +2 -0
- package/dist/css/_yfm-only.min.css.map +7 -0
- package/dist/css/base.css +580 -0
- package/dist/css/base.css.map +7 -0
- package/dist/css/base.min.css +2 -0
- package/dist/css/base.min.css.map +7 -0
- package/dist/css/print.css.map +2 -2
- package/dist/css/yfm.css +124 -98
- package/dist/css/yfm.css.map +3 -3
- package/dist/css/yfm.min.css +1 -1
- package/dist/css/yfm.min.css.map +3 -3
- package/dist/js/_yfm-only.js +223 -0
- package/dist/js/_yfm-only.js.map +7 -0
- package/dist/js/_yfm-only.min.js +2 -0
- package/dist/js/_yfm-only.min.js.map +7 -0
- package/dist/js/base.js +138 -0
- package/dist/js/base.js.map +7 -0
- package/dist/js/base.min.js +2 -0
- package/dist/js/base.min.js.map +7 -0
- package/dist/js/yfm.js +100 -100
- package/dist/js/yfm.js.map +3 -3
- package/dist/js/yfm.min.js +1 -1
- package/dist/js/yfm.min.js.map +3 -3
- package/lib/md.d.ts +2 -2
- package/lib/md.js +2 -2
- package/lib/plugins/csp.d.ts +6 -0
- package/lib/plugins/csp.js +26 -0
- package/lib/plugins/csp.js.map +1 -0
- package/lib/plugins/includes/collect.js +16 -11
- package/lib/plugins/includes/collect.js.map +1 -1
- package/lib/plugins/includes/types.d.ts +1 -0
- package/lib/plugins/tabs.js +11 -1
- package/lib/plugins/tabs.js.map +1 -1
- package/lib/plugins/utils.d.ts +1 -0
- package/lib/plugins/utils.js +10 -1
- package/lib/plugins/utils.js.map +1 -1
- package/lib/plugins/video/const.d.ts +8 -1
- package/lib/plugins/video/const.js +4 -0
- package/lib/plugins/video/const.js.map +1 -1
- package/lib/plugins/video/index.js +12 -3
- package/lib/plugins/video/index.js.map +1 -1
- package/lib/plugins/video/parsers.d.ts +3 -1
- package/lib/plugins/video/parsers.js +59 -28
- package/lib/plugins/video/parsers.js.map +1 -1
- package/lib/plugins/video/types.d.ts +6 -27
- package/lib/plugins/video/utils.js +5 -1
- package/lib/plugins/video/utils.js.map +1 -1
- package/lib/preprocessors/included/index.js +1 -1
- package/lib/preprocessors/included/index.js.map +1 -1
- package/package.json +2 -2
- package/src/js/_yfm-only.ts +1 -0
- package/src/js/base.ts +2 -0
- package/src/js/index.ts +2 -3
- package/src/scss/_yfm-only.scss +12 -0
- package/src/scss/base.scss +4 -0
- package/src/scss/yfm.scss +2 -9
- package/src/transform/index.ts +2 -2
- package/src/transform/md.ts +2 -2
- package/src/transform/plugins/changelog/collect.ts +2 -2
- package/src/transform/plugins/includes/collect.ts +18 -23
- package/src/transform/plugins/includes/types.ts +1 -0
- package/src/transform/plugins/tabs.ts +11 -1
- package/src/transform/plugins/utils.ts +16 -0
- package/src/transform/plugins/video/const.ts +11 -0
- package/src/transform/plugins/video/index.ts +15 -3
- package/src/transform/plugins/video/parsers.ts +63 -28
- package/src/transform/plugins/video/types.ts +8 -7
- package/src/transform/plugins/video/utils.ts +5 -1
- package/src/transform/preprocessors/included/index.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Services} from './const';
|
|
2
2
|
|
|
3
3
|
const ytRegex = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/;
|
|
4
4
|
export function youtubeParser(url: string) {
|
|
@@ -39,45 +39,80 @@ export function yandexParser(url: string) {
|
|
|
39
39
|
return match ? match[1] : url;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const vkRegex = /^https:\/\/vk
|
|
42
|
+
const vkRegex = /^https:\/\/vk\.com\/video_ext\.php\?(oid=[-\d]+&id=[-\d]+)/;
|
|
43
43
|
export function vkParser(url: string) {
|
|
44
44
|
const match = url.match(vkRegex);
|
|
45
45
|
return match ? match[1] : url;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
const rutubeRegex = /^https:\/\/rutube\.ru\/video\/([a-zA-Z0-9]+)\/?/;
|
|
49
|
+
export function rutubeParser(url: string) {
|
|
50
|
+
const match = url.match(rutubeRegex);
|
|
51
|
+
return match ? match[1] : url;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const dzenRegex = /^https:\/\/dzen\.ru\/video\/watch\/([a-zA-Z0-9]+)/;
|
|
55
|
+
export function dzenParser(url: string) {
|
|
56
|
+
const match = url.match(dzenRegex);
|
|
57
|
+
return match ? match[1] : url;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const supportedServices = Object.entries({
|
|
61
|
+
osf: {
|
|
62
|
+
extract: mfrParser,
|
|
63
|
+
},
|
|
64
|
+
prezi: {
|
|
65
|
+
extract: preziParser,
|
|
66
|
+
},
|
|
67
|
+
vimeo: {
|
|
68
|
+
extract: vimeoParser,
|
|
69
|
+
},
|
|
70
|
+
vine: {
|
|
71
|
+
extract: vineParser,
|
|
72
|
+
},
|
|
73
|
+
yandex: {
|
|
74
|
+
extract: yandexParser,
|
|
75
|
+
},
|
|
76
|
+
youtube: {
|
|
77
|
+
extract: youtubeParser,
|
|
78
|
+
},
|
|
79
|
+
vk: {
|
|
80
|
+
extract: vkParser,
|
|
81
|
+
csp: {
|
|
82
|
+
'frame-src': 'https://vk.com/',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
rutube: {
|
|
86
|
+
extract: rutubeParser,
|
|
87
|
+
csp: {
|
|
88
|
+
'frame-src': 'https://rutube.ru/play/embed/',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
dzen: {
|
|
92
|
+
extract: dzenParser,
|
|
93
|
+
csp: {
|
|
94
|
+
'frame-src': 'https://dzen.ru/embed/',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
}) as Services;
|
|
98
|
+
|
|
99
|
+
export function parseVideoUrl(service: string, url: string) {
|
|
49
100
|
let videoID = '';
|
|
101
|
+
const normalizedService = service.toLowerCase();
|
|
102
|
+
const parsed = supportedServices.find(([name]) => name === normalizedService);
|
|
50
103
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
videoID = youtubeParser(url);
|
|
54
|
-
break;
|
|
55
|
-
case VideoService.Vimeo:
|
|
56
|
-
videoID = vimeoParser(url);
|
|
57
|
-
break;
|
|
58
|
-
case VideoService.Vine:
|
|
59
|
-
videoID = vineParser(url);
|
|
60
|
-
break;
|
|
61
|
-
case VideoService.Prezi:
|
|
62
|
-
videoID = preziParser(url);
|
|
63
|
-
break;
|
|
64
|
-
case VideoService.Osf:
|
|
65
|
-
videoID = mfrParser(url);
|
|
66
|
-
break;
|
|
67
|
-
case VideoService.Yandex:
|
|
68
|
-
videoID = yandexParser(url);
|
|
69
|
-
break;
|
|
70
|
-
case VideoService.Vk:
|
|
71
|
-
videoID = vkParser(url);
|
|
72
|
-
break;
|
|
73
|
-
default:
|
|
74
|
-
return false;
|
|
104
|
+
if (!parsed) {
|
|
105
|
+
return false;
|
|
75
106
|
}
|
|
76
107
|
|
|
108
|
+
const [, videoParser] = parsed;
|
|
109
|
+
|
|
110
|
+
videoID = videoParser.extract(url);
|
|
111
|
+
|
|
77
112
|
// If the videoID field is empty, regex currently make it the close parenthesis.
|
|
78
113
|
if (videoID === ')') {
|
|
79
114
|
videoID = '';
|
|
80
115
|
}
|
|
81
116
|
|
|
82
|
-
return videoID;
|
|
117
|
+
return [videoID, videoParser.csp] as const;
|
|
83
118
|
}
|
|
@@ -7,13 +7,14 @@ export type VideoToken = Token & {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export type VideoServicesOptions = {
|
|
10
|
-
[VideoService
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
[service in VideoService]: {
|
|
11
|
+
width: number | string;
|
|
12
|
+
height: number | string;
|
|
13
|
+
};
|
|
14
|
+
} & {
|
|
15
|
+
vine: {
|
|
16
|
+
embed: 'simple' | (string & {});
|
|
17
|
+
};
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
export type VideoFullOptions = VideoServicesOptions & {
|
|
@@ -18,9 +18,13 @@ export const videoUrl: VideoUrlFn = (service, videoID, options) => {
|
|
|
18
18
|
case 'osf':
|
|
19
19
|
return `https://mfr.osf.io/render?url=https://osf.io/${videoID}/?action=download`;
|
|
20
20
|
case 'yandex':
|
|
21
|
-
return `https://runtime.video.cloud.yandex.net/player/${videoID}`;
|
|
21
|
+
return `https://runtime.video.cloud.yandex.net/player/video/${videoID}`;
|
|
22
22
|
case 'vk':
|
|
23
23
|
return `https://vk.com/video_ext.php?${videoID}`;
|
|
24
|
+
case 'rutube':
|
|
25
|
+
return `https://rutube.ru/play/embed/${videoID}`;
|
|
26
|
+
case 'dzen':
|
|
27
|
+
return `https://dzen.ru/video/embed/${videoID}`;
|
|
24
28
|
default:
|
|
25
29
|
return service;
|
|
26
30
|
}
|
|
@@ -74,7 +74,7 @@ const index: MarkdownItPreprocessorCb<{
|
|
|
74
74
|
|
|
75
75
|
// To reduce file reading we can include the file content into the generated content
|
|
76
76
|
if (included) {
|
|
77
|
-
const lines = input
|
|
77
|
+
const lines = input?.split('\n') || [];
|
|
78
78
|
|
|
79
79
|
// The finction reads the files from bottom to top(!). It stops the loop if it does not have anything to swap.
|
|
80
80
|
// If the function finds something to process then it restarts the loop because the position of the last element has been moved.
|