nodebb-plugin-markdown 12.2.6 → 12.2.7
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/index.js +14 -22
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/public/scss/default.scss +9 -0
package/index.js
CHANGED
|
@@ -372,34 +372,25 @@ const Markdown = {
|
|
|
372
372
|
};
|
|
373
373
|
|
|
374
374
|
parser.renderer.rules.link_open = function (tokens, idx, options, env, self) {
|
|
375
|
-
|
|
376
|
-
const targetIdx = tokens[idx].attrIndex('target');
|
|
377
|
-
let relIdx = tokens[idx].attrIndex('rel');
|
|
378
|
-
const hrefIdx = tokens[idx].attrIndex('href');
|
|
375
|
+
const attributes = new Map(tokens[idx].attrs);
|
|
379
376
|
|
|
380
|
-
if (Markdown.isExternalLink(
|
|
377
|
+
if (attributes.has('href') && Markdown.isExternalLink(attributes.get('href'))) {
|
|
378
|
+
const rel = [];
|
|
381
379
|
if (Markdown.config.externalBlank) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
} else {
|
|
385
|
-
tokens[idx].attrs[targetIdx][1] = '_blank';
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
if (relIdx < 0) {
|
|
389
|
-
tokens[idx].attrPush(['rel', 'noopener noreferrer']);
|
|
390
|
-
relIdx = tokens[idx].attrIndex('rel');
|
|
391
|
-
} else {
|
|
392
|
-
tokens[idx].attrs[relIdx][1] = 'noopener noreferrer';
|
|
393
|
-
}
|
|
380
|
+
attributes.set('target', '_blank');
|
|
381
|
+
rel.push('noopener', 'noreferrer');
|
|
394
382
|
}
|
|
395
383
|
|
|
396
384
|
if (Markdown.config.nofollow) {
|
|
397
|
-
|
|
398
|
-
tokens[idx].attrPush(['rel', 'nofollow ugc']);
|
|
399
|
-
} else {
|
|
400
|
-
tokens[idx].attrs[relIdx][1] += ' nofollow ugc';
|
|
401
|
-
}
|
|
385
|
+
rel.push('nofollow', 'ugc');
|
|
402
386
|
}
|
|
387
|
+
|
|
388
|
+
attributes.set('rel', rel.join(' '));
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// Clearly indicate hidden links
|
|
392
|
+
if (tokens[idx + 1].type === 'link_close') {
|
|
393
|
+
attributes.set('class', String(`${attributes.get('class') || ''} plugin-markdown-hidden-link small link-danger`).trim());
|
|
403
394
|
}
|
|
404
395
|
|
|
405
396
|
if (!Markdown.config.allowRTLO) {
|
|
@@ -410,6 +401,7 @@ const Markdown = {
|
|
|
410
401
|
}
|
|
411
402
|
}
|
|
412
403
|
|
|
404
|
+
tokens[idx].attrs = Array.from(attributes);
|
|
413
405
|
return renderLink(tokens, idx, options, env, self);
|
|
414
406
|
};
|
|
415
407
|
|
package/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodebb-plugin-markdown",
|
|
3
|
-
"version": "12.2.
|
|
3
|
+
"version": "12.2.7",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "nodebb-plugin-markdown",
|
|
9
|
-
"version": "12.2.
|
|
9
|
+
"version": "12.2.7",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"highlight.js": "11.4.0",
|
package/package.json
CHANGED
package/public/scss/default.scss
CHANGED