From 67a4391dcbda8668ce8a01bae6e63c721774b1a4 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 13 Dec 2023 15:57:00 -0600 Subject: [PATCH 1/9] WIP --- shared/naturalcrit/markdown.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 7185cab8e..7dbc32f1a 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -234,6 +234,15 @@ const superSubScripts = { } }; +const underline = { + name : 'underline', + level : 'inline', + start(src) { return src.match(/\w_[^_]_/m)?.index;}, + tokenizer(src, tokens) { + const uRegex = /^_(?!\s)(?=([^_]*[^\s]))\1\^/m; + } +} + const definitionLists = { name : 'definitionLists', level : 'block', From 04187cf769fa289ca1a85557b268f99cd7eaac98 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 13 Dec 2023 17:37:05 -0600 Subject: [PATCH 2/9] Simple Underline token. Overrides __ --- shared/naturalcrit/markdown.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 7dbc32f1a..83badb05e 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -239,9 +239,24 @@ const underline = { level : 'inline', start(src) { return src.match(/\w_[^_]_/m)?.index;}, tokenizer(src, tokens) { - const uRegex = /^_(?!\s)(?=([^_]*[^\s]))\1\^/m; + const uRegex = /^_([^_]*)_/m; + const match = uRegex.exec(src); + console.log('Looking'); + if(match?.length) { + console.log('found!'); + console.log(match); + return { + type : 'underline', + raw : match[0], + tokens : this.lexer.inlineTokens(match[1]) + }; + } + }, + renderer(token) { + console.log() + return `${this.parser.parseInline(token.tokens)}`; } -} +}; const definitionLists = { name : 'definitionLists', @@ -275,7 +290,7 @@ const definitionLists = { } }; -Marked.use({ extensions: [mustacheSpans, mustacheDivs, mustacheInjectInline, definitionLists, superSubScripts] }); +Marked.use({ extensions: [mustacheSpans, mustacheDivs, mustacheInjectInline, definitionLists, superSubScripts, underline] }); Marked.use(mustacheInjectBlock); Marked.use({ renderer: renderer, mangle: false }); Marked.use(MarkedExtendedTables(), MarkedGFMHeadingId(), MarkedSmartypantsLite()); From a88b256b6c0692eb1bf79cd4dfa7461a206869ee Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 13 Dec 2023 21:47:55 -0600 Subject: [PATCH 3/9] A better regex for underlining. --- shared/naturalcrit/markdown.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 83badb05e..2c2f356c5 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -237,9 +237,9 @@ const superSubScripts = { const underline = { name : 'underline', level : 'inline', - start(src) { return src.match(/\w_[^_]_/m)?.index;}, + start(src) { return src.match(/\b_(?![_\s])(.*?[^_\s])_\b/m)?.index;}, tokenizer(src, tokens) { - const uRegex = /^_([^_]*)_/m; + const uRegex = /^\b_(?![_\s])(.*?[^_\s])_\b/m; const match = uRegex.exec(src); console.log('Looking'); if(match?.length) { From 1861c7db695e8e0147f633eff672cc13334bae1e Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 13 Dec 2023 21:59:02 -0600 Subject: [PATCH 4/9] Remove stray console.logs. --- shared/naturalcrit/markdown.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 2c2f356c5..3b7981435 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -241,10 +241,7 @@ const underline = { tokenizer(src, tokens) { const uRegex = /^\b_(?![_\s])(.*?[^_\s])_\b/m; const match = uRegex.exec(src); - console.log('Looking'); if(match?.length) { - console.log('found!'); - console.log(match); return { type : 'underline', raw : match[0], @@ -253,7 +250,6 @@ const underline = { } }, renderer(token) { - console.log() return `${this.parser.parseInline(token.tokens)}`; } }; From 8b31966c2ba7962fa4086b4dd71e0cd0dd39fe4d Mon Sep 17 00:00:00 2001 From: David Bolack Date: Thu, 18 Jan 2024 09:51:07 -0600 Subject: [PATCH 5/9] Revert "Remove stray console.logs." This reverts commit 1861c7db695e8e0147f633eff672cc13334bae1e. --- shared/naturalcrit/markdown.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 03020705c..9297717c1 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -241,7 +241,10 @@ const underline = { tokenizer(src, tokens) { const uRegex = /^\b_(?![_\s])(.*?[^_\s])_\b/m; const match = uRegex.exec(src); + console.log('Looking'); if(match?.length) { + console.log('found!'); + console.log(match); return { type : 'underline', raw : match[0], @@ -250,6 +253,7 @@ const underline = { } }, renderer(token) { + console.log() return `${this.parser.parseInline(token.tokens)}`; } }; From ac9fc720f7a77eb903bc41410198929e6d088175 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Thu, 18 Jan 2024 09:51:11 -0600 Subject: [PATCH 6/9] Revert "A better regex for underlining." This reverts commit a88b256b6c0692eb1bf79cd4dfa7461a206869ee. --- shared/naturalcrit/markdown.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 9297717c1..2c7c95375 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -237,9 +237,9 @@ const superSubScripts = { const underline = { name : 'underline', level : 'inline', - start(src) { return src.match(/\b_(?![_\s])(.*?[^_\s])_\b/m)?.index;}, + start(src) { return src.match(/\w_[^_]_/m)?.index;}, tokenizer(src, tokens) { - const uRegex = /^\b_(?![_\s])(.*?[^_\s])_\b/m; + const uRegex = /^_([^_]*)_/m; const match = uRegex.exec(src); console.log('Looking'); if(match?.length) { From 0c6c9fce4d3e8f7dbcb14a68bd4a070026a93c92 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Thu, 18 Jan 2024 09:51:14 -0600 Subject: [PATCH 7/9] Revert "Simple Underline token." This reverts commit 04187cf769fa289ca1a85557b268f99cd7eaac98. --- shared/naturalcrit/markdown.js | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 2c7c95375..cc18d3135 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -239,24 +239,9 @@ const underline = { level : 'inline', start(src) { return src.match(/\w_[^_]_/m)?.index;}, tokenizer(src, tokens) { - const uRegex = /^_([^_]*)_/m; - const match = uRegex.exec(src); - console.log('Looking'); - if(match?.length) { - console.log('found!'); - console.log(match); - return { - type : 'underline', - raw : match[0], - tokens : this.lexer.inlineTokens(match[1]) - }; - } - }, - renderer(token) { - console.log() - return `${this.parser.parseInline(token.tokens)}`; + const uRegex = /^_(?!\s)(?=([^_]*[^\s]))\1\^/m; } -}; +} const definitionLists = { name : 'definitionLists', @@ -290,7 +275,7 @@ const definitionLists = { } }; -Marked.use({ extensions: [mustacheSpans, mustacheDivs, mustacheInjectInline, definitionLists, superSubScripts, underline] }); +Marked.use({ extensions: [mustacheSpans, mustacheDivs, mustacheInjectInline, definitionLists, superSubScripts] }); Marked.use(mustacheInjectBlock); Marked.use({ renderer: renderer, mangle: false }); Marked.use(MarkedExtendedTables(), MarkedGFMHeadingId(), MarkedSmartypantsLite()); From 0c010a0a87ddd044a284f2a7be14be278a7145d9 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Thu, 18 Jan 2024 09:51:17 -0600 Subject: [PATCH 8/9] Revert "WIP" This reverts commit 67a4391dcbda8668ce8a01bae6e63c721774b1a4. --- shared/naturalcrit/markdown.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index cc18d3135..5be80ac97 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -234,15 +234,6 @@ const superSubScripts = { } }; -const underline = { - name : 'underline', - level : 'inline', - start(src) { return src.match(/\w_[^_]_/m)?.index;}, - tokenizer(src, tokens) { - const uRegex = /^_(?!\s)(?=([^_]*[^\s]))\1\^/m; - } -} - const definitionLists = { name : 'definitionLists', level : 'block', From 54921a998a3dc7f63f1a2be91032accd2be78987 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Thu, 25 Jan 2024 19:51:03 -0600 Subject: [PATCH 9/9] Clone tags along with the rest of the brew --- server/app.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/app.js b/server/app.js index 970c2cd9c..fc5d4a035 100644 --- a/server/app.js +++ b/server/app.js @@ -304,7 +304,8 @@ app.get('/new/:id', asyncHandler(getBrew('share')), (req, res, next)=>{ text : req.brew.text, style : req.brew.style, renderer : req.brew.renderer, - theme : req.brew.theme + theme : req.brew.theme, + tags : req.brew.tags }; req.brew = _.defaults(brew, DEFAULT_BREW);