File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -77,12 +77,20 @@ export default function rehypeSN (options = {}) {
77
77
if ( node . tagName === 'a' &&
78
78
! parent . children . some ( s => s . type === 'text' && s . value . trim ( ) ) &&
79
79
toString ( node ) === node . properties . href ) {
80
- const embed = parseEmbedUrl ( node . properties . href )
81
- if ( embed ) {
82
- node . tagName = 'embed'
83
- node . properties = { ... embed , src : node . properties . href }
84
- } else {
80
+ nostrIdRegex . lastIndex = 0
81
+ const isNostrLink = nostrIdRegex . test ( node . properties . href )
82
+ nostrIdRegex . lastIndex = 0
83
+
84
+ if ( isNostrLink ) {
85
85
node . tagName = 'autolink'
86
+ } else {
87
+ const embed = parseEmbedUrl ( node . properties . href )
88
+ if ( embed ) {
89
+ node . tagName = 'embed'
90
+ node . properties = { ...embed , src : node . properties . href }
91
+ } else {
92
+ node . tagName = 'autolink'
93
+ }
86
94
}
87
95
}
88
96
@@ -137,7 +145,7 @@ export default function rehypeSN (options = {}) {
137
145
}
138
146
139
147
// Handle Nostr IDs
140
- if ( node . type === 'text' ) {
148
+ if ( node . type === 'text' && ! ( parent && [ 'a' , 'autolink' ] . includes ( parent . tagName ) ) ) {
141
149
const newChildren = [ ]
142
150
let lastIndex = 0
143
151
let match
You can’t perform that action at this time.
0 commit comments