Skip to content

Commit 87f780c

Browse files
committed
fix: match markdown formatting around abbreviations
1 parent d4ae97f commit 87f780c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/commands/abbreviations.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export function registerListAbbreviationsCommand (context, outputChannel) {
6565
let firstFullIdx = -1
6666

6767
// Look for term
68-
const termRgx = new RegExp(`(?:^|[\\s>([])(?<term>${escapeRegExp(abbr.term)})(?:$|[\\s.,<>)\\]:])`, 'g')
68+
const termRgx = new RegExp(`(?:^|[\\s>([*_])(?<term>${escapeRegExp(abbr.term)})(?:$|[\\s.,<>)*_\\]:])`, 'g')
6969

7070
while ((rgxArray = termRgx.exec(contents)) !== null) {
7171
if (rgxArray.groups?.term) {
@@ -83,7 +83,7 @@ export function registerListAbbreviationsCommand (context, outputChannel) {
8383

8484
// Look for full expansion
8585
if (abbr.full) {
86-
const fullRgx = new RegExp(`(?:^|[\\s>([])(?<full>${escapeRegExp(abbr.full)})(?:$|[\\s.,<>)\\]:])`, 'gi')
86+
const fullRgx = new RegExp(`(?:^|[\\s>([*_])(?<full>${escapeRegExp(abbr.full)})(?:$|[\\s.,<>)*_\\]:])`, 'gi')
8787

8888
while ((rgxArray = fullRgx.exec(contents)) !== null) {
8989
if (rgxArray.groups?.full) {
@@ -101,7 +101,7 @@ export function registerListAbbreviationsCommand (context, outputChannel) {
101101

102102
// Look for redundant word after abbreviation
103103
const lastExpansionWord = abbr.full.split(' ').pop()
104-
const redundantRgx = new RegExp(`(?:^|[\\s>([])(?<term>${escapeRegExp(abbr.term)}[\\s\\-]${escapeRegExp(lastExpansionWord)})(?:$|[\\s.,<>)\\]:])`, 'gi')
104+
const redundantRgx = new RegExp(`(?:^|[\\s>([*_])(?<term>${escapeRegExp(abbr.term)}[\\s\\-]${escapeRegExp(lastExpansionWord)})(?:$|[\\s.,<>)*_\\]:])`, 'gi')
105105
while ((rgxArray = redundantRgx.exec(contents)) !== null) {
106106
if (rgxArray.groups?.term) {
107107
const startIdx = rgxArray[0].indexOf(abbr.term) === 0 ? rgxArray.index : rgxArray.index + 1

0 commit comments

Comments
 (0)