Skip to content

Commit 9a25c34

Browse files
fix: resolve formatting issues, maintainer workflows and build size (#4)
* fix: resolve formatting issues, maintainer workflows and build size - Fix double blank lines (MD012) by removing ensureTrailingBlankLine() from block elements - Fix spaces in link text (MD039) by trimming leading/trailing whitespace - Fix reference link spacing in markdown output - Add high-frequency maintenance scripts for QA and regression testing - Consolidate documentation by merging MAINTAINERS.md into CONTRIBUTING.md - Streamline README.md development section for clarity - Move packages from `dependencies` to `devDependencies` These changes improve markdown output quality (85% fewer linting issues vs competitors), reduce package size by 82%, and provide maintainers with workflows for validation and testing. * chore: update changesets * fix(ci): reorder node setup jobs for regression tests * fix(build): sync lockfile * fix(ci): do not fail with external libraries regressions * fix(biome): expand scope to `bench/` files
1 parent 4e80ece commit 9a25c34

27 files changed

Lines changed: 6453 additions & 1040 deletions

.changeset/clever-zoos-judge.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
"h2m-parser": minor
3+
---
4+
5+
Optimize package size and update Node.js requirements
6+
7+
- Reduce npm package size by 82% (570KB → 103KB) by excluding source maps and enabling minification
8+
- Remove unused `turndown` dependency, moving it to devDependencies for benchmarks only
9+
- Update Node.js requirement to >=22 and test matrix to Node 22 and 24
10+
- Fix tsup config TypeScript error in esbuildOptions
11+
- Update all GitHub Actions workflows to use Node.js 24
12+
- Configure package.json to exclude source maps from published package
13+
- Enable minification in production builds while keeping it disabled for watch mode
14+
15+
These changes improve installation speed and reduce disk usage for end users while
16+
maintaining full functionality.

.github/workflows/performance-regression.yml

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,26 @@ jobs:
1717
regression:
1818
if: github.event_name == 'pull_request'
1919
runs-on: ubuntu-latest
20+
permissions:
21+
pull-requests: write
22+
issues: write
2023

2124
steps:
2225
- name: Checkout repository
2326
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2427
with:
2528
persist-credentials: false
2629

27-
- name: Setup Node.js
28-
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
29-
with:
30-
node-version: '24'
31-
32-
- name: Enable Corepack
33-
run: corepack enable
34-
3530
- name: Setup pnpm
3631
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
3732
with:
3833
run_install: false
3934

35+
- name: Setup Node.js
36+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
37+
with:
38+
node-version: '24'
39+
4040
- name: Install dependencies
4141
run: pnpm install --frozen-lockfile
4242

@@ -66,7 +66,7 @@ jobs:
6666
if-no-files-found: ignore
6767

6868
- name: Comment PR with results
69-
if: always()
69+
if: always() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
7070
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
7171
with:
7272
script: |
@@ -129,19 +129,16 @@ jobs:
129129
fetch-depth: 0
130130
persist-credentials: false
131131

132-
- name: Setup Node.js
133-
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
134-
with:
135-
node-version: '24'
136-
137-
- name: Enable Corepack
138-
run: corepack enable
139-
140132
- name: Setup pnpm
141133
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
142134
with:
143135
run_install: false
144136

137+
- name: Setup Node.js
138+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
139+
with:
140+
node-version: '24'
141+
145142
- name: Install dependencies
146143
run: pnpm install --frozen-lockfile
147144

.markdownlint.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"default": true,
3+
"MD013": false,
4+
"MD033": false,
5+
"MD041": false,
6+
"MD024": {
7+
"siblings_only": true
8+
},
9+
"MD026": {
10+
"punctuation": ".,;:!"
11+
},
12+
"MD029": {
13+
"style": "ordered"
14+
},
15+
"MD036": false,
16+
"MD045": false
17+
}

