From b45686eb3b22e7f448713bdf1ddb0075a43285f5 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Sat, 23 Nov 2024 11:18:44 -0600 Subject: [PATCH 01/22] Create an element for serial non-breaking spaces as proposed in V4 discussion --- shared/naturalcrit/markdown.js | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 4c1a2f92a..45d573262 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -391,6 +391,27 @@ const forcedParagraphBreaks = { } }; +const nonbreakingSpaces = { + name : 'nonbreakingSpaces', + level : 'inline', + start(src) { return src.match(/:>+/m)?.index; }, // Hint to Marked.js to stop and check for a match + tokenizer(src, tokens) { + const regex = /:(>+)/ym; + const match = regex.exec(src); + if(match?.length) { + return { + type : 'nonbreakingSpaces', // Should match "name" above + raw : match[0], // Text to consume from the source + length : match[1].length, + text : '' + }; + } + }, + renderer(token) { + return ` `.repeat(token.length).concat('\n'); + } +}; + const definitionListsSingleLine = { name : 'definitionListsSingleLine', level : 'block', @@ -748,11 +769,12 @@ const tableTerminators = [ ]; Marked.use(MarkedVariables()); -Marked.use({ extensions : [definitionListsMultiLine, definitionListsSingleLine, forcedParagraphBreaks, superSubScripts, - mustacheSpans, mustacheDivs, mustacheInjectInline] }); +Marked.use({ extensions : [definitionListsMultiLine, definitionListsSingleLine, forcedParagraphBreaks, + nonbreakingSpaces, superSubScripts, mustacheSpans, mustacheDivs, mustacheInjectInline] }); Marked.use(mustacheInjectBlock); Marked.use({ renderer: renderer, tokenizer: tokenizer, mangle: false }); -Marked.use(MarkedExtendedTables(tableTerminators), MarkedGFMHeadingId({ globalSlugs: true }), MarkedSmartypantsLite(), MarkedEmojis(MarkedEmojiOptions)); +Marked.use(MarkedExtendedTables(tableTerminators), MarkedGFMHeadingId({ globalSlugs: true }), + MarkedSmartypantsLite(), MarkedEmojis(MarkedEmojiOptions)); function cleanUrl(href) { try { From 596c4ad68dc1764804c1aa36d7702bc016251e1b Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 4 Dec 2024 21:24:48 -0600 Subject: [PATCH 02/22] Add Tests --- shared/naturalcrit/markdown.js | 4 +- tests/markdown/horizontalSpaces.test.js | 49 +++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 tests/markdown/horizontalSpaces.test.js diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 45d573262..6ceee2b03 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -415,9 +415,9 @@ const nonbreakingSpaces = { const definitionListsSingleLine = { name : 'definitionListsSingleLine', level : 'block', - start(src) { return src.match(/\n[^\n]*?::[^\n]*/m)?.index; }, // Hint to Marked.js to stop and check for a match + start(src) { return src.match(/\n[^\n]*?::[^:\n]*/m)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { - const regex = /^([^\n]*?)::([^\n]*)(?:\n|$)/ym; + const regex = /^([^\n]*?)::([^\:\>][^\n]*)(?:\n|$)/ym; let match; let endIndex = 0; const definitions = []; diff --git a/tests/markdown/horizontalSpaces.test.js b/tests/markdown/horizontalSpaces.test.js new file mode 100644 index 000000000..6789b934c --- /dev/null +++ b/tests/markdown/horizontalSpaces.test.js @@ -0,0 +1,49 @@ +/* eslint-disable max-lines */ + +import Markdown from 'naturalcrit/markdown.js'; + +describe('Hard Breaks', ()=>{ + test('Single Break', function() { + const source = ':>\n\n'; + const rendered = Markdown.render(source).trim(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

 \n

`); + }); + + test('Double Break', function() { + const source = ':>>\n\n'; + const rendered = Markdown.render(source).trim(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

  \n

`); + }); + + test('Triple Break', function() { + const source = ':>>>\n\n'; + const rendered = Markdown.render(source).trim(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

   \n

`); + }); + + test('Many Break', function() { + const source = ':>>>>>>>>>>\n\n'; + const rendered = Markdown.render(source).trim(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

          \n

`); + }); + + test('Multiple sets of Breaks', function() { + const source = ':>>>\n:>>>\n:>>>'; + const rendered = Markdown.render(source).trim(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

   \n\n   \n\n   \n

`); + }); + + test('Break directly between two paragraphs', function() { + const source = 'Line 1\n:>>\nLine 2'; + const rendered = Markdown.render(source).trim(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

Line 1\n  \n\nLine 2

`); + }); + + test('Ignored inside a code block', function() { + const source = '```\n\n:>\n\n```\n'; + const rendered = Markdown.render(source).trim(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`
\n:>\n
`); + }); + +}); + From c63b6ffaf0857ef5f9a28e9a070a91133b33ed79 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Tue, 17 Dec 2024 21:38:32 -0600 Subject: [PATCH 03/22] Add test for a pair of inline horizontal breaks --- shared/naturalcrit/markdown.js | 2 +- tests/markdown/horizontalSpaces.test.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 6ceee2b03..6b737e02f 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -408,7 +408,7 @@ const nonbreakingSpaces = { } }, renderer(token) { - return ` `.repeat(token.length).concat('\n'); + return ` `.repeat(token.length).concat(''); } }; diff --git a/tests/markdown/horizontalSpaces.test.js b/tests/markdown/horizontalSpaces.test.js index 6789b934c..1ef8ea043 100644 --- a/tests/markdown/horizontalSpaces.test.js +++ b/tests/markdown/horizontalSpaces.test.js @@ -33,6 +33,12 @@ describe('Hard Breaks', ()=>{ expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

   \n\n   \n\n   \n

`); }); + test('Pair of inline Breaks', function() { + const source = ':>>:>>'; + const rendered = Markdown.render(source).trim(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

  \n  \n

`); + }); + test('Break directly between two paragraphs', function() { const source = 'Line 1\n:>>\nLine 2'; const rendered = Markdown.render(source).trim(); From 912f9f0cf689a34648e00517010b15cbaa63eca1 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Tue, 17 Dec 2024 21:40:56 -0600 Subject: [PATCH 04/22] Remove extraneous linefeeds in horizontalbreaks --- tests/markdown/horizontalSpaces.test.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/markdown/horizontalSpaces.test.js b/tests/markdown/horizontalSpaces.test.js index 1ef8ea043..5e5611e0f 100644 --- a/tests/markdown/horizontalSpaces.test.js +++ b/tests/markdown/horizontalSpaces.test.js @@ -6,43 +6,43 @@ describe('Hard Breaks', ()=>{ test('Single Break', function() { const source = ':>\n\n'; const rendered = Markdown.render(source).trim(); - expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

 \n

`); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

 

`); }); test('Double Break', function() { const source = ':>>\n\n'; const rendered = Markdown.render(source).trim(); - expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

  \n

`); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

  

`); }); test('Triple Break', function() { const source = ':>>>\n\n'; const rendered = Markdown.render(source).trim(); - expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

   \n

`); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

   

`); }); test('Many Break', function() { const source = ':>>>>>>>>>>\n\n'; const rendered = Markdown.render(source).trim(); - expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

          \n

`); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

          

`); }); test('Multiple sets of Breaks', function() { const source = ':>>>\n:>>>\n:>>>'; const rendered = Markdown.render(source).trim(); - expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

   \n\n   \n\n   \n

`); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

   \n   \n   

`); }); test('Pair of inline Breaks', function() { const source = ':>>:>>'; const rendered = Markdown.render(source).trim(); - expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

  \n  \n

`); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

    

`); }); test('Break directly between two paragraphs', function() { const source = 'Line 1\n:>>\nLine 2'; const rendered = Markdown.render(source).trim(); - expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

Line 1\n  \n\nLine 2

`); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

Line 1\n  \nLine 2

`); }); test('Ignored inside a code block', function() { From aee5b7a8cce7e13d10ce4d6717dc858eee8c22d2 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Wed, 18 Dec 2024 12:14:08 -0500 Subject: [PATCH 05/22] Require user to be logged in to change name --- server/app.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/app.js b/server/app.js index c91bbc57f..4dec6b4c4 100644 --- a/server/app.js +++ b/server/app.js @@ -351,11 +351,12 @@ app.get('/user/:username', async (req, res, next)=>{ //Change author name on brews app.put('/api/user/rename', async (req, res)=>{ const { username, newUsername } = req.body; - console.log(req.account); + const ownAccount = req.account && (req.account.username == newUsername); - if(!username || !newUsername) { + if(!username || !newUsername) return res.status(400).json({ error: 'Username and newUsername are required.' }); - } + if(!ownAccount) + return res.status(403).json({ error: 'Must be logged in to change your username' }); try { const brews = await HomebrewModel.getByUser(username, true, ['authors']); const renamePromises = brews.map(async (brew)=>{ From 64b792c6450e005229886f0f7a7dcb3cd0ffdba7 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Wed, 18 Dec 2024 13:02:14 -0500 Subject: [PATCH 06/22] Fix case where no stub is found When retrieving a Google Brew with no stub yet, if the user is not logged in or has expired credentials, we enter this error handler. However, the error message itself tries to send a list of authors. If there was no stub, we crash here with a 500 error. This adds conditional operator to any stub value so we can send the actual "not logged in" error in case of no stub. --- server/homebrew.api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 159c08b47..7bf10f38d 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -111,7 +111,7 @@ const api = { const isInvited = stub?.invitedAuthors?.includes(req.account?.username); if(accessType === 'edit' && !(isOwner || isAuthor || isInvited)) { - const accessError = { name: 'Access Error', status: 401, authors: stub.authors, brewTitle: stub.title, shareId: stub.shareId }; + const accessError = { name: 'Access Error', status: 401, authors: stub?.authors, brewTitle: stub?.title, shareId: stub?.shareId }; if(req.account) throw { ...accessError, message: 'User is not an Author', HBErrorCode: '03' }; else @@ -119,7 +119,7 @@ const api = { } if(stub?.lock?.locked && accessType != 'edit') { - throw { HBErrorCode: '51', code: stub.lock.code, message: stub.lock.shareMessage, brewId: stub.shareId, brewTitle: stub.title }; + throw { HBErrorCode: '51', code: stub?.lock.code, message: stub?.lock.shareMessage, brewId: stub?.shareId, brewTitle: stub?.title }; } // If there is a google id, try to find the google brew From e61144beb8ba9ddf0d4a5144996311fcb18a1c3b Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Wed, 18 Dec 2024 13:45:53 -0500 Subject: [PATCH 07/22] Mark as owner if stub doesn't exist Old Google Drive files without a stub have no author, so if no stub exists, consider the current user the owner. --- server/homebrew.api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 7bf10f38d..56da8872c 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -106,7 +106,7 @@ const api = { stub = stub?.toObject(); googleId ??= stub?.googleId; - const isOwner = stub?.authors?.length === 0 || stub?.authors?.[0] === req.account?.username; + const isOwner = !stub || stub?.authors?.length === 0 || stub?.authors?.[0] === req.account?.username; const isAuthor = stub?.authors?.includes(req.account?.username); const isInvited = stub?.invitedAuthors?.includes(req.account?.username); From 6e8a0d731468cf0f399b97e7bd53fbd6a2394e8f Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Wed, 18 Dec 2024 17:07:09 -0500 Subject: [PATCH 08/22] current user owns 0-author brew only if edit mode Previous code was treating /share/ visits to google brews with no stub as visits by owner, thus using their own credentials to open the file instead of serviceaccount --- server/homebrew.api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 56da8872c..548346643 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -106,7 +106,7 @@ const api = { stub = stub?.toObject(); googleId ??= stub?.googleId; - const isOwner = !stub || stub?.authors?.length === 0 || stub?.authors?.[0] === req.account?.username; + const isOwner = (accessType == 'edit' && (!stub || stub?.authors?.length === 0)) || stub?.authors?.[0] === req.account?.username; const isAuthor = stub?.authors?.includes(req.account?.username); const isInvited = stub?.invitedAuthors?.includes(req.account?.username); @@ -124,7 +124,7 @@ const api = { // If there is a google id, try to find the google brew if(!stubOnly && googleId) { - const oAuth2Client = isOwner? GoogleActions.authCheck(req.account, res) : undefined; + const oAuth2Client = isOwner ? GoogleActions.authCheck(req.account, res) : undefined; const googleBrew = await GoogleActions.getGoogleBrew(oAuth2Client, googleId, id, accessType) .catch((googleError)=>{ From 5f14f656ef88a20bb4e12033cf3763d53d753f2e Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Wed, 18 Dec 2024 17:23:38 -0500 Subject: [PATCH 09/22] Logging --- server/homebrew.api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 548346643..5f19f81fb 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -125,7 +125,7 @@ const api = { // If there is a google id, try to find the google brew if(!stubOnly && googleId) { const oAuth2Client = isOwner ? GoogleActions.authCheck(req.account, res) : undefined; - + console.log(`user ${req.account?.username} attempting to get googlebrew ${googleId} as ${isOwner ? 'owner' : 'visitor'}`); const googleBrew = await GoogleActions.getGoogleBrew(oAuth2Client, googleId, id, accessType) .catch((googleError)=>{ const reason = googleError.errors?.[0].reason; From 2dc8a8fbe92f9bfb82dcd7287d21ed594849696f Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Thu, 19 Dec 2024 16:20:04 +1300 Subject: [PATCH 10/22] Remove req.account from update request --- server/admin.api.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/admin.api.js b/server/admin.api.js index 02cdcb2f7..2febdfebb 100644 --- a/server/admin.api.js +++ b/server/admin.api.js @@ -108,6 +108,9 @@ router.put('/admin/clean/script/:id', asyncHandler(HomebrewAPI.getBrew('admin', req.body = brew; + // Remove Account from request to prevent Admin user from being added to brew as an Author + req.account = undefined; + return await HomebrewAPI.updateBrew(req, res); }); From 7a169cbd9e5fce6ebca6b0c34428fefa27749255 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Thu, 19 Dec 2024 16:20:28 +1300 Subject: [PATCH 11/22] Linter clean up --- server/admin.api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/admin.api.js b/server/admin.api.js index 2febdfebb..1a39f020b 100644 --- a/server/admin.api.js +++ b/server/admin.api.js @@ -1,5 +1,5 @@ -import {model as HomebrewModel } from './homebrew.model.js'; -import {model as NotificationModel } from './notifications.model.js'; +import { model as HomebrewModel } from './homebrew.model.js'; +import { model as NotificationModel } from './notifications.model.js'; import express from 'express'; import Moment from 'moment'; import zlib from 'zlib'; From 9dbfb26e6c903afa60575d9dd750bda742eb7c49 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 03:47:25 +0000 Subject: [PATCH 12/22] Bump globals from 15.13.0 to 15.14.0 Bumps [globals](https://github.com/sindresorhus/globals) from 15.13.0 to 15.14.0. - [Release notes](https://github.com/sindresorhus/globals/releases) - [Commits](https://github.com/sindresorhus/globals/compare/v15.13.0...v15.14.0) --- updated-dependencies: - dependency-name: globals dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 9 ++++----- package.json | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 94178b331..d6300cb8a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57,7 +57,7 @@ "eslint": "^9.17.0", "eslint-plugin-jest": "^28.9.0", "eslint-plugin-react": "^7.37.2", - "globals": "^15.13.0", + "globals": "^15.14.0", "jest": "^29.7.0", "jest-expect-message": "^1.1.3", "jsdom-global": "^3.0.2", @@ -6714,11 +6714,10 @@ } }, "node_modules/globals": { - "version": "15.13.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-15.13.0.tgz", - "integrity": "sha512-49TewVEz0UxZjr1WYYsWpPrhyC/B/pA8Bq0fUmet2n+eR7yn0IvNzNaoBwnK6mdkzcN+se7Ez9zUgULTz2QH4g==", + "version": "15.14.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.14.0.tgz", + "integrity": "sha512-OkToC372DtlQeje9/zHIo5CT8lRP/FUgEOKBEhU4e0abL7J7CD24fD9ohiLN5hagG/kWCYj4K5oaxxtj2Z0Dig==", "dev": true, - "license": "MIT", "engines": { "node": ">=18" }, diff --git a/package.json b/package.json index 38b25bc77..3b192214a 100644 --- a/package.json +++ b/package.json @@ -130,7 +130,7 @@ "eslint": "^9.17.0", "eslint-plugin-jest": "^28.9.0", "eslint-plugin-react": "^7.37.2", - "globals": "^15.13.0", + "globals": "^15.14.0", "jest": "^29.7.0", "jest-expect-message": "^1.1.3", "jsdom-global": "^3.0.2", From 57467701d0036fdf488778b85b98db39f688059b Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Wed, 18 Dec 2024 23:00:01 -0500 Subject: [PATCH 13/22] Fetch Google Brew if only stub requested but nothing found /update/ requests only the stub for updating. But if no stub exists, we should fetch the full brew so we return *something*. --- server/homebrew.api.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index 5f19f81fb..9a479732e 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -122,10 +122,10 @@ const api = { throw { HBErrorCode: '51', code: stub?.lock.code, message: stub?.lock.shareMessage, brewId: stub?.shareId, brewTitle: stub?.title }; } - // If there is a google id, try to find the google brew - if(!stubOnly && googleId) { + // If there's a google id, get it if requesting the full brew or if no stub found yet + if(googleId && (!stubOnly || !stub)) { const oAuth2Client = isOwner ? GoogleActions.authCheck(req.account, res) : undefined; - console.log(`user ${req.account?.username} attempting to get googlebrew ${googleId} as ${isOwner ? 'owner' : 'visitor'}`); + const googleBrew = await GoogleActions.getGoogleBrew(oAuth2Client, googleId, id, accessType) .catch((googleError)=>{ const reason = googleError.errors?.[0].reason; From 6301a66fd3e8f583edb08b59e96415f242a955e0 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Thu, 19 Dec 2024 17:44:48 -0600 Subject: [PATCH 14/22] Add additional tests --- tests/markdown/horizontalSpaces.test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/markdown/horizontalSpaces.test.js b/tests/markdown/horizontalSpaces.test.js index 5e5611e0f..94e1a93b9 100644 --- a/tests/markdown/horizontalSpaces.test.js +++ b/tests/markdown/horizontalSpaces.test.js @@ -51,5 +51,17 @@ describe('Hard Breaks', ()=>{ expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`
\n:>\n
`); }); + + test('I am actually a definition list!', function() { + const source = 'Term\n::> Definition 1\n'; + const rendered = Markdown.render(source).trim(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`
Term
\n
> Definition 1
`); + }); + + test('I am actually a two term definition list!', function() { + const source = 'Term\n::> Definition 1\n::>> Definition 2'; + const rendered = Markdown.render(source).trim(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`
Term
\n
> Definition 1
\n
>> Definition 2
`); + }); }); From 7e1312805f716295a21c495ab2eda6850e12bdb7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 03:38:26 +0000 Subject: [PATCH 15/22] Bump mongoose from 8.9.1 to 8.9.2 Bumps [mongoose](https://github.com/Automattic/mongoose) from 8.9.1 to 8.9.2. - [Release notes](https://github.com/Automattic/mongoose/releases) - [Changelog](https://github.com/Automattic/mongoose/blob/master/CHANGELOG.md) - [Commits](https://github.com/Automattic/mongoose/compare/8.9.1...8.9.2) --- updated-dependencies: - dependency-name: mongoose dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index d6300cb8a..d969bc244 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,7 +40,7 @@ "marked-smartypants-lite": "^1.0.2", "markedLegacy": "npm:marked@^0.3.19", "moment": "^2.30.1", - "mongoose": "^8.9.1", + "mongoose": "^8.9.2", "nanoid": "5.0.9", "nconf": "^0.12.1", "react": "^18.3.1", @@ -10126,9 +10126,9 @@ } }, "node_modules/mongoose": { - "version": "8.9.1", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.9.1.tgz", - "integrity": "sha512-whM6lWMdeKlUm4d2LSLS/q6cWtTp13lUrL5hy2YTsQdTSN+dsAu8HLdLUQOEgtBE59qp4IqLrjSXCSETbxhkQQ==", + "version": "8.9.2", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.9.2.tgz", + "integrity": "sha512-mLWynmZS1v8HTeMxyLhskQncS1SkrjW1eLNuFDYGQMQ/5QrFrxTLNwWXeCRZeKT2lXyaxW8bnJC9AKPT9jYMkw==", "dependencies": { "bson": "^6.10.1", "kareem": "2.6.3", diff --git a/package.json b/package.json index 3b192214a..ea541fe26 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "marked-smartypants-lite": "^1.0.2", "markedLegacy": "npm:marked@^0.3.19", "moment": "^2.30.1", - "mongoose": "^8.9.1", + "mongoose": "^8.9.2", "nanoid": "5.0.9", "nconf": "^0.12.1", "react": "^18.3.1", From 6e9d293bbe33b900217795a03ea341f1681c6f85 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Thu, 19 Dec 2024 23:09:43 -0500 Subject: [PATCH 16/22] Rename tests to "Non-breaking Spaces" Hard Breaks name was leftover from copying the `::::` test file. --- tests/markdown/horizontalSpaces.test.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/markdown/horizontalSpaces.test.js b/tests/markdown/horizontalSpaces.test.js index 94e1a93b9..20bb8b892 100644 --- a/tests/markdown/horizontalSpaces.test.js +++ b/tests/markdown/horizontalSpaces.test.js @@ -2,44 +2,44 @@ import Markdown from 'naturalcrit/markdown.js'; -describe('Hard Breaks', ()=>{ - test('Single Break', function() { +describe('Non-Breaking Spaces', ()=>{ + test('Single Space', function() { const source = ':>\n\n'; const rendered = Markdown.render(source).trim(); expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

 

`); }); - test('Double Break', function() { + test('Double Space', function() { const source = ':>>\n\n'; const rendered = Markdown.render(source).trim(); expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

  

`); }); - test('Triple Break', function() { + test('Triple Space', function() { const source = ':>>>\n\n'; const rendered = Markdown.render(source).trim(); expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

   

`); }); - test('Many Break', function() { + test('Many Space', function() { const source = ':>>>>>>>>>>\n\n'; const rendered = Markdown.render(source).trim(); expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

          

`); }); - test('Multiple sets of Breaks', function() { + test('Multiple sets of Spaces', function() { const source = ':>>>\n:>>>\n:>>>'; const rendered = Markdown.render(source).trim(); expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

   \n   \n   

`); }); - test('Pair of inline Breaks', function() { + test('Pair of inline Spaces', function() { const source = ':>>:>>'; const rendered = Markdown.render(source).trim(); expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

    

`); }); - test('Break directly between two paragraphs', function() { + test('Space directly between two paragraphs', function() { const source = 'Line 1\n:>>\nLine 2'; const rendered = Markdown.render(source).trim(); expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

Line 1\n  \nLine 2

`); @@ -58,7 +58,7 @@ describe('Hard Breaks', ()=>{ expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`
Term
\n
> Definition 1
`); }); - test('I am actually a two term definition list!', function() { + test('I am actually a two-term definition list!', function() { const source = 'Term\n::> Definition 1\n::>> Definition 2'; const rendered = Markdown.render(source).trim(); expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`
Term
\n
> Definition 1
\n
>> Definition 2
`); From ed8c4d0eef0c7b8e951951f6b679536687699e04 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Thu, 19 Dec 2024 23:14:32 -0500 Subject: [PATCH 17/22] Add tests to circleCi --- .circleci/config.yml | 3 +++ package.json | 1 + .../{horizontalSpaces.test.js => non-breaking-spaces.test.js} | 0 3 files changed, 4 insertions(+) rename tests/markdown/{horizontalSpaces.test.js => non-breaking-spaces.test.js} (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 00cbdf5bc..51c598f02 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -70,6 +70,9 @@ jobs: - run: name: Test - Hard Breaks command: npm run test:hard-breaks + - run: + name: Test - Non-Breaking Spaces + command: npm run test:non-breaking-spaces - run: name: Test - Variables command: npm run test:variables diff --git a/package.json b/package.json index 3b192214a..d084a866b 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "test:mustache-syntax:injection": "jest \".*(mustache-syntax).*\" -t '^Injection:.*' --verbose --noStackTrace", "test:definition-lists": "jest tests/markdown/definition-lists.test.js --verbose --noStackTrace", "test:hard-breaks": "jest tests/markdown/hard-breaks.test.js --verbose --noStackTrace", + "test:non-breaking-spaces": "jest tests/markdown/non-breaking-spaces.test.js --verbose --noStackTrace", "test:emojis": "jest tests/markdown/emojis.test.js --verbose --noStackTrace", "test:route": "jest tests/routes/static-pages.test.js --verbose", "test:safehtml": "jest tests/html/safeHTML.test.js --verbose", diff --git a/tests/markdown/horizontalSpaces.test.js b/tests/markdown/non-breaking-spaces.test.js similarity index 100% rename from tests/markdown/horizontalSpaces.test.js rename to tests/markdown/non-breaking-spaces.test.js From fde21868cdb3bd21438ebff2cc8b80e9c0544900 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Thu, 19 Dec 2024 23:20:01 -0500 Subject: [PATCH 18/22] Add emoji tests to circleci --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 00cbdf5bc..10264d4d3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -73,6 +73,9 @@ jobs: - run: name: Test - Variables command: npm run test:variables + - run: + name: Test - Emojis + command: npm run test:emojis - run: name: Test - Routes command: npm run test:route From ba83dfacd9bcc34b9e9b9cf54a5250897a3bfdf0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 04:26:51 +0000 Subject: [PATCH 19/22] Bump eslint-plugin-jest from 28.9.0 to 28.10.0 Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 28.9.0 to 28.10.0. - [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases) - [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md) - [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v28.9.0...v28.10.0) --- updated-dependencies: - dependency-name: eslint-plugin-jest dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index d969bc244..bc4c66238 100644 --- a/package-lock.json +++ b/package-lock.json @@ -55,7 +55,7 @@ "@stylistic/stylelint-plugin": "^3.1.1", "babel-plugin-transform-import-meta": "^2.2.1", "eslint": "^9.17.0", - "eslint-plugin-jest": "^28.9.0", + "eslint-plugin-jest": "^28.10.0", "eslint-plugin-react": "^7.37.2", "globals": "^15.14.0", "jest": "^29.7.0", @@ -5618,9 +5618,9 @@ } }, "node_modules/eslint-plugin-jest": { - "version": "28.9.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.9.0.tgz", - "integrity": "sha512-rLu1s1Wf96TgUUxSw6loVIkNtUjq1Re7A9QdCCHSohnvXEBAjuL420h0T/fMmkQlNsQP2GhQzEUpYHPfxBkvYQ==", + "version": "28.10.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.10.0.tgz", + "integrity": "sha512-hyMWUxkBH99HpXT3p8hc7REbEZK3D+nk8vHXGgpB+XXsi0gO4PxMSP+pjfUzb67GnV9yawV9a53eUmcde1CCZA==", "dev": true, "dependencies": { "@typescript-eslint/utils": "^6.0.0 || ^7.0.0 || ^8.0.0" diff --git a/package.json b/package.json index ea541fe26..aec34b085 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,7 @@ "@stylistic/stylelint-plugin": "^3.1.1", "babel-plugin-transform-import-meta": "^2.2.1", "eslint": "^9.17.0", - "eslint-plugin-jest": "^28.9.0", + "eslint-plugin-jest": "^28.10.0", "eslint-plugin-react": "^7.37.2", "globals": "^15.14.0", "jest": "^29.7.0", From aae5367ad25d7c41f7ad851a38b95e34609adda6 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Fri, 20 Dec 2024 11:01:55 -0500 Subject: [PATCH 20/22] Add test case for single-line definition list --- tests/markdown/non-breaking-spaces.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/markdown/non-breaking-spaces.test.js b/tests/markdown/non-breaking-spaces.test.js index 20bb8b892..9dad4eb0f 100644 --- a/tests/markdown/non-breaking-spaces.test.js +++ b/tests/markdown/non-breaking-spaces.test.js @@ -51,6 +51,11 @@ describe('Non-Breaking Spaces', ()=>{ expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`
\n:>\n
`); }); + test('I am actually a single-line definition list!', function() { + const source = 'Term ::> Definition 1\n'; + const rendered = Markdown.render(source).trim(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`
Term
> Definition 1
\n
`); + }); test('I am actually a definition list!', function() { const source = 'Term\n::> Definition 1\n'; From 50fcffb2538986fa5716f348980679c631e4213a Mon Sep 17 00:00:00 2001 From: David Bolack Date: Fri, 20 Dec 2024 14:06:20 -0600 Subject: [PATCH 21/22] Revert exclusion on single definition list regex This permits `Term ::> Definition` to process as a single line definition list --- shared/naturalcrit/markdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 6b737e02f..b40887259 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -417,7 +417,7 @@ const definitionListsSingleLine = { level : 'block', start(src) { return src.match(/\n[^\n]*?::[^:\n]*/m)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { - const regex = /^([^\n]*?)::([^\:\>][^\n]*)(?:\n|$)/ym; + const regex = /^([^\n]*?)::([^\n]*)(?:\n|$)/ym; let match; let endIndex = 0; const definitions = []; From adb1db1d3c28115ede5e8182755b06dcf63c39c7 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Fri, 20 Dec 2024 15:39:57 -0500 Subject: [PATCH 22/22] Revert one more regex change --- shared/naturalcrit/markdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index b40887259..852243d81 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -415,7 +415,7 @@ const nonbreakingSpaces = { const definitionListsSingleLine = { name : 'definitionListsSingleLine', level : 'block', - start(src) { return src.match(/\n[^\n]*?::[^:\n]*/m)?.index; }, // Hint to Marked.js to stop and check for a match + start(src) { return src.match(/\n[^\n]*?::[^\n]*/m)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { const regex = /^([^\n]*?)::([^\n]*)(?:\n|$)/ym; let match;