diff options
| author | Joe Mou <dev@mou.fo> | 2026-01-28 13:05:02 -0500 |
|---|---|---|
| committer | Joe Mou <dev@mou.fo> | 2026-01-28 15:17:54 -0500 |
| commit | dd8d686c9eb9a68eb057aaf86206bc930e22d09a (patch) | |
| tree | df34df851c57e2d268fba42ecff0708bfd8a8e18 /src/scraper.ts | |
| parent | 200defaa5c769b4603f9256e943821344cadbe82 (diff) | |
Render Markdown blobs
Diffstat (limited to 'src/scraper.ts')
| -rw-r--r-- | src/scraper.ts | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/src/scraper.ts b/src/scraper.ts index bbf7511..c2983c9 100644 --- a/src/scraper.ts +++ b/src/scraper.ts @@ -16,7 +16,6 @@ interface TreeItem { interface OverviewFile { displayName: string; - preferredFileType: string; richText?: string; loaded: boolean; } @@ -64,12 +63,17 @@ interface RawPayload { items: TreeItem[]; }; blob?: { + headerInfo: { + blobSize: string; + lineInfo: { + truncatedLoc: string; + truncatedSloc: string; + }; + }; language?: string; - rawLines?: string[]; - highlightedLines?: { - text?: string; - }[]; - size: number; + rawLines: string[] | null; + colorizedLines: string[] | null; + richText: string | null; }; overview?: { overviewFiles?: OverviewFile[]; @@ -110,9 +114,9 @@ export interface GitHubRepo extends GitHubTree { export interface GitHubBlob extends GitHubNav { language: string | null; - size: number | null; - content: string; - rawContent: string; + size: string; + rawLines: string[] | null; + htmlContent: string | null; } interface Issue { @@ -265,20 +269,15 @@ export async function getGitHubBlob( throw new Error("Could not find blob data in embedded JSON"); } - const blob = payload.blob; - const rawLines = blob.rawLines || []; - const rawContent = rawLines.join("\n"); - const highlightedLines = blob.highlightedLines || []; - const content = highlightedLines.map((line) => line.text || "").join("\n"); - - // Calculate size from raw content if not provided - const size = blob.size ?? (rawContent.length > 0 ? Buffer.byteLength(rawContent, "utf8") : null); + const { headerInfo, language, rawLines, richText } = payload.blob; + // TODO fine tune + const size = `${headerInfo.blobSize} / ${headerInfo.lineInfo.truncatedLoc} lines / ${headerInfo.lineInfo.truncatedSloc} loc`; return extractGitHub(payload, { - content: content || rawContent, - rawContent, - language: blob.language || null, + language: language || null, size, + rawLines, + htmlContent: richText, }); } |
