aboutsummaryrefslogtreecommitdiff
path: root/src/scraper.test.ts
diff options
context:
space:
mode:
authorJoe Mou <dev@mou.fo>2026-04-20 17:14:11 -0400
committerJoe Mou <dev@mou.fo>2026-04-20 21:25:43 -0400
commitf179a3f77c6617b4375e6149cc696ae5dab4d171 (patch)
treec12be415c1bfa7c806082d899cb51df5fc6543c3 /src/scraper.test.ts
parentd2001c480e6f9fe171fe249c4bfeb7f540a70b13 (diff)
Apply overlapping styling drectives instead of duplicating content
Diffstat (limited to 'src/scraper.test.ts')
-rw-r--r--src/scraper.test.ts24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/scraper.test.ts b/src/scraper.test.ts
index a843561..4432231 100644
--- a/src/scraper.test.ts
+++ b/src/scraper.test.ts
@@ -95,7 +95,7 @@ describe("GitHub scraper", () => {
assert.strictEqual(data.textLines?.[0], "# deploy-pages 🚀");
assert.strictEqual(
data.htmlLines?.[0],
- '<span class="pl-mh"># deploy-pages 🚀</span>deploy-pages 🚀<span class="pl-en">deploy-pages 🚀</span>',
+ '<span class="pl-mh"># <span class="pl-en">deploy-pages 🚀</span></span>',
);
const firstLine =
/^<article class="markdown-body entry-content container-lg" itemprop="text"><div class="markdown-heading" dir="auto"><h1 tabindex="-1" class="heading-element" dir="auto">deploy-pages 🚀<\/h1>/;
@@ -197,6 +197,28 @@ describe("GitHub scraper", () => {
});
});
+ describe("dustinlyons/nixos-config repository", () => {
+ it("should fetch nix blob with combined overlapping styling directives", async () => {
+ const data = await getGitHubBlob("dustinlyons", "nixos-config", "main", "flake.nix");
+
+ assert.strictEqual(data.repo.owner, "dustinlyons");
+ assert.strictEqual(data.repo.name, "nixos-config");
+ assert.strictEqual(data.path, "flake.nix");
+ assert.strictEqual(data.image, false);
+ assert.strictEqual(data.htmlContent, null);
+ assert.ok(data.htmlLines !== null && data.htmlLines.length > 0);
+
+ // Line 2 has directives [2,13,"pl-c1"] and [2,13,"pl-s1"] with identical ranges.
+ // They should be combined into one span, not duplicated.
+ const line2 = data.htmlLines[1];
+ assert.ok(line2.includes('class="pl-c1 pl-s1"'), `expected combined classes in: ${line2}`);
+ assert.ok(
+ (line2.match(/description/g) ?? []).length === 1,
+ `expected "description" to appear once in: ${line2}`,
+ );
+ });
+ });
+
describe("rich file types", () => {
it("should support PNG", async () => {
const data = await getGitHubBlob("github", "docs", "main", "assets/images/site/logo.png");