Skip to content

translaster/the-ansible-workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š Write-Book-Template

This repository is a ready-to-use template for efficiently writing, organizing, and publishing books with modern tooling. It includes a structured directory layout, powerful automation scripts, and full integration with Poetry via a pyproject.toml configuration.

Authors can easily create, format, and export books in multiple formats like PDF, EPUB, MOBI, and DOCX.


✨ Features

  • πŸ“‚ Structured Directory: Predefined folders for chapters, front matter, back matter, and assets
  • πŸ“ Markdown-Based Writing: Compose in Markdown for clarity and compatibility
  • πŸ”„ Automated Conversion: Generate multiple output formats via Pandoc
  • πŸ“œ Dynamic Table of Contents: Keep your structure organized and current
  • πŸ“‘ Metadata Automation: Easily inject book metadata with a script
  • πŸš€ Git Integration: Seamless GitHub usage for versioning and collaboration
  • 🧰 Poetry Integration: Dependency and script management powered by Poetry

🚦 Getting Started

1️⃣ Create Your Book Repository from this Template

  • Click on the green Use this template button at the top of this repository page.
  • Choose Create a new repository and name your book project.
  • Clone it locally:
git clone https://github.com/YOUR_USERNAME/YOUR_BOOK_REPO.git
cd YOUR_BOOK_REPO

2️⃣ Initialize Project Structure

⚠️ Note: The shell script scripts/create_project_structure.sh is now deprecated and will be removed in the future.
βœ… Please use the Python script with Poetry integration instead.

Run the following command to create the complete folder structure and all required files:

poetry run init-book-project

This will:

  • Create all necessary folders (manuscript/, config/, assets/, output/, etc.)

  • Generate chapter and front/back matter files

  • Create metadata.yaml and metadata_values.json with placeholders

  • Add a template for image generation prompts (scripts/data/image_project_config.json)

  • Prepare the project for exporting and translation

πŸ“˜ Full guide available here:
πŸ‘‰ πŸ“¦ Project Initialization – Wiki


βš™οΈ Poetry-Based Setup

This project is configured with Poetry. To install dependencies and use the automation scripts:

poetry install

Available scripts (defined in pyproject.toml):

  • poetry run update-metadata-values – injects structured metadata into your YAML file
  • poetry run full-export – exports your book to multiple formats
  • poetry run print-version-build – prints current version/build info

3️⃣ Automate Metadata Population

Replace placeholders in config/metadata.yaml using this command:

poetry run update-metadata-values

This method ensures your virtual environment is used correctly and dependencies are managed by Poetry.


What the script does:

  • Loads metadata values from config/metadata_values.json
  • Replaces all placeholders like {{BOOK_TITLE}} in metadata.yaml with actual content
  • Properly formats lists such as KEYWORDS and OUTPUT_FORMATS to YAML list syntax
  • Automatically deletes the metadata_values.json file after successful population
  • Logs success and error messages to the console

πŸ“˜ Learn how this works in detail in the Medium article

4️⃣ Example Metadata Structure

After running the Python script, metadata.yaml will look like this:

title: "Your Book Title"
subtitle: "A short subtitle describing your book"
author: "Your Name"
isbn: "Your ISBN Number"
edition: "Your Edition (e.g., 1st Edition, 2nd Edition)"
publisher: "Your Publisher Name"
date: "YYYY-MM-DD"
language: "en"
description: "Provide a detailed description of your book."
keywords:
  - "AI"
  - "machine learning"
  - "automation"
cover_image: "assets/covers/cover.jpg"
output_formats:
  - "pdf"
  - "epub"
  - "mobi"
kdp_enabled: true

5️⃣ Convert the Book to PDF/EPUB/MOBI

Once your book is written, export it:

poetry run full-export

The generated files will be available in the output/ folder.


7️⃣ Push to GitHub

Commit and push your changes manually to GitHub:

git add .
git commit -m "Add new content or update chapters"
git push

✍️ Start Writing

  • Add chapters in manuscript/chapters/
  • Edit manuscript/front-matter/toc.md for your table of contents
  • Add illustrations or diagrams under assets/

πŸ“– Documentation

The full documentation is available in the Wiki.
Here are the main sections to get you started:

🏁 Getting Started

✏️ Writing Tools

🌐 Translation

πŸ“€ Exporting Your Book

⚑ Project Shortcuts


πŸ“ Directory Structure

