-
Notifications
You must be signed in to change notification settings - Fork 20
Revise book data writing function #117
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
base: master
Are you sure you want to change the base?
Revise book data writing function #117
Conversation
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.
Very nice!
I didn't look at the algorithm itself, if it can generate a simple book, I'll trust it's correct. But I did leave a few comments.
How close is this code to the linked projects? Should we include their licenses?
It might be better to move the character width dict into a separate (private) file, but that can be done later.
- ``\\\\s``: When at start of page, print page as string directly | ||
- ``\\c``: When at start of line, align text to center | ||
- ``\\r``: When at start of line, align text to right side |
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.
Any reason why these are no longer supported? Removing support for them is a breaking change. In this case I'm willing to turn a blind eye to that, but it would be better if we could keep them.
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.
I'm aware of this. I couldn't quite figure out how to re-implement these. But I wouldn't say it's impossible. I will take another look at it.
The character list is pretty much verbatim, the only difference being that I reformatted from JSON into a Python dict. I shall a comment that mentions their MIR license. Gutencraft, the code on which the book writing algorithm is based, doesn't have a license at the moment. When I started this project I made an incorrect assumption that no license meant it's free for the taking, but in actuality this means legally can only view and fork the code. So I've filed an issue which will need to be resolved before this can be merged. |
Complete revision of the function that generates book data for Minecraft's written books. The previous implementation didn't break the pages as expected, resulting in pages with needless empty lines at the end of the page. It also couldn't deal that well with certain escape characters. This revised function deals with these shortcomings, inspired by the algorithm used by this Kotlin project: https://github.com/NightlyNexus/Gutencraft/blob/master/gutencraft/src/commonMain/kotlin/Gutencraft.kt
To test, create a Python file containing the following: