Skip to content

Send custom serializer through options object to enable XHTML output #605

Closed
@danburzo

Description

I'm trying to bundle some web pages filtered through Readability as EPUB, and the format requires the content to be XHTML. However, an element's .innerHTML returns a HTML, not XHTML serialization.

I would like to propose a serializer option, that defaults to serializer: el => el.innerHTML but which can be swapped to serializer: (new window.XMLSerializer()).serializeToString when returning data here:

readability/Readability.js

Lines 2056 to 2065 in 52ab9b5

return {
title: this._articleTitle,
byline: metadata.byline || this._articleByline,
dir: this._articleDir,
content: articleContent.innerHTML,
textContent: textContent,
length: textContent.length,
excerpt: metadata.excerpt,
siteName: metadata.siteName || this._articleSiteName
};

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions