Spaces:
Sleeping
Sleeping
Download frontend/src/lib/remarkSource.ts from insight-ai/web: direct link, hf CLI and curl.
- Browser
- Download file 619 Bytes
-
https://huggingface.co/spaces/insight-ai/web/resolve/main/frontend/src/lib/remarkSource.ts
- Command line
-
hf download hf://spaces/insight-ai/web/frontend/src/lib/remarkSource.ts
-
curl -L -o remarkSource.ts https://huggingface.co/spaces/insight-ai/web/resolve/main/frontend/src/lib/remarkSource.ts
619 Bytes
| import { visit } from 'unist-util-visit' | |
| import type { Plugin } from 'unified' | |
| import type { Root, HTML } from 'mdast' | |
| const remarkSource: Plugin = () => (tree: Root) => { | |
| visit(tree, 'html', (node: HTML, index, parent) => { | |
| if (node.value.startsWith('<source')) { | |
| console.debug('[remarkSource] found source tag:', node.value) | |
| } | |
| const match = node.value.match(/<source\s+path=['"](.+?)['"]\s*\/>/) | |
| if (!match || !parent) return | |
| const [, path] = match | |
| parent.children.splice(index, 1, { | |
| type: 'source', | |
| path, | |
| data: {}, | |
| } as any) | |
| }) | |
| } | |
| export default remarkSource | |