Skip to content

v0.1.6

Latest

Choose a tag to compare

@amitdevx amitdevx released this 29 Jun 13:36

Release Notes - v0.1.6

major resilience, validation, and transparency release resulting from an exhaustive live system audit. It addresses critical option handling, strict input validation, edge-case crashes, and CI pipeline reliability.

Features & Enhancements

  • Strict Paper Validation: Added strict runtime validation for --paper against A4, Letter, and Legal, cleanly rejecting unsupported inputs with exit code 1 instead of silently delegating invalid formats to Playwright.
  • Robust Margin Validation: Implemented comprehensive regex validation for all valid CSS units (mm, cm, in, px, pt, pc, em, rem, %), completely eliminating raw internal Playwright stack traces on invalid margin inputs.
  • Explicit .md Extension Guard: Added an explicit check for .md extensions prior to same-file evaluation. Passing .txt files or binary files now safely halts with exit code 2 and a helpful usage message.
  • Clear stdin Guard: Explicitly intercepts pipe (-) attempts with a clean stdin input is not supported message.
  • Engine Transparency & UX Warnings: Notifies the user via clean terminal warnings before automatically generating new parent directory trees (console.warn) and alerts the user when an existing PDF is about to be overwritten.
  • Absolute Paths on Success: Replaced ambiguous relative paths with fully resolved absolute paths in success messages, eliminating confusion when invoking from deep subdirectories.
  • Predictable Page Breaks: Changed the default h1NewPage behavior to false to prevent unexpected pagination breaks, and exposed an explicit --h1-new-page CLI flag.
  • Full CLI E2E Test Suite: Added tests/cli/index.test.ts covering 11 distinct success, error, and flag validation paths.

Bug Fixes

  • Flawless Installation Feedback: Bypassed npm postinstall output suppression by explicitly streaming directly to process.stderr.write. Installing globally (npm install -g @amitdevx/md2pdf) now clearly broadcasts md2pdf: Checking Chromium browser... and provides immediate confirmation when ready: md2pdf is ready! Run: md2pdf <file.md>.
  • EACCES Permission Handling: When encountering read-protected files (chmod 000), the CLI intercepts the EACCES code and outputs actionable permission guidance (chmod 644 <file>) with exit code 2.
  • Trailing Slash Guard: Passing a directory path with a trailing slash (e.g., -o /tmp/) is cleanly rejected, preventing the accidental creation of hidden dotfiles (/tmp/.pdf).
  • YAMLException Multiline Parsing: Corrected the regex split escape from \\n to \n, ensuring the CLI prints only the clean first line of YAML syntax errors.
  • Nested Table of Contents & pruneEmpty Fix: Refactored the TOC AST generator to emit a true, semantically nested <ul> tree rather than a flat list with CSS padding hacks. Also resolved a subtle runtime crash where pruneEmpty attempted to filter child text nodes inside anchor elements.
  • CI Workflow Order Fix: Fixed a GitHub Actions CI failure by running npm run build prior to npm run test, ensuring the compiled CLI binary is available for Vitest end-to-end tests in pristine runner environments.

Full Changelog: v0.1.5...v0.1.6