More metadata#52
Merged
danigm merged 8 commits intodanigm:masterfrom May 26, 2025
Merged
Conversation
Struct `MetadataItem` is introduced mainly to support more information than the data value (e.g,. refinements such as "file-as"). The reason to change from HashMap to Vec isn't significant. Vec is slightly easier to construct and does reflect the original element better, preserving the data items' order. In this commit, metadata does not have more or less info. The incomplete construction for EPUB2 will be completed next, and the implementation for EPUB3 following that.
Finish the parsing of metadata. One design decision made here is to reject as little data as possible, so that it supports EPUB files well even if they have features not in accordance to the file's EPUB version. Word "value" replaces "text" to represent property values.
`mdata()` used to return the value. It now returns the item (reference) where the value can still be easily accessed via `item.value`. A similar method `refinement()` is added to `MetadataItem` to query a refinement.
danigm
approved these changes
May 26, 2025
Owner
danigm
left a comment
There was a problem hiding this comment.
Looks good to me. The only thing that I have to say is that the fill_metadata function is getting more and more complex, so maybe it's worth to split to reduce the depth.
Contributor
Author
I agree. When doing that, it is perhaps worth converting it to a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mainly, extract more data from the metadata section, store it using a new struct
MetadataItem, and changeEpubDoc::metadatafromHashMap<String, Vec<String>>toVec<MetadataItem>.Auxiliary info in metadata that isn't the values is often helpful. E.g., reading systems may wish to render metadata values in the right fonts with the help of
lang, to access creators'file-asandrole.Addresses #26
P.S. The first commit in this thread is code formatting. So perhaps it's easier to compare with master modulus that. Review and suggestions are appreciated.