@dkothule/md2pdf 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,20 +18,74 @@ It keeps Mermaid diagrams sharp in PDF by rendering vector assets (SVG by defaul
18
18
  - Configurable defaults (`~/.config/md2pdf/config.env`, project `.md2pdfrc`, or `--config`).
19
19
  - Optional Finder Quick Action integration on macOS.
20
20
 
21
- ## Install
21
+ ## New Machine Bootstrap (No Homebrew or npm)
22
+
23
+ If this is a fresh machine, install package manager/runtime first:
24
+
25
+ macOS:
22
26
 
23
- ### 1) Install system dependencies
27
+ ```bash
28
+ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
29
+ eval "$(/opt/homebrew/bin/brew shellenv)" || eval "$(/usr/local/bin/brew shellenv)"
30
+ brew install node
31
+ ```
24
32
 
25
- From repo checkout, install required tools:
33
+ Debian/Ubuntu:
26
34
 
27
35
  ```bash
28
- ./install-system-deps.sh
36
+ sudo apt-get update
37
+ sudo apt-get install -y nodejs npm
29
38
  ```
30
39
 
31
- ### 2) Install md2pdf CLI
40
+ Then continue with the install steps below.
41
+
42
+ ## Install
43
+
44
+ ### Frictionless install (recommended)
45
+
46
+ Prerequisite: Node.js + npm installed (required to install the npm package).
47
+
48
+ 1) Install md2pdf:
32
49
 
33
50
  ```bash
34
51
  npm i -g @dkothule/md2pdf
52
+ ```
53
+
54
+ 2) Install runtime dependencies (system packages + `pandocfilters`):
55
+
56
+ ```bash
57
+ md2pdf-install-system-deps
58
+ ```
59
+
60
+ Use `--yes` to skip the confirmation prompt (helpful for automation):
61
+
62
+ ```bash
63
+ md2pdf-install-system-deps --yes
64
+ ```
65
+
66
+ 3) Verify:
67
+
68
+ ```bash
69
+ md2pdf --version
70
+ md2pdf --help
71
+ ```
72
+
73
+ `md2pdf-install-system-deps` supports macOS (Homebrew) and Debian/Ubuntu.
74
+ Run `md2pdf-install-system-deps --help` to see options.
75
+
76
+ ### Manual fallback (if helper script does not support your Linux distro)
77
+
78
+ Install these dependencies yourself:
79
+
80
+ - `pandoc`
81
+ - LaTeX PDF engine (`xelatex` default)
82
+ - `librsvg` / `rsvg-convert`
83
+ - `python3` + `pip`
84
+ - `node` + `npm`
85
+
86
+ Then install the Python dependency:
87
+
88
+ ```bash
35
89
  python3 -m pip install pandocfilters
36
90
  ```
37
91
 
@@ -167,7 +221,7 @@ md2pdf ./tests/samples/mermaid-all-diagram-types.md --keep-mermaid-assets
167
221
 
168
222
  ## Keywords
169
223
 
170
- markdown to pdf, md to pdf, mermaid to pdf, mermaid svg, pandoc markdown pdf, markdown pdf cli, macOS markdown pdf, Linux markdown pdf
224
+ markdown to pdf, md to pdf, md2pdf, mermaid to pdf, mermaid svg, pandoc markdown pdf, markdown pdf cli, macOS markdown pdf, Linux markdown pdf
171
225
 
172
226
  ## License
173
227
 
@@ -3,8 +3,99 @@
3
3
  # Copyright (c) 2026 Deepak Kothule
4
4
  set -euo pipefail
5
5
 
6
+ YES=0
6
7
  OS="$(uname -s)"
7
8
 
