( options?: RemendOptions )
| 234 | |
| 235 | // Also enable links handler when images option is enabled |
| 236 | const getEnabledBuiltInHandlers = ( |
| 237 | options?: RemendOptions |
| 238 | ): Array<{ |
| 239 | handler: RemendHandler; |
| 240 | earlyReturn?: (result: string) => boolean; |
| 241 | }> => { |
| 242 | const linkMode: LinkMode = options?.linkMode ?? "protocol"; |
| 243 | |
| 244 | return builtInHandlers |
| 245 | .filter(({ handler, optionKey }) => { |
| 246 | // Special case: links handler is enabled by either links or images option |
| 247 | if (handler.name === "links") { |
| 248 | return isEnabled(options?.links) || isEnabled(options?.images); |
| 249 | } |
| 250 | // Special case: inlineKatex is opt-in (defaults to false, unlike other options) |
| 251 | if (handler.name === "inlineKatex") { |
| 252 | return isOptedIn(options?.inlineKatex); |
| 253 | } |
| 254 | return isEnabled(options?.[optionKey]); |
| 255 | }) |
| 256 | .map(({ handler, earlyReturn }) => { |
| 257 | // Special case: wrap links handler to pass linkMode option |
| 258 | if (handler.name === "links") { |
| 259 | return { |
| 260 | handler: { |
| 261 | ...handler, |
| 262 | handle: (text: string) => |
| 263 | handleIncompleteLinksAndImages(text, linkMode), |
| 264 | }, |
| 265 | // Only use early return for protocol mode (text-only won't end with the marker) |
| 266 | earlyReturn: linkMode === "protocol" ? earlyReturn : undefined, |
| 267 | }; |
| 268 | } |
| 269 | return { handler, earlyReturn }; |
| 270 | }); |
| 271 | }; |
| 272 | |
| 273 | // Parses markdown text and removes incomplete tokens to prevent partial rendering |
| 274 | const remend = (text: string, options?: RemendOptions): string => { |
no test coverage detected