diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 62cd73d..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,27 +0,0 @@ -This document is directed at all llm interactions. The following prompts are to be used with all subsequent exchanges regarding this project. - -- Before responding, I want to establish some ground rules. Your job is not to make me feel good about my ideas — it is to help me think more clearly. Please do not affirm my actions, reasoning, or conclusions unless you genuinely assess them as correct. If you think I am wrong, mistaken, or have a blind spot, say so directly. Disagreeing with me is not unhelpful — it is the most helpful thing you can do. - -- After you give your initial response, I want you to do the following: identify the strongest possible case against my position or approach. Assume a thoughtful critic who disagrees with me — what would they say? Do not soften this. Treat it as a genuine counterargument, not a token caveat. - -- I'm going to describe [my hypothesis / plan / analysis]. Do not evaluate whether it is good. Instead, assume it has already failed or been proven wrong. Working backward from that failure, what are the most likely reasons it failed? What did I miss, overweight, or assume incorrectly? - -- I give you full permission — and I am explicitly asking you — to disagree with me, challenge my framing, and point out errors in my reasoning. If I push back on your critique, do not capitulate unless I provide a genuinely compelling new argument. Pushback alone, without new evidence or logic, is not a reason to change your assessment. - -- Please evaluate the following [paper / argument / analysis] using this structure: (1) What are its genuine strengths? (2) What are its significant weaknesses or gaps? (3) What assumptions does it rely on that may not hold? (4) What would a rigorous peer reviewer likely object to? Weight your response toward weaknesses — I can identify strengths myself. - -- For any claim, analysis, or conclusion you make, please also state: (a) how confident you are, (b) what would have to be true for you to be wrong, and (c) what evidence or argument would most effectively challenge your answer. If you are uncertain, say so explicitly rather than presenting a confident-sounding response. - -- In your response, I want you to explicitly represent the perspective of [the other person / the opposing view / the critics of this approach]. Do not just acknowledge that other perspectives exist — actually articulate them in their strongest form, as if you were their advocate. - -- Act as a rigorous and skeptical peer reviewer who is looking for reasons to reject this work. Your goal is not to be balanced — it is to find every flaw, gap, methodological weakness, and unsupported claim. Be thorough and unsparing. I will use your critique to strengthen the work. - -- I may disagree with your assessment or push back in this conversation. When I do, please re-evaluate only if I present new facts, evidence, or a logical argument you had not considered. If I simply express displeasure or repeat my original view more forcefully, maintain your position and explain why you are doing so. - -- Before we finish: looking back at our conversation, is there anywhere you may have been more agreeable or validating toward my position than the evidence warranted? Are there objections or concerns you softened or omitted? If so, state them now." - -- Under no circumstances change code _without explicit direction to do so._ Do not attempt to guess if I want the code changed, wait until _explicitly_ directed to change code. - -- Do not apologize for mistakes. Acknowledge them, but apologies are not production in our exchanges. - -- Do not prompt for tasks. I will direct you to a task, and do not need to be directed. diff --git a/README.md b/README.md index 1c8c1f6..84c6b6c 100644 --- a/README.md +++ b/README.md @@ -1,93 +1,154 @@ -# merger - - - -## Getting started - -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://gitlab.com/epub3/merger.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://gitlab.com/epub3/merger/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README - -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. +# epubmaker ## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. +A tool that assists in the creation of epub files from html marked source. ## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. + +Requires Python 3.10 or later. + +```bash +git clone +cd epubmaker +pip install . +``` + +For development: + +```bash +pip install -e . +pip install pytest +``` ## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. + +``` +python -m epubmaker [-f] [-v] +``` + +| Argument | Description | +|---|---| +| `source_file` | Path to the HTML source file | +| `-f`, `--force` | Overwrite an existing output directory | +| `-v`, `--verbose` | Print progress as each step completes | + +**Examples:** + +```bash +# Basic usage +python -m epubmaker mybook.html + +# Overwrite a previously generated output +python -m epubmaker -f mybook.html + +# Verbose output +python -m epubmaker -v mybook.html +``` + +The tool creates an output directory and a `.epub` file in the current working directory, both named after the value of the `Directory:` directive in the source file. + +### Source file format + +The source file is an HTML file. Metadata and structure are declared using HTML comment directives. The file must be located in a directory that also contains an `Images/` subdirectory. + +**Required `Images/` contents:** +- `cover.jpeg` — cover image +- `Inconsolata-Regular.otf`, `invisible1.ttf`, `MgOpenModataRegular.ttf` — bundled fonts +- Any additional images referenced in the file + +#### Metadata directives + +These appear before any section directives. All names in `Last, First` format. + +| Directive | Description | +|---|---| +| `` | Output directory name (required) | +| `` | Book title (required) | +| `` | Author; repeat for multiple authors | +| `` | Editor | +| `` | Cover artist | +| `` | Publisher | +| `` | Copyright statement | +| `` | ISBN | +| `` | UUID; leave blank to auto-generate | +| `` | Source work | +| `` | Comma-separated subjects | +| `` | Series index and name | +| `` | Cover image filename | + +#### Section directives + +Each section directive opens a new section. All HTML content that follows — until the next directive — becomes that section's body. The `id` field is used as the output filename (e.g., `ch1` → `ch1.xhtml`). + +``` + +``` + +| Directive | Section type | +|---|---| +| `` | Title page | +| `` | Copyright page | +| `` | Dedication | +| `` | Table of contents | +| `` | Foreword | +| `` | Body chapter | +| `` | Notes | +| `` | Acknowledgements | +| `` | License | + +#### Image directive + +Used within a section to embed an image. Supported formats: `jpg`, `jpeg`, `png`. + +``` + +``` + +The caption is optional. To omit it, leave it blank: + +``` + +``` + +#### Stylesheet + +Link a CSS file using a standard `` tag and the tool will extract and bundle it: + +```html + +``` + +#### Minimal example + +```html + + + + + + + + + +

