From 4c5ef28901eb38a89976dcc4eb1d7ca61818768b Mon Sep 17 00:00:00 2001 From: Balrog57 <193098123+Balrog57@users.noreply.github.com> Date: Sat, 5 Sep 2026 01:25:07 +0200 Subject: [PATCH] fix(french): novhell chapters using Gutenberg template --- plugins/french/novhell.ts | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/plugins/french/novhell.ts b/plugins/french/novhell.ts index a71ea2013..8adb7720a 100644 --- a/plugins/french/novhell.ts +++ b/plugins/french/novhell.ts @@ -36,7 +36,7 @@ class NovhellPlugin implements Plugin.PluginBase { name = 'Novhell'; icon = 'src/fr/novhell/icon.png'; site = 'https://novhell.org'; - version = '1.0.4'; + version = '1.0.5'; async getCheerio(url: string): Promise { return load( @@ -209,6 +209,34 @@ class NovhellPlugin implements Plugin.PluginBase { return content; } } + // Newer chapters use a Gutenberg block template with no `section` + // elements: title in the columns block holding the `h4`, body in the + // longest columns block of `article .entry-content`. + const entry = $('article .entry-content').first(); + if (entry.length) { + let titleHtml = ''; + let bodyHtml = ''; + let bodyLength = 0; + entry.children('div.wp-block-columns').each((_, element) => { + const block = $(element); + if (block.find('h4').length) { + if (!titleHtml) titleHtml = $.html(element) || ''; + return; + } + const textLength = block.text().replace(/\s+/g, ' ').trim().length; + if (textLength > bodyLength) { + bodyLength = textLength; + bodyHtml = $.html(element) || ''; + } + }); + const content = titleHtml + bodyHtml; + const parsedContent = load(content); + if ( + parsedContent.text().replace(/\s+/g, ' ').trim().length >= 200 || + parsedContent('img').length + ) + return content; + } throw new Error('No readable chapter content found'); }