nodebb-plugin-markdown 13.0.0-pre.2 → 13.0.0-pre.4
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 +18 -23
- package/package-lock.json +676 -3861
- package/package.json +1 -1
- package/public/scss/default.scss +9 -0
package/index.js
CHANGED
|
@@ -181,7 +181,10 @@ const Markdown = {
|
|
|
181
181
|
images: new Map(),
|
|
182
182
|
};
|
|
183
183
|
|
|
184
|
-
if (
|
|
184
|
+
if (
|
|
185
|
+
activitypub.helpers.isUri(data.postData.pid) &&
|
|
186
|
+
(!data.postData.hasOwnProperty('sourceContent') || !data.postData.sourceContent)
|
|
187
|
+
) {
|
|
185
188
|
// content contained is likely already html, bypass parsing
|
|
186
189
|
env.parse = false;
|
|
187
190
|
}
|
|
@@ -379,34 +382,25 @@ const Markdown = {
|
|
|
379
382
|
};
|
|
380
383
|
|
|
381
384
|
parser.renderer.rules.link_open = function (tokens, idx, options, env, self) {
|
|
382
|
-
|
|
383
|
-
const targetIdx = tokens[idx].attrIndex('target');
|
|
384
|
-
let relIdx = tokens[idx].attrIndex('rel');
|
|
385
|
-
const hrefIdx = tokens[idx].attrIndex('href');
|
|
385
|
+
const attributes = new Map(tokens[idx].attrs);
|
|
386
386
|
|
|
387
|
-
if (Markdown.isExternalLink(
|
|
387
|
+
if (attributes.has('href') && Markdown.isExternalLink(attributes.get('href'))) {
|
|
388
|
+
const rel = [];
|
|
388
389
|
if (Markdown.config.externalBlank) {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
} else {
|
|
392
|
-
tokens[idx].attrs[targetIdx][1] = '_blank';
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
if (relIdx < 0) {
|
|
396
|
-
tokens[idx].attrPush(['rel', 'noopener noreferrer']);
|
|
397
|
-
relIdx = tokens[idx].attrIndex('rel');
|
|
398
|
-
} else {
|
|
399
|
-
tokens[idx].attrs[relIdx][1] = 'noopener noreferrer';
|
|
400
|
-
}
|
|
390
|
+
attributes.set('target', '_blank');
|
|
391
|
+
rel.push('noopener', 'noreferrer');
|
|
401
392
|
}
|
|
402
393
|
|
|
403
394
|
if (Markdown.config.nofollow) {
|
|
404
|
-
|
|
405
|
-
tokens[idx].attrPush(['rel', 'nofollow ugc']);
|
|
406
|
-
} else {
|
|
407
|
-
tokens[idx].attrs[relIdx][1] += ' nofollow ugc';
|
|
408
|
-
}
|
|
395
|
+
rel.push('nofollow', 'ugc');
|
|
409
396
|
}
|
|
397
|
+
|
|
398
|
+
attributes.set('rel', rel.join(' '));
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// Clearly indicate hidden links
|
|
402
|
+
if (tokens[idx + 1].type === 'link_close') {
|
|
403
|
+
attributes.set('class', String(`${attributes.get('class') || ''} plugin-markdown-hidden-link small link-danger`).trim());
|
|
410
404
|
}
|
|
411
405
|
|
|
412
406
|
if (!Markdown.config.allowRTLO) {
|
|
@@ -417,6 +411,7 @@ const Markdown = {
|
|
|
417
411
|
}
|
|
418
412
|
}
|
|
419
413
|
|
|
414
|
+
tokens[idx].attrs = Array.from(attributes);
|
|
420
415
|
return renderLink(tokens, idx, options, env, self);
|
|
421
416
|
};
|
|
422
417
|
|