Download app/src/markdown.mjs from Mike0021/MiniCPM5-2B-WebGPU-Pi-HTTP: direct link, hf CLI and curl.
- Browser
- Download file 699 Bytes
-
https://huggingface.co/spaces/Mike0021/MiniCPM5-2B-WebGPU-Pi-HTTP/resolve/main/app/src/markdown.mjs
- Command line
-
hf download hf://spaces/Mike0021/MiniCPM5-2B-WebGPU-Pi-HTTP/app/src/markdown.mjs
-
curl -L -o markdown.mjs https://huggingface.co/spaces/Mike0021/MiniCPM5-2B-WebGPU-Pi-HTTP/resolve/main/app/src/markdown.mjs
699 Bytes
| import MarkdownIt from 'markdown-it'; | |
| const md = new MarkdownIt({ html: false, linkify: false, breaks: true }); | |
| // Model output cannot initiate image requests. Links open only on user action. | |
| md.renderer.rules.image = (tokens, index) => md.utils.escapeHtml(tokens[index].content); | |
| const defaultLink = md.renderer.rules.link_open ?? ((tokens, index, options, env, self) => self.renderToken(tokens, index, options)); | |
| md.renderer.rules.link_open = (tokens, index, options, env, self) => { | |
| tokens[index].attrSet('target', '_blank'); tokens[index].attrSet('rel', 'noopener noreferrer'); | |
| return defaultLink(tokens, index, options, env, self); | |
| }; | |
| export const renderMarkdown = text => md.render(text); | |