@apify/docs-theme 1.0.164 → 1.0.165
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/package.json +1 -1
- package/src/markdown.js +15 -2
package/package.json
CHANGED
package/src/markdown.js
CHANGED
|
@@ -11,6 +11,7 @@ const { visitParents } = require('unist-util-visit-parents');
|
|
|
11
11
|
function updateChangelog(changelog) {
|
|
12
12
|
const pipeline = unified()
|
|
13
13
|
.use(remarkParse)
|
|
14
|
+
.use(removeGitCliffMarkers)
|
|
14
15
|
.use(incrementHeadingLevels)
|
|
15
16
|
.use(prettifyPRLinks)
|
|
16
17
|
.use(linkifyUserTags)
|
|
@@ -31,10 +32,21 @@ function updateChangelog(changelog) {
|
|
|
31
32
|
*/
|
|
32
33
|
const incrementHeadingLevels = () => (tree) => {
|
|
33
34
|
visitParents(tree, 'heading', (node) => {
|
|
35
|
+
if (node.depth === 1 && node.children[0].value === 'Changelog') return;
|
|
36
|
+
|
|
34
37
|
node.depth += 1;
|
|
35
38
|
});
|
|
36
39
|
};
|
|
37
40
|
|
|
41
|
+
const removeGitCliffMarkers = () => (tree) => {
|
|
42
|
+
visitParents(tree, 'html', (node) => {
|
|
43
|
+
const gitCliffMarkerRegex = /generated by git-cliff/ig;
|
|
44
|
+
const match = gitCliffMarkerRegex.exec(node.value);
|
|
45
|
+
|
|
46
|
+
if (match) node.value = '';
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
38
50
|
/**
|
|
39
51
|
* Links user tags in the markdown content. This function replaces the user tags
|
|
40
52
|
* (e.g. `@username`) with a link to the user's GitHub profile (just like GitHub's UI).
|
|
@@ -46,9 +58,10 @@ const linkifyUserTags = () => (tree) => {
|
|
|
46
58
|
const userTagRegex = /@([a-zA-Z0-9-]+)(\s|$)/g;
|
|
47
59
|
const match = userTagRegex.exec(node.value);
|
|
48
60
|
|
|
49
|
-
if (!match) return;
|
|
50
|
-
|
|
51
61
|
const directParent = parents[parents.length - 1];
|
|
62
|
+
|
|
63
|
+
if (!match || directParent.type === 'link') return;
|
|
64
|
+
|
|
52
65
|
const nodeIndexInParent = directParent.children.findIndex((x) => x === node);
|
|
53
66
|
|
|
54
67
|
const username = match[1];
|