9
+ usage() {
10
+ cat <<EOF
11
+ Usage: $(basename "$0") [options]
12
+
13
+ Install md2pdf runtime dependencies (system packages + pandocfilters).
14
+
15
+ Options:
16
+ -y, --yes Skip confirmation prompt and proceed immediately
17
+ -h, --help Show this help message
18
+
19
+ Supported platforms:
20
+ - macOS (Homebrew)
21
+ - Debian/Ubuntu Linux (apt)
22
+ EOF
23
+ }
24
+
25
+ parse_args() {
26
+ while [[ $# -gt 0 ]]; do
27
+ case "$1" in
28
+ -y|--yes)
29
+ YES=1
30
+ ;;
31
+ -h|--help)
32
+ usage
33
+ exit 0
34
+ ;;
35
+ *)
36
+ echo "Error: unknown option: $1" >&2
37
+ usage >&2
38
+ exit 1
39
+ ;;
40
+ esac
41
+ shift
42
+ done
43
+ }
44
+
45
+ confirm_install() {
46
+ if [[ "$YES" -eq 1 ]]; then
47
+ return
48
+ fi
49
+
50
+ if [[ ! -t 0 ]]; then
51
+ echo "Non-interactive shell detected. Re-run with --yes to proceed." >&2
52
+ exit 1
53
+ fi
54
+
55
+ echo "This command will install system packages for md2pdf and may prompt for sudo password."
56
+ echo "Detected OS: $OS"
57
+ printf "Continue? [y/N] "
58
+ local response
59
+ read -r response
60
+
61
+ case "${response,,}" in
62
+ y|yes)
63
+ ;;
64
+ *)
65
+ echo "Aborted."
66
+ exit 0
67
+ ;;
68
+ esac
69
+ }
70
+
71
+ has_pandocfilters() {
72
+ python3 - <<'PY' >/dev/null 2>&1
73
+ import pandocfilters
74
+ PY
75
+ }
76
+
77
+ install_python_dependency() {
78
+ if has_pandocfilters; then
79
+ echo "Python dependency already installed: pandocfilters"
80
+ return
81
+ fi
82
+
83
+ echo "Installing Python dependency: pandocfilters"
84
+ if python3 -m pip install --user pandocfilters; then
85
+ return
86
+ fi
87
+
88
+ if python3 -m pip install pandocfilters --break-system-packages; then
89
+ return
90
+ fi
91
+
92
+ echo "Failed to install pandocfilters automatically." >&2
93
+ echo "Please install manually with one of:" >&2
94
+ echo " python3 -m pip install --user pandocfilters" >&2
95
+ echo " python3 -m pip install pandocfilters --break-system-packages" >&2
96
+ exit 1
97
+ }
98
+
8
99
  install_macos() {
9
100
  if ! command -v brew >/dev/null 2>&1; then
10
101
  echo "Homebrew is required on macOS. Install from https://brew.sh and retry."
@@ -12,7 +103,11 @@ install_macos() {
12
103
  fi
13
104
 
14
105
  brew update
15
- brew install pandoc librsvg node python
106
+ brew install pandoc librsvg python
107
+
108
+ if ! command -v node >/dev/null 2>&1 || ! command -v npm >/dev/null 2>&1; then
109
+ brew install node
110
+ fi
16
111
 
17
112
  if ! command -v xelatex >/dev/null 2>&1; then
18
113
  echo "Installing BasicTeX for xelatex..."
@@ -26,14 +121,20 @@ install_debian_ubuntu() {
26
121
  sudo apt-get install -y \
27
122
  pandoc \
28
123
  librsvg2-bin \
29
- nodejs \
30
- npm \
31
124
  python3 \
32
125
  python3-venv \
33
126
  python3-pip \
127
+ python3-pandocfilters \
34
128
  texlive-xetex
129
+
130
+ if ! command -v node >/dev/null 2>&1 || ! command -v npm >/dev/null 2>&1; then
131
+ sudo apt-get install -y nodejs npm
132
+ fi
35
133
  }
36
134
 
135
+ parse_args "$@"
136
+ confirm_install
137
+
37
138
  if [[ "$OS" == "Darwin" ]]; then
38
139
  install_macos
39
140
  elif [[ "$OS" == "Linux" ]]; then
@@ -49,4 +150,6 @@ else
49
150
  exit 1
50
151
  fi
51
152
 
52
- echo "System dependencies installed."
153
+ install_python_dependency
154
+
155
+ echo "Runtime dependencies installed."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dkothule/md2pdf",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Markdown to PDF converter with high-resolution Mermaid diagram rendering",
5
5
  "author": "Deepak Kothule",
6
6
  "license": "MIT",
@@ -44,6 +44,7 @@
44
44
  ],
45
45
  "bin": {
46
46
  "md2pdf": "./bin/md2pdf",
47
+ "md2pdf-install-system-deps": "./install-system-deps.sh",
47
48
  "md2pdf-install-finder-action": "./scripts/install_md2pdf_quick_action.sh",
48
49
  "md2pdf-uninstall-finder-action": "./scripts/uninstall_md2pdf_quick_action.sh"
49
50
  },