nodebb-plugin-markdown 13.1.0 → 13.1.2

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/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # NodeBB Markdown Parser
2
-
3
- This NodeBB plugin is a parser that allows users to write posts using [Markdown](https://daringfireball.net/projects/markdown/).
4
-
5
- To customise options for the parser, please consult the "Markdown" page in the administration panel, under the "Plugins" heading.
6
-
7
- ## Installation
8
-
9
- npm install nodebb-plugin-markdown
1
+ # NodeBB Markdown Parser
2
+
3
+ This NodeBB plugin is a parser that allows users to write posts using [Markdown](https://daringfireball.net/projects/markdown/).
4
+
5
+ To customise options for the parser, please consult the "Markdown" page in the administration panel, under the "Plugins" heading.
6
+
7
+ ## Installation
8
+
9
+ npm install nodebb-plugin-markdown
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ import serverConfig from 'eslint-config-nodebb';
4
+ import publicConfig from 'eslint-config-nodebb/public';
5
+
6
+ export default [
7
+ ...publicConfig,
8
+ ...serverConfig,
9
+ ];
10
+
package/index.js CHANGED
@@ -167,6 +167,7 @@ const Markdown = {
167
167
  ({ env } = await plugins.hooks.fire('filter:markdown.beforeParse', { env, data: Object.freeze({ ...data }) }));
168
168
 
169
169
  if (data.type === 'markdown') {
170
+ // core is expecting markdown to come back, bypass parsing
170
171
  env.parse = false;
171
172
  } else if (activitypub.helpers.isUri(data.postData.pid)) {
172
173
  if (data.postData.sourceContent) {
@@ -282,15 +283,12 @@ const Markdown = {
282
283
 
283
284
  // Update renderer to add some classes to all images
284
285
  const renderImage = parser.renderer.rules.image || function (tokens, idx, options, env, self) {
285
- // eslint-disable-next-line prefer-spread,prefer-rest-params
286
286
  return self.renderToken.apply(self, arguments);
287
287
  };
288
288
  const renderLink = parser.renderer.rules.link_open || function (tokens, idx, options, env, self) {
289
- // eslint-disable-next-line prefer-spread,prefer-rest-params
290
289
  return self.renderToken.apply(self, arguments);
291
290
  };
292
291
  const renderTable = parser.renderer.rules.table_open || function (tokens, idx, options, env, self) {
293
- // eslint-disable-next-line prefer-spread,prefer-rest-params
294
292
  return self.renderToken.apply(self, arguments);
295
293
  };
296
294
 
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "nodebb-plugin-markdown",
3
- "version": "13.1.0",
3
+ "version": "13.1.2",
4
4
  "description": "A Markdown parser for NodeBB",
5
5
  "main": "index.js",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/julianlam/nodebb-plugin-markdown"
9
9
  },
10
+ "scripts": {
11
+ "lint": "eslint ."
12
+ },
10
13
  "keywords": [
11
14
  "nodebb",
12
15
  "plugin",
@@ -41,9 +44,9 @@
41
44
  "devDependencies": {
42
45
  "@commitlint/cli": "16.2.1",
43
46
  "@commitlint/config-angular": "16.2.1",
44
- "eslint": "8.x",
45
- "eslint-config-nodebb": "0.1.1",
46
- "eslint-plugin-import": "2.x",
47
+ "eslint": "^9.25.1",
48
+ "eslint-config-nodebb": "^1.1.4",
49
+ "eslint-plugin-import": "^2.31.0",
47
50
  "husky": "7.0.4",
48
51
  "lint-staged": "12.3.5"
49
52
  }
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- define('admin/plugins/markdown', ['settings', 'alerts'], function (Settings, alerts) {
3
+ define('admin/plugins/markdown', ['settings'], function (Settings) {
4
4
  var Markdown = {};
5
5
 
6
6
  Markdown.init = function () {
@@ -31,7 +31,7 @@ define('admin/plugins/markdown', ['settings', 'alerts'], function (Settings, ale
31
31
  };
32
32
 
33
33
  // Set defaults
34
- for (var setting in defaults) {
34
+ for (const setting of Object.keys(defaults)) {
35
35
  if (!settings.hasOwnProperty(setting)) {
36
36
  if (typeof defaults[setting] === 'boolean') {
37
37
  $('#' + setting).prop('checked', defaults[setting]);
@@ -47,7 +47,7 @@
47
47
  selector: '.composer .preview pre code',
48
48
  }, async (params) => {
49
49
  await initHljs();
50
- markdown.highlight(params)
50
+ markdown.highlight(params);
51
51
  });
52
52
 
53
53
  $(window).on('action:posts.loaded action:topic.loaded action:posts.edited', async function (ev, data) {
@@ -58,13 +58,19 @@ export function prepareFormattingTools() {
58
58
  controls.insertIntoTextarea(textarea, `${heading} ${strings.heading}`);
59
59
 
60
60
  controls.updateTextareaSelection(
61
- textarea, selectionStart + heading.length + 1, selectionStart + strings.heading.length + heading.length + 1
61
+ textarea,
62
+ selectionStart + heading.length + 1,
63
+ selectionStart + strings.heading.length + heading.length + 1
62
64
  );
63
65
  } else {
64
66
  const selectedText = $(textarea).val().substring(selectionStart, selectionEnd);
65
67
  const newText = `${heading} ${selectedText}`;
66
68
  controls.replaceSelectionInTextareaWith(textarea, newText);
67
- controls.updateTextareaSelection(textarea, selectionStart + (heading.length + 1), selectionEnd + (newText.length - selectedText.length));
69
+ controls.updateTextareaSelection(
70
+ textarea,
71
+ selectionStart + (heading.length + 1),
72
+ selectionEnd + (newText.length - selectedText.length)
73
+ );
68
74
  }
69
75
  }
70
76
 
@@ -115,7 +121,7 @@ export function prepareFormattingTools() {
115
121
  formatting.addButtonDispatch(`heading${size}`, function (textarea, selectionStart, selectionEnd) {
116
122
  formatHeading(new Array(size).fill('#').join(''), textarea, selectionStart, selectionEnd);
117
123
  });
118
- })
124
+ });
119
125
 
120
126
  formatting.addButtonDispatch('list', function (textarea, selectionStart, selectionEnd) {
121
127
  if (selectionStart === selectionEnd) {
@@ -129,7 +135,9 @@ export function prepareFormattingTools() {
129
135
  const selectedText = $(textarea).val().substring(selectionStart, selectionEnd);
130
136
  const newText = '* ' + selectedText.split('\n').join('\n* ');
131
137
  controls.replaceSelectionInTextareaWith(textarea, newText);
132
- controls.updateTextareaSelection(textarea, selectionStart + 2, selectionEnd + (newText.length - selectedText.length));
138
+ controls.updateTextareaSelection(
139
+ textarea, selectionStart + 2, selectionEnd + (newText.length - selectedText.length)
140
+ );
133
141
  }
134
142
  });
135
143
 
@@ -223,7 +231,7 @@ export function markExternalLinks() {
223
231
  iconEl.classList.add('fa', 'fa-external-link', 'small');
224
232
  anchorEl.append(' ', iconEl);
225
233
  }
226
- })
234
+ });
227
235
  }
228
236
 
229
237
  export function enhanceCheckbox(ev, data) {
@@ -1,12 +1,12 @@
1
- {
2
- "bold": "Fettschrift",
3
- "italic": "Kursivschrift",
4
- "list-item": "Listenpunkt",
5
- "strikethrough-text": "Durchgestrichen",
6
- "code-text": "code_text",
7
- "link-text": "Link Text",
8
- "link-url": "Link Adresse",
9
- "picture-text": "Bild Text",
10
- "picture-url": "Bild Link",
11
- "help-text": "Dieses Forum unterstützt Markdown. <a href=\"http://commonmark.org/help/\" class=\"text-decoration-underline\">Für mehr Informationen, hier klicken.</a>"
12
- }
1
+ {
2
+ "bold": "Fettschrift",
3
+ "italic": "Kursivschrift",
4
+ "list-item": "Listenpunkt",
5
+ "strikethrough-text": "Durchgestrichen",
6
+ "code-text": "code_text",
7
+ "link-text": "Link Text",
8
+ "link-url": "Link Adresse",
9
+ "picture-text": "Bild Text",
10
+ "picture-url": "Bild Link",
11
+ "help-text": "Dieses Forum unterstützt Markdown. <a href=\"http://commonmark.org/help/\" class=\"text-decoration-underline\">Für mehr Informationen, hier klicken.</a>"
12
+ }
@@ -1,13 +1,13 @@
1
- {
2
- "bold": "bolded text",
3
- "italic": "italicised text",
4
- "list-item": "list item",
5
- "heading": "heading",
6
- "strikethrough-text": "strikethrough text",
7
- "code-text": "code_text",
8
- "link-text": "link text",
9
- "link-url": "link url",
10
- "picture-text": "alt text",
11
- "picture-url": "image url",
12
- "help-text": "This forum is powered by Markdown. <a href=\"http://commonmark.org/help/\" class=\"text-decoration-underline\">For full documentation, click here.</a>"
1
+ {
2
+ "bold": "bolded text",
3
+ "italic": "italicised text",
4
+ "list-item": "list item",
5
+ "heading": "heading",
6
+ "strikethrough-text": "strikethrough text",
7
+ "code-text": "code_text",
8
+ "link-text": "link text",
9
+ "link-url": "link url",
10
+ "picture-text": "alt text",
11
+ "picture-url": "image url",
12
+ "help-text": "This forum is powered by Markdown. <a href=\"http://commonmark.org/help/\" class=\"text-decoration-underline\">For full documentation, click here.</a>"
13
13
  }
@@ -1,11 +1,11 @@
1
- {
2
- "bold": "متن پررنگ",
3
- "italic": "متن ایتالیک ( کج )",
4
- "list-item": "لیست",
5
- "strikethrough-text": "متن خط خورده",
6
- "link-text": "متن لینک",
7
- "link-url": "آدرس لینک",
8
- "picture-text": "متن جایگزین",
9
- "picture-url": "آدرس عکس",
10
- "help-text": "این انجمن از زبان مارک دون استفاده می کند، برای اطلاعات بیشتر [اینجا](http://commonmark.org/help/) کلیک کنید!"
11
- }
1
+ {
2
+ "bold": "متن پررنگ",
3
+ "italic": "متن ایتالیک ( کج )",
4
+ "list-item": "لیست",
5
+ "strikethrough-text": "متن خط خورده",
6
+ "link-text": "متن لینک",
7
+ "link-url": "آدرس لینک",
8
+ "picture-text": "متن جایگزین",
9
+ "picture-url": "آدرس عکس",
10
+ "help-text": "این انجمن از زبان مارک دون استفاده می کند، برای اطلاعات بیشتر [اینجا](http://commonmark.org/help/) کلیک کنید!"
11
+ }
@@ -1,11 +1,11 @@
1
- {
2
- "bold": "texte en gras",
3
- "italic": "texte en italique",
4
- "list-item": "élément de liste",
5
- "strikethrough-text": "strikethrough text",
6
- "link-text": "texte du lien",
7
- "link-url": "url du lien",
8
- "picture-text": "text alternatif",
9
- "picture-url": "url de l'image",
10
- "help-text": "Ce forum utilise la syntaxe Markdown. <a href=\"http://commonmark.org/help/\" class=\"text-decoration-underline\">Pour accéder à la documentation, suivre ce lien.</a>"
11
- }
1
+ {
2
+ "bold": "texte en gras",
3
+ "italic": "texte en italique",
4
+ "list-item": "élément de liste",
5
+ "strikethrough-text": "strikethrough text",
6
+ "link-text": "texte du lien",
7
+ "link-url": "url du lien",
8
+ "picture-text": "text alternatif",
9
+ "picture-url": "url de l'image",
10
+ "help-text": "Ce forum utilise la syntaxe Markdown. <a href=\"http://commonmark.org/help/\" class=\"text-decoration-underline\">Pour accéder à la documentation, suivre ce lien.</a>"
11
+ }
@@ -1,12 +1,12 @@
1
- {
2
- "bold": "טקסט מודגש",
3
- "italic": "טקסט נטוי",
4
- "list-item": "פריט רשימה",
5
- "strikethrough-text": "קו חוצה",
6
- "code-text": "קוד",
7
- "link-text": "טקסט קישור",
8
- "link-url": "כתובת קישור",
9
- "picture-text": "כיתוב בבעיות טעינה",
10
- "picture-url": "כתובת תמונה",
11
- "help-text": "הפורום עובד עם Markdown. להסבר מלא, [לחץ כאן](http://commonmark.org/help/)"
12
- }
1
+ {
2
+ "bold": "טקסט מודגש",
3
+ "italic": "טקסט נטוי",
4
+ "list-item": "פריט רשימה",
5
+ "strikethrough-text": "קו חוצה",
6
+ "code-text": "קוד",
7
+ "link-text": "טקסט קישור",
8
+ "link-url": "כתובת קישור",
9
+ "picture-text": "כיתוב בבעיות טעינה",
10
+ "picture-url": "כתובת תמונה",
11
+ "help-text": "הפורום עובד עם Markdown. להסבר מלא, [לחץ כאן](http://commonmark.org/help/)"
12
+ }
@@ -1,11 +1,11 @@
1
- {
2
- "bold": "pogrubienie",
3
- "italic": "pochylenie",
4
- "list-item": "wypunktowanie",
5
- "strikethrough-text": "przekreślenie",
6
- "link-text": "tekst odnośnika",
7
- "link-url": "url odnośnika",
8
- "picture-text": "text alternatywny",
9
- "picture-url": "url obrazu",
10
- "help-text": "Forum działa dzięki Markdown. <a href=\"http://commonmark.org/help/\" class=\"text-decoration-underline\">By uzyskać pełną dokumentację, kliknij tutaj.</a>"
11
- }
1
+ {
2
+ "bold": "pogrubienie",
3
+ "italic": "pochylenie",
4
+ "list-item": "wypunktowanie",
5
+ "strikethrough-text": "przekreślenie",
6
+ "link-text": "tekst odnośnika",
7
+ "link-url": "url odnośnika",
8
+ "picture-text": "text alternatywny",
9
+ "picture-url": "url obrazu",
10
+ "help-text": "Forum działa dzięki Markdown. <a href=\"http://commonmark.org/help/\" class=\"text-decoration-underline\">By uzyskać pełną dokumentację, kliknij tutaj.</a>"
11
+ }
@@ -1,11 +1,11 @@
1
- {
2
- "bold": "kalın yazı",
3
- "italic": "İtalik yazı",
4
- "list-item": "liste madde",
5
- "strikethrough-text": "Üstü çizili metin",
6
- "link-text": "bağlantı metni",
7
- "link-url": "link url",
8
- "picture-text": "alt metni",
9
- "picture-url": "görsel url",
10
- "help-text": "This forum is powered by Markdown. <a href=\"http://commonmark.org/help/\" class=\"text-decoration-underline\">For full documentation, click here.</a>"
11
- }
1
+ {
2
+ "bold": "kalın yazı",
3
+ "italic": "İtalik yazı",
4
+ "list-item": "liste madde",
5
+ "strikethrough-text": "Üstü çizili metin",
6
+ "link-text": "bağlantı metni",
7
+ "link-url": "link url",
8
+ "picture-text": "alt metni",
9
+ "picture-url": "görsel url",
10
+ "help-text": "This forum is powered by Markdown. <a href=\"http://commonmark.org/help/\" class=\"text-decoration-underline\">For full documentation, click here.</a>"
11
+ }
@@ -1,11 +1,11 @@
1
- {
2
- "bold": "粗体字",
3
- "italic": "斜体字",
4
- "list-item": "列表",
5
- "strikethrough-text": "删除线",
6
- "link-text": "链接文本",
7
- "link-url": "链接地址",
8
- "picture-text": "替代文字",
9
- "picture-url": "图片地址",
10
- "help-text": "该论坛使用 Markdown 语法。[点此查看](http://commonmark.org/help/) 语法说明。"
11
- }
1
+ {
2
+ "bold": "粗体字",
3
+ "italic": "斜体字",
4
+ "list-item": "列表",
5
+ "strikethrough-text": "删除线",
6
+ "link-text": "链接文本",
7
+ "link-url": "链接地址",
8
+ "picture-text": "替代文字",
9
+ "picture-url": "图片地址",
10
+ "help-text": "该论坛使用 Markdown 语法。[点此查看](http://commonmark.org/help/) 语法说明。"
11
+ }
package/websockets.js CHANGED
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  const privileges = require.main.require('./src/privileges');
4
- const SocketPosts = require.main.require('./src/socket.io/posts');
4
+ const postsAPI = require.main.require('./src/api/posts');
5
5
  const posts = require.main.require('./src/posts');
6
6
 
7
7
  module.exports.checkbox = {
8
8
  edit: async function (socket, data) {
9
- const canEdit = await privileges.posts.canEdit(parseInt(data.pid, 10), socket.uid);
9
+ const canEdit = await privileges.posts.canEdit(data.pid, socket.uid);
10
10
  if (!canEdit) {
11
11
  throw new Error('[[error:no-privileges]]');
12
12
  }
@@ -16,12 +16,12 @@ module.exports.checkbox = {
16
16
  const checkboxRegex = /\[[\sx]?\]/g;
17
17
  let match;
18
18
  const indices = [];
19
- // eslint-disable-next-line
19
+
20
20
  while ((match = checkboxRegex.exec(content)) !== null) {
21
21
  indices.push(match.index);
22
22
  }
23
23
 
24
- content = content.replace(checkboxRegex, function (match, idx) {
24
+ content = content.replace(checkboxRegex, (match, idx) => {
25
25
  if (idx !== indices[data.index]) {
26
26
  return match;
27
27
  }
@@ -29,7 +29,7 @@ module.exports.checkbox = {
29
29
  return data.state ? '[x]' : '[ ]';
30
30
  });
31
31
 
32
- await SocketPosts.edit(socket, {
32
+ await postsAPI.edit(socket, {
33
33
  pid: data.pid,
34
34
  content: content,
35
35
  });
package/.eslintrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "nodebb"
3
- }
package/.jshintrc DELETED
@@ -1,86 +0,0 @@
1
- {
2
- // JSHint Default Configuration File (as on JSHint website)
3
- // See http://jshint.com/docs/ for more details
4
-
5
- "maxerr" : 50, // {int} Maximum error before stopping
6
-
7
- // Enforcing
8
- "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
9
- "camelcase" : false, // true: Identifiers must be in camelCase
10
- "curly" : true, // true: Require {} for every new block or scope
11
- "eqeqeq" : true, // true: Require triple equals (===) for comparison
12
- "forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
13
- "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
14
- "indent" : 4, // {int} Number of spaces to use for indentation
15
- "latedef" : false, // true: Require variables/functions to be defined before being used
16
- "newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()`
17
- "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
18
- "noempty" : true, // true: Prohibit use of empty blocks
19
- "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment)
20
- "plusplus" : false, // true: Prohibit use of `++` & `--`
21
- "quotmark" : false, // Quotation mark consistency:
22
- // false : do nothing (default)
23
- // true : ensure whatever is used is consistent
24
- // "single" : require single quotes
25
- // "double" : require double quotes
26
- "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
27
- "unused" : true, // true: Require all defined variables be used
28
- "strict" : true, // true: Requires all functions run in ES5 Strict Mode
29
- "trailing" : false, // true: Prohibit trailing whitespaces
30
- "maxparams" : false, // {int} Max number of formal params allowed per function
31
- "maxdepth" : false, // {int} Max depth of nested blocks (within functions)
32
- "maxstatements" : false, // {int} Max number statements per function
33
- "maxcomplexity" : false, // {int} Max cyclomatic complexity per function
34
- "maxlen" : false, // {int} Max number of characters per line
35
-
36
- // Relaxing
37
- "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
38
- "boss" : false, // true: Tolerate assignments where comparisons would be expected
39
- "debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
40
- "eqnull" : false, // true: Tolerate use of `== null`
41
- "es5" : false, // true: Allow ES5 syntax (ex: getters and setters)
42
- "esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`)
43
- "moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
44
- // (ex: `for each`, multiple try/catch, function expression…)
45
- "evil" : false, // true: Tolerate use of `eval` and `new Function()`
46
- "expr" : false, // true: Tolerate `ExpressionStatement` as Programs
47
- "funcscope" : false, // true: Tolerate defining variables inside control statements"
48
- "globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
49
- "iterator" : false, // true: Tolerate using the `__iterator__` property
50
- "lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
51
- "laxbreak" : false, // true: Tolerate possibly unsafe line breakings
52
- "laxcomma" : false, // true: Tolerate comma-first style coding
53
- "loopfunc" : false, // true: Tolerate functions being defined in loops
54
- "multistr" : false, // true: Tolerate multi-line strings
55
- "proto" : false, // true: Tolerate using the `__proto__` property
56
- "scripturl" : false, // true: Tolerate script-targeted URLs
57
- "smarttabs" : false, // true: Tolerate mixed tabs/spaces when used for alignment
58
- "shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
59
- "sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
60
- "supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
61
- "validthis" : false, // true: Tolerate using this in a non-constructor function
62
-
63
- // Environments
64
- "browser" : true, // Web Browser (window, document, etc)
65
- "couch" : false, // CouchDB
66
- "devel" : true, // Development/debugging (alert, confirm, etc)
67
- "dojo" : false, // Dojo Toolkit
68
- "jquery" : true, // jQuery
69
- "mootools" : false, // MooTools
70
- "node" : true, // Node.js
71
- "nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
72
- "prototypejs" : false, // Prototype and Scriptaculous
73
- "rhino" : false, // Rhino
74
- "worker" : false, // Web Workers
75
- "wsh" : false, // Windows Scripting Host
76
- "yui" : false, // Yahoo User Interface
77
-
78
- // Legacy
79
- "nomen" : false, // true: Prohibit dangling `_` in variables
80
- "onevar" : false, // true: Allow only one `var` statement per function
81
- "passfail" : false, // true: Stop on first error
82
- "white" : false, // true: Check against strict whitespace and indentation rules
83
-
84
- // Custom Globals
85
- "globals" : {} // additional predefined global variables
86
- }