Jelajahi Sumber

Merge branch 'feature/tab-size' of bajdev/posts into main

bajdev 1 hari lalu
induk
melakukan
382e623f2f

+ 5 - 0
main_test.go

@@ -144,6 +144,11 @@ func TestStatic(t *testing.T) {
 	if status != 200 || !strings.HasPrefix(h.Get("Content-Type"), "text/css") || !strings.Contains(body, ":root") {
 		t.Errorf("status = %d, type = %q", status, h.Get("Content-Type"))
 	}
+	// gofmt indents with tabs; browsers default to 8 columns, which pushes
+	// quoted Go code past the edge of the column.
+	if !strings.Contains(body, "tab-size: 4") {
+		t.Error("stylesheet should set tab-size: 4 for code blocks")
+	}
 }
 
 func TestStylesheetCacheBusting(t *testing.T) {

+ 33 - 0
pull-releases/008-tab-size/README.md

@@ -0,0 +1,33 @@
+# Show tabs in code blocks 4 columns wide
+
+Branch `feature/tab-size` · version 0.5.1
+
+## What changed
+
+- **`tab-size: 4` on code blocks.** Browsers show a tab as 8 columns by default. gofmt indents Go with tabs, so quoted Go code ran past the edge of its box two levels in. Code blocks now show tabs 4 columns wide.
+- **Test:** the stylesheet test checks the rule is there.
+- **Version:** 0.5.1.
+
+## Notes
+
+- Posts can now quote Go exactly as gofmt writes it, with tabs, instead of re-indenting with spaces. The pinned-posts post was re-indented with spaces before this fix and looks the same either way.
+- The stylesheet's content hash changes, so browsers fetch the new file on their next visit without a hard refresh (v0.2.1).
+
+## Testing
+
+- All tests pass with the race detector (`go test -race ./...`).
+- Rendered the same tab-indented Go snippet with the old and new stylesheet:
+
+| Before (8 columns) | After (4 columns) |
+|---|---|
+| [![Before](tabs-before.png)](tabs-before.png) | [![After](tabs-after.png)](tabs-after.png) |
+
+## Screenshots
+
+From the branch's build running locally. The home page doesn't change.
+
+| Desktop | Mobile |
+|---|---|
+| [![Desktop](desktop.png)](desktop.png) | [![Mobile](mobile.png)](mobile.png) |
+
+🤖 Generated with [Claude Code](https://claude.com/claude-code)

TEMPAT SAMPAH
pull-releases/008-tab-size/desktop.png


TEMPAT SAMPAH
pull-releases/008-tab-size/mobile.png


TEMPAT SAMPAH
pull-releases/008-tab-size/tabs-after.png


TEMPAT SAMPAH
pull-releases/008-tab-size/tabs-before.png


+ 1 - 0
pull-releases/README.md

@@ -34,3 +34,4 @@ screenshot, or its `README.md` doesn't load.
 | [005](005-post-author/) | Author in the post header |
 | [006](006-go-1-27/) | Require Go 1.27.3 (security fixes) |
 | [007](007-pinned-posts/) | Pinned posts |
+| [008](008-tab-size/) | Tabs in code blocks 4 columns wide |

+ 1 - 1
static/style.css

@@ -94,7 +94,7 @@ article img { max-width: 100%; height: auto; }
 
 code, pre { font: 0.9em/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
 code { background: var(--code-bg); padding: 0.1em 0.3em; border-radius: 3px; }
-pre { background: var(--code-bg); padding: 1rem; overflow-x: auto; border-radius: 4px; }
+pre { background: var(--code-bg); padding: 1rem; overflow-x: auto; border-radius: 4px; tab-size: 4; }
 pre code { background: none; padding: 0; }
 
 blockquote { margin: 1rem 0; padding-left: 1rem; border-left: 3px solid var(--rule); color: var(--muted); }

+ 1 - 1
version.go

@@ -4,7 +4,7 @@ import "runtime/debug"
 
 // version is the release number shown on the About page. Bump it in the PR
 // that makes a user-visible change.
-const version = "0.5.0"
+const version = "0.5.1"
 
 // buildCommit returns the short git revision that `go build` stamped into the
 // binary, with "-dirty" if the tree had uncommitted changes, or "" if the