Skip to content

Many changes, sorry for the size#1

Open
arran4 wants to merge 40 commits into
d0iasm:masterfrom
arran4:2026-07-10
Open

Many changes, sorry for the size#1
arran4 wants to merge 40 commits into
d0iasm:masterfrom
arran4:2026-07-10

Conversation

@arran4

@arran4 arran4 commented Jul 10, 2026

Copy link
Copy Markdown

I've attempted to bring this up to date so I could use it, I have made it a bit of my own sorry if that's an issue. Please provide feedback, etc. There was AI used in this let me know if that's also an issue.

Generated summary:

Summary

This PR modernises the project’s development and release workflow, expands the automated test coverage, improves command-line error handling, and fixes several Markdown conversion edge cases.

The main goals are to make the project easier to build, test, release, and maintain while preserving its existing lightweight implementation.

Changes

Add standard Go module support

  • Add go.mod and go.sum.

  • Allow the project to be built, tested, and installed using standard Go commands.

  • Remove the Makefile, which only wrapped standard Go tooling.

  • Update the README to document:

    • go run .
    • go test ./...
    • go install
    • installation from GitHub Releases

This reduces project-specific setup and makes the repository behave like a conventional Go project.

Add comprehensive CI and release automation

Add a GitHub Actions workflow covering automated validation and release-related tasks, including:

  • builds and tests
  • formatting and static analysis
  • linting
  • dependency and vulnerability checks
  • secret scanning
  • cross-platform build verification
  • GoReleaser validation and release generation

Also add:

  • .goreleaser.yml for reproducible binary releases
  • .gitleaks.toml for secret-scanning configuration

This provides earlier feedback on regressions and makes releases repeatable rather than dependent on manual local steps.

Replace the ad hoc test program with Go tests

Remove the standalone test.go test runner and replace it with a normal testing package test suite.

Test cases are now stored as embedded txtar fixtures under testdata/txtar. Each fixture contains a Markdown input and its expected HTML output.

Coverage includes:

  • paragraphs
  • headings
  • inline headings
  • unordered and nested lists
  • links
  • emphasis
  • strong text
  • multiple inline constructs
  • hard line breaks
  • interactions between headings, paragraphs, and lists

The fixture-based structure makes failures easier to understand and allows new parser cases to be added without expanding a large table or creating another custom test mechanism.

Improve command-line handling

The command-line interface now:

  • displays usage when no input file is supplied
  • supports -h, --help, and -help
  • accepts -nocss independently of argument order
  • reports unknown flags
  • rejects multiple input files
  • reports errors through standard error
  • avoids panics for normal user-input errors
  • validates that the input has a .md extension
  • correctly handles filenames containing multiple dots
  • derives the output path using filepath.Ext and strings.TrimSuffix

For example, an input named release.notes.md now produces release.notes.html rather than relying on a fragile string split.

These changes make the program safer to invoke from scripts and provide clearer feedback when it is used incorrectly.

Improve file and write error handling

  • Check errors returned while opening and creating files.
  • Report failures with useful error messages.
  • Flush the buffered writer explicitly.
  • Handle input and output close errors more carefully.
  • Avoid panicking for expected filesystem or argument errors.

This results in more predictable CLI behaviour and prevents failures from being silently ignored.

Fix Markdown hard line breaks

Support both CommonMark hard-break forms:

  • two trailing spaces
  • a trailing backslash

The parser now records whether a paragraph line ended in a hard break, rather than attempting to infer that later from generated HTML.

This keeps paragraph joining logic separate from inline conversion and avoids accidentally inserting spaces after <br>.

Improve parser reliability

The parser and generator have also received smaller correctness and maintainability fixes, including:

  • clearer heading-level conversion
  • corrected unreachable-code and return-path issues
  • non-greedy matching for inline constructs
  • repeated conversion of multiple inline elements on one line
  • improved handling of whitespace
  • tests for headings and paragraphs appearing around lists

Why this is better

The project now follows standard Go conventions and can be worked on without learning repository-specific build commands.

The expanded fixture-based test suite documents current behaviour and makes future parser changes safer. CI validates contributions consistently across formatting, tests, static analysis, security checks, and release configuration.

For users, the CLI is less likely to panic, produces clearer errors, supports more robust filename handling, and correctly recognises both standard hard-line-break forms.

For maintainers, releases become reproducible, regressions are easier to detect, and adding a parser test generally requires only a small input/output fixture.

Testing

Run the full test suite with:

go test ./...

The CI workflow also performs the broader linting, static-analysis, security, and release validation checks.

google-labs-jules Bot and others added 30 commits July 6, 2026 08:57
- Implemented unified, single-file GitHub Actions CI/CD setup based on the referenced blog post
- Added GoReleaser configuration for pure Go binaries
- Added `.golangci.yml` and `.gitleaks.toml`
- Updated `README.md` with binary and `go install` instructions

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
…rations

- Added `//go:build ignore` to `test.go` to prevent it from being compiled when running `go vet ./...` and `golangci-lint` for the entire project, which previously caused "main redeclared in this block" errors.
- The `test.go` file acts as a standalone script for `make test` rather than a standard `_test.go` file.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
- Fixed unhandled errors in `main.go`.
- Fixed increment/decrement syntax in `gen.go`.
- Fixed regex raw string issue in `regexp.go`.
- Fixed variable naming in `regexp.go`.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
- Added `...` raw string on the `horizontal` regular expression in `regexp.go`.
- Added missing returns in `ntoh` and `hton` in `regexp.go` to satisfy golangci-lint typechecks.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
- Renamed `test.go` to `main_test.go` and refactored tests to use the `testing` package to fix the multiple main declarations error.
- Updated the module path in `go.mod` to `github.com/mdtohtml/mdtohtml` to match the installation path.
- Used raw strings for `regexp.Compile` in `regexp.go` to fix the `gosimple` lint error.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
- Updated `main.go` to only check the error returned by `writer.Flush()` instead of checking every `WriteString` call.
- Refactored `regexp.go` to use `regexp.MustCompile` for package-level variables instead of ignoring the error from `regexp.Compile`.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
- Added empty assignment (`_`) for unhandled errors from `writer.WriteString` calls.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
- Rewrote tests in `main_test.go` to iterate over an `embed.FS` directory and process `txtar` files.
- Extracted existing test cases into individual `txtar` archives in `testdata/txtar/`.
- Updated `go.mod` to include `golang.org/x/tools/txtar` dependency.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
- Upgraded Go to 1.25.0 to resolve the internal compilation error caused by newer toolchain requirements of `golang.org/x/tools`.
- Updated GitHub Actions to `actions/checkout@v6`, `actions/setup-go@v6`, and `golangci/golangci-lint-action@v9` per instructions.
- Removed the local `.golangci.yml` file to rely on the default linter config.
- Addressed newly discovered `golangci-lint` errors (e.g. missing returns from type check in `regexp.go`).
- Ran `go fmt ./...`.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Removed duplicate `with` blocks for the golangci-lint step in
.github/workflows/ci.yml to fix workflow parsing errors.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Removed unreachable returns after switch blocks containing panics in `regexp.go` to fix CI failures.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Appended dummy returns after panics in `regexp.go` to satisfy `golangci-lint` and `go vet`. Also explicitly pinned the `golangci-lint` action version to `v1.64.8` to match the `go 1.25.0` requirement in `go.mod`.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Updated the `.github/workflows/ci.yml` `golangci-lint-action` configuration to use a properly formatted version pinned to `v1.64.8` while utilizing `action@v6` which resolves version mismatches causing CI to fail with `golangci-lint v1 is not supported by golangci-lint-action >= v7`. Also removed the dummy `return` statements causing unreachable code issues.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Updated the `golangci-lint` workflow configuration to match the blog guidelines by setting the action version to `v9.3.0` and `golangci-lint` version to `v2.12.2` to resolve version compatibility errors. Also, removed unreachable dummy `return` statements in `regexp.go` that caused `go vet` to fail.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Updated the `golangci-lint` workflow configuration to match the blog guidelines by setting the action version to `v9.3.0` and `golangci-lint` version to `v1.64.8` to resolve version compatibility errors. Also, removed unreachable dummy `return` statements in `regexp.go` that caused `go vet` to fail.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Updated the `golangci-lint` workflow configuration to match the blog guidelines by setting the action version to `v9.3.0` and `golangci-lint` version to `v1.64.8` to resolve version compatibility errors. Also, removed unreachable dummy `return` statements in `regexp.go` that caused `go vet` to fail.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Fixed lint issues by explicitly checking errors on standard library method calls `wfile.Close()`, `fmt.Fprintln()`, and `rfile.Close()`. Refactored `switch` on `f.Name` to satisfy `staticcheck` warnings. Also ensured `golangci-lint` uses the v9.3.0 GitHub Actions wrapper with go1.25 compatibility.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
…573028