CONTRIBUTING.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,167 @@ Open GitHub issues with:
3838
- Does new configuration default to sensible values to minimize user surprise?
3939

4040
Thanks for helping keep h2m-parser simple and reliable!
41+
42+
## Maintainer Scripts
43+
44+
### High-Frequency Commands
45+
46+
```bash
47+
# Quick quality checks (10 seconds)
48+
pnpm qa:quick
49+
50+
# Full regression test (30 seconds)
51+
pnpm regression
52+
53+
# Complete QA with validation (2-3 minutes)
54+
pnpm qa
55+
56+
# Development watch mode
57+
pnpm build:watch # Terminal 1
58+
pnpm test:watch # Terminal 2
59+
```
60+
61+
### Script Reference
62+
63+
#### Quality Assurance
64+
65+
| Script | Purpose | Duration | When to Use |
66+
|--------|---------|----------|-------------|
67+
| `pnpm qa:quick` | Quick validation: lint, types, tests, export | ~10s | Before commits |
68+
| `pnpm qa` | Full QA with markdown validation | ~2-3min | Before PRs |
69+
| `pnpm regression` | Basic regression test | ~30s | After changes |
70+
| `pnpm regression:full` | Complete regression suite | ~1-2min | Before releases |
71+
72+
#### Benchmarking
73+
74+
| Script | Purpose | Duration | When to Use |
75+
|--------|---------|----------|-------------|
76+
| `pnpm bench:quick` | Quick performance check | ~5s | During development |
77+
| `pnpm bench:compare:quick` | Fast comparison with competitors | ~10s | After optimizations |
78+
| `pnpm bench:compare` | Full comparison benchmark | ~2min | Before releases |
79+
| `pnpm bench:profile` | Detailed performance profiling | ~30s | Performance debugging |
80+
| `pnpm bench:analyze` | Pipeline analysis | ~30s | Optimization work |
81+
82+
#### Output Generation
83+
84+
| Script | Purpose | Duration | When to Use |
85+
|--------|---------|----------|-------------|
86+
| `pnpm bench:export` | Generate markdown outputs | ~5s | Testing conversions |
87+
| `pnpm bench:export:validate` | Export + validate with markdownlint | ~10s | Quality checks |
88+
| `pnpm bench:readme:generate` | Generate all benchmark reports | ~3min | Before releases |
89+
90+
### Typical Workflows
91+
92+
#### Making Changes
93+
94+
```bash
95+
# Start development
96+
pnpm build:watch # In terminal 1
97+
pnpm test:watch # In terminal 2
98+
99+
# After making changes
100+
pnpm qa:quick # Quick validation
101+
pnpm bench:export # Check output quality
102+
```
103+
104+
#### Before Committing
105+
106+
```bash
107+
# Standard pre-commit check
108+
pnpm regression
109+
110+
# Or if you want to be thorough
111+
pnpm qa
112+
```
113+
114+
#### Performance Work
115+
116+
```bash
117+
# Before optimization
118+
pnpm bench:compare:quick > before.txt
119+
120+
# After optimization
121+
pnpm bench:compare:quick > after.txt
122+
123+
# Detailed analysis
124+
pnpm bench:profile
125+
pnpm bench:analyze
126+
```
127+
128+
#### Release Preparation
129+
130+
```bash
131+
# Full validation
132+
pnpm regression:full
133+
134+
# Generate all reports
135+
pnpm bench:readme:generate
136+
137+
# Update changelog
138+
pnpm changeset
139+
140+
# Release
141+
pnpm release
142+
```
143+
144+
## Output Validation
145+
146+
The `bench/output/` directory contains markdown outputs from different converters:
147+
148+
- `bench/output/h2m-parser/` - Our outputs
149+
- `bench/output/turndown/` - Turndown outputs
150+
- `bench/output/node-html-markdown/` - node-html-markdown outputs
151+
152+
To validate output quality:
153+
154+
```bash
155+
# Generate fresh outputs and validate
156+
pnpm bench:export:validate
157+
158+
# Check specific issues
159+
npx markdownlint bench/output/h2m-parser/*.md
160+
161+
# Compare with competitors
162+
npx markdownlint bench/output/*/*.md 2>&1 | grep -c "^bench"
163+
```
164+
165+
## Performance Baselines
166+
167+
Current performance targets (from benchmarks):
168+
169+
- **Without Readability**: ~1-3ms for typical web pages
170+
- **With Readability**: ~5-10ms for typical web pages
171+
- **vs Turndown**: Should be within 1-2x
172+
- **vs node-html-markdown**: Should be competitive or faster
173+
174+
## Troubleshooting
175+
176+
### Tests Failing
177+
178+
```bash
179+
# Run specific test
180+
pnpm test -- htmlparser2-default-tags.test.ts
181+
182+
# Update snapshots if needed
183+
pnpm test -- -u
184+
```
185+
186+
### Performance Regression
187+
188+
```bash
189+
# Quick comparison
190+
pnpm bench:compare:quick
191+
192+
# Detailed profiling
193+
node --expose-gc bench/profile.js --memory
194+
```
195+
196+
### Markdown Quality Issues
197+
198+
```bash
199+
# Check specific file
200+
npx markdownlint bench/output/h2m-parser/[filename].md
201+
202+
# See all issues
203+
pnpm bench:export:validate
204+
```

