(target: string, anchor?: string, alias?: string)
| 106 | } |
| 107 | |
| 108 | export function parseWikiRef(target: string, anchor?: string, alias?: string): WikiRef { |
| 109 | let normAnchor: string | null = null; |
| 110 | let isBlock = false; |
| 111 | if (anchor) { |
| 112 | if (anchor.startsWith("^")) { |
| 113 | normAnchor = anchor.slice(1); |
| 114 | isBlock = true; |
| 115 | } else { |
| 116 | normAnchor = anchor; |
| 117 | } |
| 118 | } |
| 119 | return { |
| 120 | path: normalizeRefPath(target), |
| 121 | anchor: normAnchor, |
| 122 | isBlock, |
| 123 | alias: alias?.trim() || null, |
| 124 | }; |
| 125 | } |
| 126 | |
| 127 | /** 默认显示文本:alias 优先;没有时用 path#anchor 的精简形 */ |
| 128 | export function refDisplayText(ref: WikiRef): string { |
no test coverage detected