Skip to content

[Feature request] Retain Original HTML Structure and Attributes During Translation #481

@jeffreychuuu

Description

@jeffreychuuu

Is your feature request related to a problem? Please describe
I'm always frustrated when important HTML attributes like id or class are missing after translation. These attributes are often used for internal linking (e.g., anchor links), styling, or JavaScript interactions in ebooks. When they are lost, it breaks navigation and the overall structure of the document.

For example, an element like:

<a id="chapter1" href="#section2">Go to Section 2</a>

will become:

<a href="#section2">前往第2節</a>

Describe the solution you'd like
I'd like to see an option in the plugin settings to preserve original HTML attributes—like id, class, and possibly data-*—when rebuilding the translated content.

This could be a simple checkbox like:

[x] Preserve original HTML attributes during translation

Or an advanced setting where users can list which attributes should be retained (e.g. "id,class,data-*").

Describe alternatives you've considered

  • Manually re-adding lost attributes using the Calibre HTML editor after translation. This is time-consuming and error-prone.

  • Wrapping elements in custom containers and excluding them from translation entirely using "Ignored Elements". This avoids attribute loss but disables content translation, which defeats the purpose.

  • Disabling merging or adjusting translation modes; however, even with these tweaks, attribute loss can still occur in some cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already existsenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions