Skip to content

Commit

Permalink
fix: misuse of m flag
Browse files Browse the repository at this point in the history
`m` flag means match newline with `^` and `$`, but what we want is to
match real start and end of string.
The correct "dot-all" flag is `s` which is used correctly.

Fixes #6
  • Loading branch information
AllanChain committed Oct 2, 2023
1 parent 037bbe3 commit ae573e6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function main() {
}
}
if (event.text.length <= 2) return
if (!event.text.match(/^(\$+)([^$]+)\1$/m)) return
if (!event.text.match(/^(\$+)([^$]+)\1$/)) return
const block = await logseq.Editor.getCurrentBlock()
if (block === null) return
openPopup(block.uuid, {
Expand Down
2 changes: 1 addition & 1 deletion src/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function openPopup(
let delim = logseq.settings?.preferDisplay ? '$$' : '$'
let newline = logseq.settings?.preferMultiline ? '\n' : ''
if (originalContent) {
const match = originalContent.match(/^(?<delim>\$+)(?<newline>\n*)(?<content>.*)\2\1$/ms)
const match = originalContent.match(/^(?<delim>\$+)(?<newline>\n*)(?<content>.*)\2\1$/s)
if (match !== null && match.groups !== undefined) {
originalValue = match.groups.content
delim = match.groups.delim
Expand Down

0 comments on commit ae573e6

Please sign in to comment.