Skip to content
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

Feature request: specify output filename #21

Closed
sowbug opened this issue May 8, 2023 · 2 comments
Closed

Feature request: specify output filename #21

sowbug opened this issue May 8, 2023 · 2 comments

Comments

@sowbug
Copy link

sowbug commented May 8, 2023

I'd really appreciate it if we could set a setting to substitute the book's title for the filename instead of output.pdf. It looks like it's hardcoded at https://github.com/HollowMan6/mdbook-pdf/blob/main/src/main.rs#L224, which suggests that it would be a new feature rather than an option that I haven't been able to find. Thank you.

@HollowMan6
Copy link
Owner

Hi! Thank you for proposing this issue, but unfortunately, I won't implement this because of the following reasons:

  1. In mdbook-pdf-outline, we actually rely on the output.pdf naming to get the generated pdf by mdbook-pdf. https://github.com/HollowMan6/mdbook-pdf/blob/main/mdbook_pdf_outline/mdbook_pdf_outline.py#L137
    We won't know exactly where it is unless you configure the name of the generated pdf in book.toml twice for each backend, which is a bad idea for consistency.
  2. There are a lot of special characters that are not allowed in a filename, and different OS can have different rules, it's not worth spending time on implementing and testing these rules.
  3. Most importantly, you can easily rename it using any postscript, and you can even have such postscript right in your book.toml: https://rust-lang.github.io/mdBook/format/configuration/renderers.html#custom-backend-commands
[output.html]

[output.pdf]

[output.pdf-outline]

[output.pdf-rename]
command = "mv ../pdf-outline/output.pdf ../pdf-outline/something-you-like.pdf"

I'm closing this issue now. If you do have some special use cases for renaming, please tell me and try to submit a PR yourself to suit both your need and the blockers I mentioned above.

@HollowMan6 HollowMan6 closed this as not planned Won't fix, can't repro, duplicate, stale May 8, 2023
@sowbug
Copy link
Author

sowbug commented May 8, 2023

Thanks. I see why it's more complicated than expected. I didn't know about the custom backend commands -- thank you for turning me on to it. I'll write a shell script that runs mdbook build and does the rename.

(My use case is a family recipe book that we update every couple months. It's nice to update the title and filename with a version number, and to do so in just one place in the source.)

@HollowMan6 HollowMan6 pinned this issue May 9, 2023
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

No branches or pull requests

2 participants