Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alf

Your personal CLI butler.

Install

cd alf/
npm install
npm link

Commands

alf html2pdf — HTML to PDF

Convert any HTML file to PDF with styles preserved and links clickable.

alf html2pdf --input resume.html --output resume.pdf
Option Short Description
--input -i Input HTML file
--output -o Output PDF file

The underlying Playwright/Chromium waits for web fonts and JavaScript-rendered content (e.g. FontAwesome icons) to settle before printing. CSS @media print rules are honoured, and the PDF is tagged so hyperlinks remain clickable.

alf md2pdf — Markdown to PDF

Convert a Markdown file (with YAML front matter) to PDF in one step.

alf md2pdf --md cv.md --pdf cv.pdf
Option Short Description
--md -m Input Markdown file
--pdf -p Output PDF file

The YAML front matter declares CSS/JS assets and extra header tags:

---
title: "My Resume"
output:
  html:
    meta:
      css: ["static/default.css", "static/font.css"]
      js: ["js/default.js"]
      header-includes: '<script src="https://kit.fontawesome.com/xxx.js" crossorigin="anonymous"></script>'
---

CSS @import URLs (e.g. Google Fonts) are automatically downloaded and inlined as base64 data URIs, so the intermediate HTML is fully self-contained. Pandoc fenced Divs (::::: {#id .class}) are supported in the Markdown.

Project structure

alf/
├── bin/
│   └── alf.mjs             # CLI entry point
├── src/
│   ├── cli.mjs             # Commander setup, command registration
│   ├── commands/
│   │   ├── html2pdf.mjs    # alf html2pdf
│   │   └── md2pdf.mjs      # alf md2pdf
│   └── lib/
│       ├── browser.mjs     # Playwright PDF rendering
│       └── markdown.mjs    # Markdown parsing & CSS inlining
└── package.json

Adding a new command

  1. Create src/commands/<name>.mjs exporting a function that returns a Command:

    import { Command } from 'commander';
    export function myCommand() {
      return new Command('mycmd')
        .description('Does something useful')
        .action(() => { /* ... */ });
    }
  2. Register it in src/cli.mjs:

    import { myCommand } from './commands/mycmd.mjs';
    program.addCommand(myCommand());

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages