Skip to content

Commit 18228f2

Browse files
ECgearclaude
andcommitted
feat: initial release of csv-html-fixer v1.0.0
Interactive, dependency-free CLI that repairs unclosed HTML tags inside CSV cells. Auto-detects encoding (UTF-8/BOM, Shift-JIS) and HTML-bearing cells, applies a minimal stack-based repair (append missing close tags, drop stray close tags, fix mis-nesting), and writes a non-destructive *_fixed.csv while preserving newline style, in-field newlines, quoting and encoding. Includes unit tests, cross-platform CI (Ubuntu/macOS/Windows, Python 3.8-3.12), a Python preflight secret-scan gate, bilingual beginner-friendly README, and standard OSS docs (LICENSE/CHANGELOG/CONTRIBUTING/CODE_OF_CONDUCT/SECURITY). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0 parents  commit 18228f2

18 files changed

Lines changed: 1221 additions & 0 deletions

‎.githooks/pre-commit‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
# Block commits that would introduce secrets or other publish risks.
3+
# Bypass only when you are certain: git commit --no-verify
4+
python3 scripts/preflight.py --staged || {
5+
echo "" >&2
6+
echo "✖ pre-commit blocked by preflight (see above)." >&2
7+
echo " If this is a false positive, re-run with: git commit --no-verify" >&2
8+
exit 1
9+
}

‎.githooks/pre-push‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
# Full preflight scan before pushing (secrets, dangerous file names).
3+
python3 scripts/preflight.py || {
4+
echo "" >&2
5+
echo "✖ pre-push blocked by preflight (see above)." >&2
6+
exit 1
7+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: Bug report
3+
about: Report something that isn't working
4+
title: "[bug] "
5+
labels: bug
6+
---
7+
8+
## Describe the bug
9+
A clear and concise description of the problem.
10+
11+
## To reproduce
12+
Steps / command used:
13+
```bash
14+
15+
```
16+
If possible, attach a small sample CSV (with no private data) that triggers the issue.
17+
18+
## Expected behavior
19+
What you expected to happen.
20+
21+
## Environment
22+
- OS:
23+
- Python version (`python3 --version`):
24+
- csv-html-fixer version:
25+
26+
## Additional context
27+
Logs, screenshots, sample files, etc.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea or improvement
4+
title: "[feat] "
5+
labels: enhancement
6+
---
7+
8+
## Problem / motivation
9+
What are you trying to do? Why is the current behavior insufficient?
10+
11+
## Proposed solution
12+
What you'd like to happen.
13+
14+
## Alternatives considered
15+
Other approaches you thought about.
16+
17+
## Additional context
18+
Anything else.

‎.github/PULL_REQUEST_TEMPLATE.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## What & why
2+
<!-- What does this PR change, and why? Link related issues (e.g. Closes #1). -->
3+
4+
## Changes
5+
-
6+
7+
## Checklist
8+
- [ ] `python3 -m unittest discover -s tests` passes locally
9+
- [ ] CI is green
10+
- [ ] No new third-party dependencies (standard library only)
11+
- [ ] Commits follow Conventional Commits
12+
- [ ] `CHANGELOG.md` updated under "Unreleased" (if user-facing)
13+
- [ ] Docs updated (if needed)
14+
- [ ] No secrets / credentials committed

‎.github/workflows/ci.yml‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
name: test (python ${{ matrix.python }} / ${{ matrix.os }})
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, macos-latest, windows-latest]
17+
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python }}
23+
- name: Run tests
24+
run: python -m unittest discover -s tests -v
25+
- name: Preflight (secrets / dangerous files)
26+
run: python scripts/preflight.py

‎.gitignore‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*.egg-info/
5+
.eggs/
6+
build/
7+
dist/
8+
.venv/
9+
venv/
10+
env/
11+
.pytest_cache/
12+
.mypy_cache/
13+
.ruff_cache/
14+
.coverage
15+
htmlcov/
16+
17+
# Tool output (fixed CSVs generated by runs)
18+
*_fixed.csv
19+
20+
# Secrets — never commit
21+
.env
22+
*.env
23+
.env.*
24+
*.key
25+
*.pem
26+
*.p12
27+
*.pfx
28+
*secret*
29+
*credential*
30+
*token*
31+
*service*account*.json
32+
33+
# OS / editor
34+
.DS_Store
35+
Thumbs.db
36+
.vscode/
37+
.idea/

‎CHANGELOG.md‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Changelog
2+
3+
All notable changes to this project are documented here.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [1.0.0] - 2026-06-09
11+
12+
### Added
13+
- Interactive CLI that asks for the target CSV path (drag & drop / paste, then Enter).
14+
- Automatic detection and minimal repair of unclosed HTML tags across **all** cells of a
15+
CSV: appends missing close tags, removes stray close tags, and fixes mis-nesting
16+
(e.g. `<p><a></p>` → `<p><a></a></p>`). Valid cells are left byte-for-byte unchanged.
17+
- Known-HTML-tag gating so plain text such as `a < b > c` is never altered, and a
18+
tokenizer that tolerates `>` inside quoted attribute values.
19+
- Automatic character-encoding detection (UTF-8 with/without BOM, Shift-JIS / cp932) with
20+
a `--encoding` override; output is written in the same encoding.
21+
- Faithful round-trip of file format: newline style (CRLF/LF), in-field newlines, quoting,
22+
and trailing-newline presence are all preserved. Results are written to a new
23+
`<name>_fixed.csv` file (non-destructive).
24+
- Non-interactive mode (`csv-html-fixer input.csv ...`) for batch/automation use.
25+
- Unit tests (`python -m unittest`) and cross-platform CI (Ubuntu/macOS/Windows,
26+
Python 3.8–3.12). Zero runtime dependencies.
27+
28+
[Unreleased]: https://github.com/ECgear/csv-html-fixer/compare/v1.0.0...HEAD
29+
[1.0.0]: https://github.com/ECgear/csv-html-fixer/releases/tag/v1.0.0

‎CODE_OF_CONDUCT.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Code of Conduct
2+
3+
This project adopts the **Contributor Covenant, version 2.1** as its Code of Conduct.
4+
5+
Full text: <https://www.contributor-covenant.org/version/2/1/code_of_conduct/>
6+
7+
## Our pledge (summary)
8+
9+
We are committed to providing a friendly, safe, and welcoming environment for
10+
everyone. Maintainers and participants are expected to be respectful and
11+
professional in all project spaces (issues, pull requests, discussions).
12+
13+
## Enforcement
14+
15+
Concerns may be reported privately to the maintainers via a
16+
[GitHub Security Advisory](https://github.com/ECgear/csv-html-fixer/security/advisories/new)
17+
or a direct message to the maintainers. All reports will be reviewed and handled
18+
confidentially. Maintainers may take any action they deem appropriate, up to and
19+
including a temporary or permanent ban from project spaces.
20+
21+
For the complete standards and enforcement guidelines, see the linked
22+
Contributor Covenant 2.1 above.

‎CONTRIBUTING.md‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Contributing to csv-html-fixer
2+
3+
Thanks for your interest in contributing! 🙌
4+
5+
## Ways to contribute
6+
- 🐛 Report bugs via [Issues](https://github.com/ECgear/csv-html-fixer/issues)
7+
- 💡 Propose features (open an issue first to discuss)
8+
- 📖 Improve docs
9+
- 🔧 Submit pull requests
10+
11+
## Development setup
12+
13+
No third-party dependencies are required — just Python 3.8+.
14+
15+
```bash
16+
git clone https://github.com/ECgear/csv-html-fixer.git
17+
cd csv-html-fixer
18+
python3 -m unittest discover -s tests -v # run the tests
19+
git config core.hooksPath .githooks # enable the preflight git hooks
20+
```
21+
22+
Try it against the bundled example:
23+
24+
```bash
25+
python3 csv_html_fixer.py examples/sample.csv
26+
```
27+
28+
## Pull request guidelines
29+
1. Fork & create a branch from `main` (`feat/...`, `fix/...`).
30+
2. Keep changes focused; add tests when it makes sense.
31+
3. Use [Conventional Commits](https://www.conventionalcommits.org/) (`feat:`, `fix:`, `docs:`...).
32+
4. Ensure `python3 -m unittest discover -s tests` passes and CI is green.
33+
5. Keep the tool **dependency-free** (standard library only).
34+
6. Update `CHANGELOG.md` under "Unreleased".
35+
7. Open the PR with a clear description of what & why.
36+
37+
## Code of Conduct
38+
39+
This project follows the [Contributor Covenant](./CODE_OF_CONDUCT.md). By participating you agree to uphold it.

0 commit comments

Comments
 (0)