Download frontend/src/utils/parse-cell-content.ts from ar08/zzz: direct link, hf CLI and curl.
- Browser
- Download file 695 Bytes
-
https://huggingface.co/spaces/ar08/zzz/resolve/main/frontend/src/utils/parse-cell-content.ts
- Command line
-
hf download hf://spaces/ar08/zzz/frontend/src/utils/parse-cell-content.ts
-
curl -L -o parse-cell-content.ts https://huggingface.co/spaces/ar08/zzz/resolve/main/frontend/src/utils/parse-cell-content.ts
695 Bytes
| export type JupyterLine = { type: "plaintext" | "image"; content: string }; | |
| export const parseCellContent = (content: string) => { | |
| const lines: JupyterLine[] = []; | |
| let currentText = ""; | |
| for (const line of content.split("\n")) { | |
| if (line.startsWith(") { | |
| if (currentText) { | |
| lines.push({ type: "plaintext", content: currentText }); | |
| currentText = ""; // Reset after pushing plaintext | |
| } | |
| lines.push({ type: "image", content: line }); | |
| } else { | |
| currentText += `${line}\n`; | |
| } | |
| } | |
| if (currentText) { | |
| lines.push({ type: "plaintext", content: currentText }); | |
| } | |
| return lines; | |
| }; | |