nodebb-plugin-markdown 13.0.0-pre.8 → 13.0.0-pre.9
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 +19 -0
- package/package-lock.json +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -136,6 +136,7 @@ const Markdown = {
|
|
|
136
136
|
if (env.parse && data && data.postData && data.postData.content && parser) {
|
|
137
137
|
data.postData.content = parser.render(data.postData.content, env || {});
|
|
138
138
|
}
|
|
139
|
+
|
|
139
140
|
return Markdown.afterParse(data);
|
|
140
141
|
},
|
|
141
142
|
|
|
@@ -160,6 +161,7 @@ const Markdown = {
|
|
|
160
161
|
beforeParse: async (data) => {
|
|
161
162
|
let env = {
|
|
162
163
|
parse: true,
|
|
164
|
+
type: data.type,
|
|
163
165
|
images: new Map(), // is this still used?
|
|
164
166
|
};
|
|
165
167
|
|
|
@@ -294,6 +296,10 @@ const Markdown = {
|
|
|
294
296
|
parser.renderer.rules.image = function (tokens, idx, options, env, self) {
|
|
295
297
|
const token = tokens[idx];
|
|
296
298
|
const attributes = new Map(token.attrs);
|
|
299
|
+
if (env.type === 'plaintext') {
|
|
300
|
+
const filename = path.basename(attributes.get('src'));
|
|
301
|
+
return `[image: ${filename}]`;
|
|
302
|
+
}
|
|
297
303
|
|
|
298
304
|
// Validate the url
|
|
299
305
|
if (!Markdown.isUrlValid(attributes.get('src'))) { return ''; }
|
|
@@ -304,6 +310,10 @@ const Markdown = {
|
|
|
304
310
|
};
|
|
305
311
|
|
|
306
312
|
parser.renderer.rules.link_open = function (tokens, idx, options, env, self) {
|
|
313
|
+
if (env.type === 'plaintext') {
|
|
314
|
+
return '';
|
|
315
|
+
}
|
|
316
|
+
|
|
307
317
|
const attributes = new Map(tokens[idx].attrs);
|
|
308
318
|
|
|
309
319
|
if (attributes.has('href') && Markdown.isExternalLink(attributes.get('href'))) {
|
|
@@ -337,6 +347,15 @@ const Markdown = {
|
|
|
337
347
|
return renderLink(tokens, idx, options, env, self);
|
|
338
348
|
};
|
|
339
349
|
|
|
350
|
+
parser.renderer.rules.link_close = function (...args) {
|
|
351
|
+
const [,,, env, self] = args;
|
|
352
|
+
if (env === 'plaintext') {
|
|
353
|
+
return '';
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return self.renderToken(...args);
|
|
357
|
+
};
|
|
358
|
+
|
|
340
359
|
parser.renderer.rules.table_open = function (tokens, idx, options, env, self) {
|
|
341
360
|
const classIdx = tokens[idx].attrIndex('class');
|
|
342
361
|
|
package/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodebb-plugin-markdown",
|
|
3
|
-
"version": "13.0.0-pre.
|
|
3
|
+
"version": "13.0.0-pre.9",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "nodebb-plugin-markdown",
|
|
9
|
-
"version": "13.0.0-pre.
|
|
9
|
+
"version": "13.0.0-pre.9",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"highlight.js": "11.4.0",
|