README.md

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ Estimated processing times for different file sizes (without Readability):
154154

155155
Sample results showing performance across different file types and sizes:
156156

157-
158157
#### tiny (18 bytes)
159158

160159
| Library | Mean (ms) | P95 (ms) | P99 (ms) |
@@ -248,37 +247,21 @@ pnpm bench:readme
248247

249248
<!-- BENCHMARK:END -->
250249

251-
## Tooling & scripts
252-
253-
| Command | Description |
254-
|---------|-------------|
255-
| `pnpm verify` | Run lint → typecheck → tests in one go. |
256-
| `pnpm bench` | Interactive benchmark runner (profiles, comparisons, regression tools). |
257-
| `node bench/capture-baseline.js` | Snapshot current performance metrics for future comparisons. |
258-
| `node bench/check-regression.js --exit-on-regression` | Compare against the stored baseline and fail on regressions. |
259-
| `pnpm export:markdown` | Dump Markdown outputs for h2m-parser, Turndown, and node-html-markdown. |
260-
| `pnpm changeset` / `pnpm release` | Prepare and publish releases. |
261-
262-
More detail lives in [`docs/SCRIPTS.md`](docs/SCRIPTS.md).
263-
264250
## Development
265251

266252
```bash
267253
pnpm install
268254
pnpm verify
269255
```
270256

271-
- `pnpm build` – tsup bundles (CJS+ESM+types).
272-
- `pnpm test` / `pnpm test:watch` – Vitest suites.
273-
- `pnpm lint` / `pnpm lint:fix` – Biome checks.
274-
- `pnpm typecheck``tsc --noEmit`.
275-
- `pnpm bench:quick` – sanity benchmark (25 files max).
276-
277-
See [`docs/PERFORMANCE-REGRESSION.md`](docs/PERFORMANCE-REGRESSION.md) for the baseline/CI story, and [`docs/API.md`](docs/API.md) for generated API notes.
278-
279257
## Contributing
280258

281-
We welcome improvements! Start with [CONTRIBUTING.md](CONTRIBUTING.md) for coding standards, commit conventions, and release flow.
259+
We welcome improvements! See [CONTRIBUTING.md](CONTRIBUTING.md) for:
260+
261+
- Development setup and coding standards
262+
- Commit conventions and release workflow
263+
- Maintainer scripts and workflows
264+
- Performance baselines and troubleshooting
282265

283266
## License
284267

0 commit comments

Comments
 (0)