Spaces:
Runtime error
Runtime error
Download api/src/utils/scrape/plugins/inlineLink.ts from supernovagateway/Steel: direct link, hf CLI and curl.
- Browser
- Download file 725 Bytes
-
https://huggingface.co/spaces/supernovagateway/Steel/resolve/main/api/src/utils/scrape/plugins/inlineLink.ts
- Command line
-
hf download hf://spaces/supernovagateway/Steel/api/src/utils/scrape/plugins/inlineLink.ts
-
curl -L -o inlineLink.ts https://huggingface.co/spaces/supernovagateway/Steel/resolve/main/api/src/utils/scrape/plugins/inlineLink.ts
725 Bytes
| // Adapted from https://github.com/laurent22/joplin/blob/dev/packages/turndown-plugin-gfm/src/tables.js | |
| import TurndownService from "@joplin/turndown"; | |
| export default function inlineLink(turndownService: TurndownService) { | |
| turndownService.addRule("inlineLink", { | |
| filter: function (node, options) { | |
| return ( | |
| options.linkStyle === "inlined" && node.nodeName === "A" && !!node.getAttribute("href") | |
| ); | |
| }, | |
| replacement: function (content, node) { | |
| const href = (node as HTMLElement).getAttribute("href")?.trim(); | |
| const title = (node as HTMLElement).title ? ' "' + (node as HTMLElement).title + '"' : ""; | |
| return "[" + content.trim() + "](" + href + title + ")\n"; | |
| }, | |
| }); | |
| } | |