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:
@@ -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();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user