-
Notifications
You must be signed in to change notification settings - Fork 600
Supporting MuPDF file recognizer #4481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JorjMcKie
wants to merge
1
commit into
main
Choose a base branch
from
support-mupdf-recognizer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:xlink="http://www.w3.org/1999/xlink"> | ||
<description> | ||
<title-info> | ||
<genre>computers</genre> | ||
<author> | ||
<first-name>Chris</first-name> | ||
<last-name>Clark</last-name> | ||
</author> | ||
<book-title>Sample FB2 book</book-title> | ||
<annotation> | ||
<p>Short sample of a FictionBook2 book with simple metadata. Based on test_book.md from https://github.com/clach04/sample_reading_media</p> | ||
</annotation> | ||
<keywords>ebook,sample,markdown,fb2,FictionBook2</keywords> | ||
</title-info> | ||
<document-info> | ||
<author> | ||
<nickname>clach04</nickname> | ||
<home-page>https://github.com/clach04/sample_reading_media</home-page> | ||
</author> | ||
|
||
<program-used>vim and scite</program-used> | ||
<src-url>https://github.com/clach04/sample_reading_media</src-url> | ||
<version>1.0</version> | ||
<history> | ||
<p>Initial version, written by hand.</p> | ||
</history> | ||
</document-info> | ||
</description> | ||
<body> | ||
<title> | ||
<p>This is a title</p> | ||
</title> | ||
|
||
<section id="test-header-h1"> | ||
<title> | ||
<p>Test Header h1</p> | ||
</title> | ||
|
||
<p>A test paragraph.</p> | ||
<p>Another test paragraph.</p> | ||
</section> | ||
|
||
<section id="another-test-header-h1"> | ||
<title> | ||
<p>Another Test Header h1</p> | ||
</title> | ||
|
||
<section id="a-test-header-h2"> | ||
<title> | ||
<p>A Test Header h2</p> | ||
</title> | ||
|
||
<section id="a-test-header-h3"> | ||
<title> | ||
<p>A Test Header h3</p> | ||
</title> | ||
|
||
<p>Yet more copy</p> | ||
</section> | ||
</section> | ||
</section> | ||
</body> | ||
</FictionBook> |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this contradict the new docs which says:
:arg str filetype: A string specifying the type of document. Will be ignored in most [#f8]_ cases for :ref:
a supported document type<Supported_File_Types>
.?
Shouldn't we should get a handler with
fz_recognize_document_stream_content()
here, so that the contents overrides the suppliedmagic
where possible?Or simply use
fz_open_document_with_stream()
, i.e. don't create an intermediate handler? I.e. remove the entireif magic: ...
block in the code?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The recognizer seems to always detect the type except in 3 cases: "txt", "fb2", "mobi". This means we have identical behavior between file-open versus stream-open.
Only those three cases still require the correct extension, respectively filetype. Everything else disregards file extension, respectively needs no filetype-help.
The two cases "fb2" and "mobi" can be resolved with a little improved recognizer, which will hopefully happen soon.
The case "txt" remains an exception because of principle reasons.
This is the background of my new logic.