Skip to content

Add --rights <text> flag for stamping dc:rights (closes #21)#24

Merged
roelvangils merged 1 commit into
mainfrom
feature/rights-flag
May 5, 2026
Merged

Add --rights <text> flag for stamping dc:rights (closes #21)#24
roelvangils merged 1 commit into
mainfrom
feature/rights-flag

Conversation

@roelvangils
Copy link
Copy Markdown
Member

Summary

Tiny feature implementing #21. `dpub convert --rights ""` stamps a free-text `dc:rights` element into the EPUB's OPF metadata.

Why

Producers redistributing accessibility-exception copies routinely need to assert the rights frame they're operating under — copyright statement, Marrakesh Treaty, Belgian / EU exception, etc. DAISY 2.02 NCCs sometimes carry that in `dc:rights` and sometimes don't (the reference Belgian title in this project's memory does not). Before this PR, dpub had no way to add it.

Behaviour

  • Source-NCC fallback: `build_package_metadata` defaults `rights` from the source NCC's `other.get("dc:rights")` so books that already carry rights info don't lose it on conversion.
  • CLI override: `--rights ""` wins over the source.
  • Omitted flag + missing source = no `dc:rights` element emitted (current behaviour preserved).

Implementation

  • `PackageMetadata.rights: Option` in `epub3-writer/src/model.rs`. Surfaced as `dc:rights` in `writers.rs::write_opf_metadata`.
  • `ConvertOptions.rights: Option` in `dpub-convert/src/lib.rs`. Override applied after the initial `convert(book)` call.
  • CLI flag in `dpub-cli/src/main.rs`.

Out of scope

  • `--rights-from-file ` for longer text. Trivial follow-up if needed.
  • Structured rights statements (CC URIs, Marrakesh-statement libraries). Plain text is enough for v1.

Test plan

  • `cargo test --workspace` green.
  • `cargo clippy -p epub3-writer -p dpub-convert -p dpub-cli --all-targets -- -D warnings` clean.

Producers redistributing accessibility-exception copies routinely
need to assert the rights frame they're operating under (Marrakesh
Treaty, EU exception, copyright statement). DAISY 2.02 NCCs
sometimes carry that in dc:rights and sometimes don't (the
reference Belgian title in our memory tests does not).

  * `PackageMetadata.rights: Option<String>` added in
    `epub3-writer/src/model.rs`. Surfaced as `<dc:rights>` in the
    OPF metadata block.
  * `ConvertOptions.rights: Option<String>` added in
    `dpub-convert/src/lib.rs`. CLI override applied after the
    initial `convert(book)` call.
  * `build_package_metadata` defaults `rights` from the source
    NCC's `other.get("dc:rights")` so books that already carry
    rights info don't lose it on conversion.
  * CLI: `--rights "<text>"` flag on `dpub convert`. Override
    semantics — explicit flag wins.

Plain text only for v1; structured rights statements (CC URIs,
Marrakesh statement libraries) are a future enhancement.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@roelvangils roelvangils merged commit b572e05 into main May 5, 2026
@roelvangils roelvangils deleted the feature/rights-flag branch May 5, 2026 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant