Socket
Book a DemoInstallSign in
Socket

github.com/opd-ai/bookie

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/opd-ai/bookie

v0.0.0-20241231151724-f92d22435b8c
Source
Go
Version published
Created
Source

Bookie

Bookie is a powerful Go library for converting markdown documents into professionally formatted PDF books with support for chapters, table of contents, and rich formatting. It's designed to help authors and technical writers create publication-ready documents from markdown content.

Features

  • Chapter Organization

    • Automatic chapter discovery and numbering
    • Support for episode-based content structure
    • Flexible markdown file organization
  • Rich Content Support

    • Full markdown syntax support including tables
    • Image handling with automatic scaling
    • Code blocks with syntax highlighting
    • Nested lists (ordered and unordered)
    • Blockquotes and horizontal rules
  • Professional PDF Output

    • Automatic table of contents generation
    • Configurable page numbering
    • Consistent typography and spacing
    • A4 page format with customizable margins
    • Header and footer support
  • Advanced Formatting

    • Custom font styles and sizes
    • Table support with header styling
    • Flexible text alignment options
    • Link highlighting
    • Image captions

Installation

go get github.com/opd-ai/bookie

Requires Go 1.21.3 or later.

Usage

Basic Example

package main

import "github.com/opd-ai/bookie"

func main() {
    // Create a new book compiler
    compiler := bookie.NewBookCompiler(
        "path/to/markdown/files",  // Root directory containing chapters
        "output.pdf",             // Output PDF path
    )

    // Compile the book
    if err := compiler.Compile(); err != nil {
        log.Fatal(err)
    }
}

Directory Structure

Organize your markdown files in episode-based chapters:

root/
  ├── Episode01/
  │   ├── content.md
  │   └── images/
  ├── Episode02/
  │   ├── intro.md
  │   └── details.md
  └── Episode03/
      └── final.md

Configuration

Configure the book compiler with these options:

compiler.SetPageNumbers(true)           // Enable/disable page numbers
compiler.SetToCTitle("Table of Contents") // Custom ToC title

// Font settings are configurable
compiler.SetChapterFont("Arial")
compiler.SetTextFont("Times")

Default Settings

  • Page Size: A4 (210x297mm)
  • Margins: 20mm
  • Chapter Font: Arial
  • Body Text Font: Times
  • Default Line Height: 5mm

Contributing

  • Fork the repository
  • Create your feature branch (git checkout -b feature/amazing-feature)
  • Run tests (go test ./...)
  • Commit your changes (git commit -m 'Add amazing feature')
  • Push to the branch (git push origin feature/amazing-feature)
  • Open a Pull Request

Code Style

  • Follow standard Go formatting guidelines
  • Include comprehensive comments
  • Add tests for new functionality
  • Update documentation when needed

Testing

Run the test suite:

go test -v ./...

Ensure all tests pass before submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Built with these excellent libraries:

  • gofpdf - PDF generation
  • blackfriday/v2 - Markdown processing
  • golang.org/x/net - HTML processing

Documentation

For detailed API documentation, visit the Go package documentation.

For more examples and detailed usage, see the Wiki.

Support the Project

If you find this project useful, consider supporting the developer:

Monero Address: 43H3Uqnc9rfEsJjUXZYmam45MbtWmREFSANAWY5hijY4aht8cqYaT2BCNhfBhua5XwNdx9Tb6BEdt4tjUHJDwNW5H7mTiwe Bitcoin Address: bc1qew5kx0srtp8c4hlpw8ax0gllhnpsnp9ylthpas

FAQs

Package last updated on 31 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.