Skip to content

Commit

Permalink
fix: adjust position offset in wikiLinks function
Browse files Browse the repository at this point in the history
  • Loading branch information
purocean committed Jan 13, 2025
1 parent 1b8b2e4 commit 3ebef13
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/renderer/plugins/markdown-wiki-links/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export const RULE_NAME = 'wiki-links'
export function wikiLinks (state: StateInline, silent?: boolean) {
const isImage = state.src.charCodeAt(state.pos) === 0x21/* ! */

const offset = isImage ? 3 : 2
const offset = isImage
? 3 // ![[
: 2 // [[

// check [[
if (state.src.charCodeAt(state.pos + offset - 2) !== 0x5B/* [ */ || state.src.charCodeAt(state.pos + offset - 1) !== 0x5B/* [ */) {
Expand Down Expand Up @@ -82,7 +84,7 @@ export function wikiLinks (state: StateInline, silent?: boolean) {
}
}

state.pos = endPos + offset
state.pos = endPos + 2 // ]]

return true
}

0 comments on commit 3ebef13

Please sign in to comment.