From a88b256b6c0692eb1bf79cd4dfa7461a206869ee Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 13 Dec 2023 21:47:55 -0600 Subject: [PATCH] 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) {