You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

github.com/warky-devs/go-mdtopdf-helper

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/warky-devs/go-mdtopdf-helper

v1.0.0
Source
Go
Version published
Created
Source

go-mdtopdf-helper

A command-line tool that automatically converts Markdown files to PDF using wkhtmltopdf. Perfect for maintaining PDF documentation alongside your Markdown files in Git repositories.

Features

  • Converts Markdown files to high-quality PDFs
  • Can run as a Git pre-commit hook
  • Recursive directory scanning
  • Parallel file processing
  • Cross-platform support (Windows, Linux, macOS)
  • Automatic detection of wkhtmltopdf installation

Prerequisites

This tool requires wkhtmltopdf to be installed on your system. The application will check for its presence in standard installation locations:

  • Windows: C:\Program Files\wkhtmltopdf\bin
  • Linux: /usr/local/bin/wkhtmltopdf or /usr/bin/wkhtmltopdf
  • macOS: /usr/local/bin/wkhtmltopdf or via Homebrew

If wkhtmltopdf is not found, you will be prompted to install it.

Installation

go get github.com/Warky-Devs/go-mdtopdf-helper

Usage

Basic Usage

Convert Markdown files in the current directory:

go-mdtopdf-helper

Command Line Options

go-mdtopdf-helper [options]

Options:
  -dir string
        Directory to scan for markdown files (default ".")
  -recursive
        Scan directories recursively (default true)
  -parallel
        Convert files in parallel (default true)
  -hook
        Run as git pre-commit hook

Git Pre-commit Hook

To use as a Git pre-commit hook:

  • Create a file named pre-commit in your repository's .git/hooks/ directory
  • Add the following content:
#!/bin/sh
go-mdtopdf-helper -hook
  • Make the hook executable:
chmod +x .git/hooks/pre-commit

When enabled as a pre-commit hook, the tool will:

  • Detect staged Markdown files
  • Ask for confirmation before conversion
  • Convert files to PDF
  • Automatically stage the generated PDFs

PDF Output Configuration

The generated PDFs are configured with:

  • 300 DPI resolution
  • 15mm margins on all sides
  • Local file access enabled for images
  • Support for common Markdown extensions

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. Here's how you can contribute:

  • Fork the repository
  • Create your feature branch (git checkout -b feature/AmazingFeature)
  • Commit your changes (git commit -m 'Add some AmazingFeature')
  • Push to the branch (git push origin feature/AmazingFeature)
  • Open a Pull Request

Development Setup

  • Clone the repository
  • Install dependencies:
    go mod download
    
  • Make your changes
  • Run tests:
    go test ./...
    

Dependencies

License

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

Acknowledgments

  • Thanks to SebastiaanKlippert for the go-wkhtmltopdf library
  • Thanks to the gomarkdown team for their Markdown parser

FAQs

Package last updated on 07 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.