Fix duplicate `with` keys in GitHub Actions workflow
Updates the module declaration in go.mod from github.com/mdtohtml/mdtohtml
to github.com/arran4/fork-mdtohtml to resolve the version constraints
conflict encountered during `go get` or `go install`. Also updates the
README.md instructions to point to the new fork URL.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Fix module path constraint conflict by updating go.mod to match fork
- Added trailing spaces to `testdata/txtar/paragraph_br.txtar` to properly trigger the `<br>` tag parsing.
- Modified `gen.go` to avoid inserting an extraneous space when the previous line already contains a `<br>` tag.
- Ensured string checks do not cause slice out of bounds panics by validating length.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
- Modified `gen.go` to avoid inserting an extraneous space when the previous line already ends in a `<br>` tag. Added safe bounds checking.
- Updated `testdata/txtar/paragraph_br.txtar` to include the required two trailing spaces after `a paragraph` so that it translates correctly to a `<br>` tag according to markdown standard formatting.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
- fixed golangci-lint version format and parameters in `.github/workflows/ci.yml`.
- introduced `hasBr` to `Line` struct to accurately track formatting blocks without hacking string lengths or suffix scanning.
- corrected markdown syntax in `testdata/txtar/paragraph_br.txtar` to contain appropriate two trailing spaces to invoke `<br>` tags properly.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
fix: TestTxtar/paragraph_br failing test and whitespace handling
Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
google-labs-jules Bot and others added 10 commits July 10, 2026 04:18
Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
…6850059

Fix `paragraph_br` markdown break test
- Prevent `index out of range` panic by verifying `os.Args` length and adding a proper `usage()` output.
- Clean up file extension handling: Replace fragile `strings.Split` with `filepath.Ext` and `strings.TrimSuffix` to support filenames with multiple dots.
- Replace aggressive `panic()` calls with `fmt.Fprintf(os.Stderr)` and `os.Exit(1)` for a cleaner CLI experience.
- Gracefully handle the `-nocss` flag regardless of order in arguments.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
- Add handling for unknown flags in arguments parsing.
- Return error on specifying multiple input files.
- Don't use `os.Exit(1)` inside the deferred function closing the read file, only log the error.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
…886464840

Fix CLI arguments, error outputs, and filename parsing
- Remove the unnecessary `Makefile`.
- Update GitHub Actions workflow to run `go test -v ./...` instead of `make test`.
- Update `README.md` to reflect usage with `go build .` and `go test ./...`.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
- Replaced the usage examples that relied on chaining `go build .` with `go run .`.
- Added examples for how to use the binary after installing via `go install`.

Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Remove Makefile and use standard go commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant