WebToEpub icon indicating copy to clipboard operation
WebToEpub copied to clipboard

Is there any way to add two content CSS selectors in the same chapter?

Open mrclfr opened this issue 11 months ago • 1 comments

Hello

I would like to know if you could make a feature that would allow us to add two CSS selectors for the content in one chapter.

I will put an example below

Image

mrclfr avatar Jan 18 '25 17:01 mrclfr

@mrclfr

I would like to know if you could make a feature that would allow us to add two CSS selectors for the content in one chapter.

While such a change could be done, I'm not willing to do it. Mostly because I think it would make this interface more difficult for people to understand and use, for the small number of users it would benefit.

That said, I can tell you how to achieve what you're after.

The steps are:

  1. In WebToEpub, provide the CSS selector for an element that is a parent of both the elements you're actually interested in.
  2. Create the epub. Each chapter in the epub will now have both elements you want. (Along with some garbage.)
  3. You can now use a script with EpubEditor to process the epub and remove the garbage.

Example script. Assume the parent selector is div.article, then the script would be something like

let parent = dom.querySelector("div.article");
let review = dom.querySelector("div.review-item");
let author = dom.querySelector("div.author-info");

if (review) {
    parent.replaceWith(review);
    if (author) {
        review.appendChild(author);
    }
    return true;
} else if (author) {
    parent.replaceWith(author);
    return true;
}
return false;

Note, if you can provide me with URL of story you want processed, I'll be able to test the script.

Notes Time taken: 18 minutes

dteviot avatar Jan 21 '25 06:01 dteviot

Closing, due to lack of response

dteviot avatar Feb 23 '25 21:02 dteviot