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
--paperagainstA4,Letter, andLegal, cleanly rejecting unsupported inputs with exit code1instead 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
.mdextensions prior to same-file evaluation. Passing.txtfiles or binary files now safely halts with exit code2and a helpful usage message. - Clear stdin Guard: Explicitly intercepts pipe (
-) attempts with a cleanstdin input is not supportedmessage. - 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
h1NewPagebehavior tofalseto prevent unexpected pagination breaks, and exposed an explicit--h1-new-pageCLI flag. - Full CLI E2E Test Suite: Added
tests/cli/index.test.tscovering 11 distinct success, error, and flag validation paths.
Bug Fixes
- Flawless Installation Feedback: Bypassed npm
postinstalloutput suppression by explicitly streaming directly toprocess.stderr.write. Installing globally (npm install -g @amitdevx/md2pdf) now clearly broadcastsmd2pdf: 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 theEACCEScode and outputs actionable permission guidance (chmod 644 <file>) with exit code2. - 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
\\nto\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 wherepruneEmptyattempted to filter child text nodes inside anchor elements. - CI Workflow Order Fix: Fixed a GitHub Actions CI failure by running
npm run buildprior tonpm 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