My Book

+

Jane Smith

+ + + + + +

Chapter One

+

Body text goes here.

+``` ## Support Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. ## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. +Modify this code to use pypub. ## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. +Rory Hinnen ## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +GPL 3.0 diff --git a/src/epubmaker.py b/src/epubmaker.py index e55ef2a..161b7ec 100755 --- a/src/epubmaker.py +++ b/src/epubmaker.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -from epubmaker.cli import main +from epubmaker.main import main if __name__ == "__main__": main() diff --git a/src/epubmaker/__main__.py b/src/epubmaker/__main__.py index 4e28416..5d6a810 100644 --- a/src/epubmaker/__main__.py +++ b/src/epubmaker/__main__.py @@ -1,3 +1,3 @@ -from .cli import main +from .main import main main() diff --git a/src/epubmaker/cli.py b/src/epubmaker/cli.py index bcbafc1..5323015 100644 --- a/src/epubmaker/cli.py +++ b/src/epubmaker/cli.py @@ -1,12 +1,6 @@ import os import argparse -from datetime import datetime from .models import BuildContext -from .parser import parse_book -from .writer import ( - write_structure, write_misc, write_styles, write_ncx, - write_cover, write_contents, write_sections, write_illustrations, write_epub, -) def parse_args(ctx: BuildContext) -> bool: @@ -21,25 +15,3 @@ def parse_args(ctx: BuildContext) -> bool: exit() ctx.verbose = args.verbose return args.force - - -def main() -> None: - ctx = BuildContext() - ctx.book.publish_date = "{}-{}-{}".format( - datetime.now().year, - datetime.now().month, - datetime.now().day, - ) - overwrite = parse_args(ctx) - parse_book(ctx) - if overwrite and ctx.verbose: - print("Force flag, overwriting existing directory") - write_structure(ctx, overwrite) - write_misc(ctx) - write_styles(ctx) - write_ncx(ctx) - write_cover(ctx) - write_contents(ctx) - write_sections(ctx) - write_illustrations(ctx) - write_epub(ctx) diff --git a/src/epubmaker/common/__init__.py b/src/epubmaker/common/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/epubmaker/main.py b/src/epubmaker/main.py new file mode 100644 index 0000000..9b8fdd2 --- /dev/null +++ b/src/epubmaker/main.py @@ -0,0 +1,30 @@ +from datetime import datetime +from .models import BuildContext +from .cli import parse_args +from .parser import parse_book +from .writer import ( + write_structure, write_misc, write_styles, write_ncx, + write_cover, write_contents, write_sections, write_illustrations, write_epub, +) + + +def main() -> None: + ctx = BuildContext() + ctx.book.publish_date = "{}-{}-{}".format( + datetime.now().year, + datetime.now().month, + datetime.now().day, + ) + overwrite = parse_args(ctx) + parse_book(ctx) + if overwrite and ctx.verbose: + print("Force flag, overwriting existing directory") + write_structure(ctx, overwrite) + write_misc(ctx) + write_styles(ctx) + write_ncx(ctx) + write_cover(ctx) + write_contents(ctx) + write_sections(ctx) + write_illustrations(ctx) + write_epub(ctx)