feat(scripts): strip translator credits and promo lines from fetched and existing EPUBs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
masi
2026-09-25 17:18:05 -03:00
parent fba9a35075
commit 750c2824ce
3 changed files with 82 additions and 1 deletions
+3 -1
View File
@@ -6,6 +6,7 @@ import { load } from 'cheerio';
import fs from 'fs';
import path from 'path';
import { loadPlugins, print, ROOT } from './load-plugins.js';
import { stripPromo } from './clean-chapter.js';
// Be gentle with the source site: few parallel requests, retries with backoff.
const CONCURRENCY = 3;
@@ -51,10 +52,11 @@ const esc = s =>
);
// Chapter HTML is tag soup; re-serialise it as well-formed XHTML without
// scripts or remote resources (an EPUB must be self-contained).
// scripts, remote resources (an EPUB must be self-contained) or promo lines.
const toXhtml = html => {
const $ = load(html, null, false);
$('script, style, iframe, link, meta, img, video, audio, source').remove();
stripPromo($);
return $.xml();
};