Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only match entities not embedded in links #3

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 2 additions & 55 deletions src/__tests__/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,30 +554,7 @@ https://host.com/2.jpeg
"type": "link",
},
],
"text": "https://github.com/",
"type": "text",
},
{
"attrs": {
"nprofile": "nostr:npub1cesrkrcuelkxyhvupzm48e8hwn4005w0ya5jyvf9kh75mfegqx0q4kt37c",
"pubkey": "c6603b0f1ccfec625d9c08b753e4f774eaf7d1cf2769223125b5fd4da728019e",
"relays": [],
},
"type": "nprofile",
},
{
"marks": [
{
"attrs": {
"class": null,
"href": "https://github.com/nostr:npub1cesrkrcuelkxyhvupzm48e8hwn4005w0ya5jyvf9kh75mfegqx0q4kt37c/wrong/link/",
"rel": "noopener noreferrer nofollow",
"target": "_blank",
},
"type": "link",
},
],
"text": "/wrong/link/",
"text": "https://github.com/nostr:npub1cesrkrcuelkxyhvupzm48e8hwn4005w0ya5jyvf9kh75mfegqx0q4kt37c/wrong/link/",
"type": "text",
},
{
Expand All @@ -596,37 +573,7 @@ https://host.com/2.jpeg
"type": "link",
},
],
"text": "https://github.com/",
"type": "text",
},
],
"type": "paragraph",
},
{
"attrs": {
"author": "0a5a87baeead12b08c0c026caa46c009bb533aae1bd1681f52d609dd2b6fd8bc",
"id": "2ceb90d42ab5a19b76dddfbda45687bc8011917a41286783edd14ca690fd86ee",
"kind": null,
"nevent": "nostr:nevent1qgsq5k58hth26y4s3sxqym92gmqqnw6n82hph5tgrafdvzwa9dha30qqyqkwhyx59266rxmkmh0mmfzks77gqyv30fqjseurahg5ef5slkrwuzwpwzp",
"relays": [],
},
"type": "nevent",
},
{
"content": [
{
"marks": [
{
"attrs": {
"class": null,
"href": "https://github.com/nostr:nevent1qgsq5k58hth26y4s3sxqym92gmqqnw6n82hph5tgrafdvzwa9dha30qqyqkwhyx59266rxmkmh0mmfzks77gqyv30fqjseurahg5ef5slkrwuzwpwzp/error",
"rel": "noopener noreferrer nofollow",
"target": "_blank",
},
"type": "link",
},
],
"text": "/error",
"text": "https://github.com/nostr:nevent1qgsq5k58hth26y4s3sxqym92gmqqnw6n82hph5tgrafdvzwa9dha30qqyqkwhyx59266rxmkmh0mmfzks77gqyv30fqjseurahg5ef5slkrwuzwpwzp/error",
"type": "text",
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/Bolt11Extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { decode } from 'light-bolt11-decoder'
import type { MarkdownSerializerState } from 'prosemirror-markdown'
import { createPasteRuleMatch } from '../helpers/utils'

const LNBC_REGEX = /(lnbc[0-9a-z]{10,})/g
const LNBC_REGEX = /(?<![\w./:?=])(lnbc[0-9a-z]{10,})/g

export interface Bolt11Attributes {
lnbc: string
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/NAddrExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { AddressPointer } from 'nostr-tools/nip19'
import type { MarkdownSerializerState } from 'prosemirror-markdown'
import { createPasteRuleMatch, parseRelayAttribute } from '../helpers/utils'

export const NADDR_REGEX = /(nostr:)?(naddr1[0-9a-z]+)/g
export const NADDR_REGEX = /(?<![\w./:?=])(nostr:)?(naddr1[0-9a-z]+)/g

export interface NAddrAttributes {
naddr: string
Expand Down
4 changes: 2 additions & 2 deletions src/extensions/NEventExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import type { EventPointer } from 'nostr-tools/nip19'
import type { MarkdownSerializerState } from 'prosemirror-markdown'
import { createPasteRuleMatch, parseRelayAttribute } from '../helpers/utils'

export const NOTE_REGEX = /(nostr:)?(note1[0-9a-z]+)/g
export const NOTE_REGEX = /(?<![\w./:?=])(nostr:)?(note1[0-9a-z]+)/g

export const NEVENT_REGEX = /(nostr:)?(nevent1[0-9a-z]+)/g
export const NEVENT_REGEX = /(?<![\w./:?=])(nostr:)?(nevent1[0-9a-z]+)/g

export interface NEventAttributes {
nevent: string
Expand Down
4 changes: 2 additions & 2 deletions src/extensions/NProfileExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import type { ProfilePointer } from 'nostr-tools/nip19'
import type { MarkdownSerializerState } from 'prosemirror-markdown'
import { createPasteRuleMatch, parseRelayAttribute } from '../helpers/utils'

export const NPUB_REGEX = /(nostr:)?(npub1[0-9a-z]+)/g
export const NPUB_REGEX = /(?<![\w./:?=])(nostr:)?(npub1[0-9a-z]+)/g

export const NPROFILE_REGEX = /(nostr:)?(nprofile1[0-9a-z]+)/g
export const NPROFILE_REGEX = /(?<![\w./:?=])(nostr:)?(nprofile1[0-9a-z]+)/g

export type NProfileAttributes = {
nprofile: string
Expand Down
Loading