write-book-template/
│── manuscript/
β”‚   β”œβ”€β”€ chapters/
β”‚   β”‚   β”œβ”€β”€ 01-introduction.md
β”‚   β”‚   β”œβ”€β”€ 02-chapter.md
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”œβ”€β”€ front-matter/
β”‚   β”‚   β”œβ”€β”€ toc.md
β”‚   β”‚   β”œβ”€β”€ preface.md
β”‚   β”‚   β”œβ”€β”€ foreword.md
β”‚   β”‚   β”œβ”€β”€ acknowledgments.md
β”‚   β”œβ”€β”€ back-matter/
β”‚   β”‚   β”œβ”€β”€ about-the-author.md
β”‚   β”‚   β”œβ”€β”€ appendix.md
β”‚   β”‚   β”œβ”€β”€ bibliography.md
β”‚   β”‚   β”œβ”€β”€ faq.md
β”‚   β”‚   β”œβ”€β”€ glossary.md
β”‚   β”‚   β”œβ”€β”€ index.md
β”‚   β”œβ”€β”€ figures/
β”‚   β”‚   β”œβ”€β”€ fig1.png
β”‚   β”‚   β”œβ”€β”€ fig2.svg
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”œβ”€β”€ tables/
β”‚   β”‚   β”œβ”€β”€ table1.csv
β”‚   β”‚   β”œβ”€β”€ table2.csv
β”‚   β”‚   β”œβ”€β”€ ...
β”‚   β”œβ”€β”€ references.bib  # If using citations (e.g., BibTeX, APA, MLA formats supported)
│── assets/ # Images, media, illustrations (for book content, cover design, and figures)
β”‚   β”œβ”€β”€ covers/
β”‚   β”‚   β”œβ”€β”€ cover-design.png
β”‚   β”œβ”€β”€ figures/
β”‚   β”‚   β”œβ”€β”€ diagrams/
β”‚   β”‚   β”œβ”€β”€ infographics/
│── config/ # Project configuration (metadata, styling, and optional Pandoc settings)
β”‚   β”œβ”€β”€ metadata.yaml   # Title, author, ISBN, etc. (used for all formats: PDF, EPUB, MOBI)
β”‚   β”œβ”€β”€ styles.css      # Custom styles for PDF/eBook
β”‚   β”œβ”€β”€ template.tex    # LaTeX template (if needed)
│── output/             # Compiled book formats
β”‚   β”œβ”€β”€ book.pdf
β”‚   β”œβ”€β”€ book.epub
β”‚   β”œβ”€β”€ book.mobi
β”‚   β”œβ”€β”€ book.docx
│── scripts/ # Scripts and tools (initialize project, convert book, update metadata, and export formats)
β”‚   β”œβ”€β”€ convert_book.sh                # Converts Markdown to multiple formats
β”‚   β”œβ”€β”€ convert_img_tags.sh            # Converts the paths of the img tags
β”‚   β”œβ”€β”€ convert_to_absolute.sh         # Converts the relative paths to absolute paths of the md images
β”‚   β”œβ”€β”€ convert_to_relative.sh         # Converts back the absolute paths to relative paths of the md images
β”‚   β”œβ”€β”€ create_project_structure.sh    # Initializes project structure
β”‚   β”œβ”€β”€ full_export_book.py            # Exports book to all publishing formats with backup
β”‚   β”œβ”€β”€ metadata_values_example.json   # example metadata values json file
β”‚   β”œβ”€β”€ update_metadata_values.py      # Automates metadata population
│── LICENSE                                   # If open-source
│── pyproject.toml                            # Configuration file for poetry
│── README.md                                 # Project description

🎨 Customization

  • Metadata: Modify config/metadata.yaml to personalize your book details (title, author, etc.)
  • Styles: Edit config/styles.css to tailor your book’s appearance and formatting.
  • Scripts: Customize conversion settings and output options as needed.

πŸ›  Requirements

  • Poetry (for managing this Python project)
  • Python 3.x (for advanced automation with full_export_book.py)
  • Pandoc for manuscript conversion.
  • Calibre specifically for MOBI conversions.
  • GitHub CLI (gh) for managing repositories (optional but recommended).

⚠️ Troubleshooting

Refer to Full Export Documentation for detailed error handling and solutions regarding export scripts.


🀝 Contributing

Found a bug or want to contribute? Pull requests and suggestions are welcome!


πŸ“„ License

Released under the MIT License. Please see the LICENSE file for details.


πŸš€ Happy writing! Start your book today!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages