Sample
github.com/russross/blackfriday/v2 v2.1.0: Heading
Verified sample for golang github.com/russross/blackfriday/v2 v2.1.0: Heading. The contract ran on go 1.26 · linux alpine/x64 · docker and passed.
sha256:6e770e8149df1b9a15436d66cc63c8c9bd529e443976e77ea93fa12a9fde290f
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
go linux 24 · ubuntu · glibc 2.39 x64 go go go
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-28 |
Case
HOW- Goal
- verify github.com/russross/blackfriday/v2.Heading in pkg:golang/github.com/russross/blackfriday/v2@v2.1.0
- Symbols
-
- github.com/russross/blackfriday/v2.Heading
- Environment
- go
- Created
- 2026-08-28T00:17:57Z
Contract
- blackfriday.Heading identifies heading AST nodes parsed from ATX and setext Markdown headers.
- blackfriday.Heading nodes carry HeadingData with Level corresponding to the header depth (1-6).
- blackfriday.Heading nodes can be traversed with Node.Walk with entering true and false states.
- blackfriday.Heading nodes populate HeadingID in HeadingData when AutoHeadingIDs or HeadingIDs extensions are enabled.
- blackfriday.NewNode with blackfriday.Heading creates an AST node of Type Heading with configurable HeadingData.
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract_test.go
Source
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify github.com/russross/blackfriday/v2.Heading in pkg:golang/github.com/russross/blackfriday/v2@v2.1.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/russross/blackfriday/v2@v2.1.0
Demonstrate these symbols/APIs:
- github.com/russross/blackfriday/v2.Heading
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:339e1c55510d99dce46b37555d0ef73f884aaa03698736cdc75bd00b7d7851b3","constraints":{"executionContext":"go"},"contract":["blackfriday.Heading identifies heading AST nodes parsed from ATX and setext Markdown headers.","blackfriday.Heading nodes carry HeadingData with Level corresponding to the header depth (1-6).","blackfriday.Heading nodes can be traversed with Node.Walk with entering true and false states.","blackfriday.Heading nodes populate HeadingID in HeadingData when AutoHeadingIDs or HeadingIDs extensions are enabled.","blackfriday.NewNode with blackfriday.Heading creates an AST node of Type Heading with configurable HeadingData."],"goal":"verify github.com/russross/blackfriday/v2.Heading in pkg:golang/github.com/russross/blackfriday/v2@v2.1.0","kind":"HOW","packages":["pkg:golang/github.com/russross/blackfriday/v2@v2.1.0"],"schemaVersion":1,"symbols":["github.com/russross/blackfriday/v2.Heading"]},"contractCommand":["go","test","./..."],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","executionContext":"go","language":"go","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","runtime":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/russross/blackfriday/v2@v2.1.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/russross/blackfriday/v2@v2.1.0","symbols":["github.com/russross/blackfriday/v2.Heading"],"verifierAdapter":"golang@1"}
module example.com/heading
go 1.26.6
require github.com/russross/blackfriday/v2 v2.1.0
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
package main
import (
"fmt"
"github.com/russross/blackfriday/v2"
)
func main() {
markdown := []byte("# Main Title\n\n## Subtitle\n\nSection content.\n")
p := blackfriday.New(blackfriday.WithExtensions(blackfriday.AutoHeadingIDs))
doc := p.Parse(markdown)
doc.Walk(func(node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
if node.Type == blackfriday.Heading && entering {
var text string
if node.FirstChild != nil {
text = string(node.FirstChild.Literal)
}
fmt.Printf("Heading Level: %d, ID: %s, Text: %s\n",
node.HeadingData.Level,
node.HeadingData.HeadingID,
text,
)
}
return blackfriday.GoToNext
})
}
{
"schemaVersion": 1,
"goal": "verify github.com/russross/blackfriday/v2.Heading in pkg:golang/github.com/russross/blackfriday/v2@v2.1.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/russross/blackfriday/v2@v2.1.0"
],
"symbols": [
"github.com/russross/blackfriday/v2.Heading"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
package test
import (
"testing"
"github.com/russross/blackfriday/v2"
)
func TestHeadingNodeParsingATX(t *testing.T) {
tests := []struct {
input string
level int
text string
}{
{"# Heading 1\n", 1, "Heading 1"},
{"## Heading 2\n", 2, "Heading 2"},
{"### Heading 3\n", 3, "Heading 3"},
{"#### Heading 4\n", 4, "Heading 4"},
{"##### Heading 5\n", 5, "Heading 5"},
{"###### Heading 6\n", 6, "Heading 6"},
}
for _, tc := range tests {
p := blackfriday.New()
doc := p.Parse([]byte(tc.input))
var headingNode *blackfriday.Node
doc.Walk(func(node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
if node.Type == blackfriday.Heading && entering {
headingNode = node
return blackfriday.Terminate
}
return blackfriday.GoToNext
})
if headingNode == nil {
t.Fatalf("expected Heading node for input %q, found none", tc.input)
}
if headingNode.Type != blackfriday.Heading {
t.Errorf("headingNode.Type = %v, want %v", headingNode.Type, blackfriday.Heading)
}
if headingNode.HeadingData.Level != tc.level {
t.Errorf("headingNode.HeadingData.Level = %d, want %d", headingNode.HeadingData.Level, tc.level)
}
if headingNode.FirstChild == nil || string(headingNode.FirstChild.Literal) != tc.text {
t.Errorf("heading text = %q, want %q", string(headingNode.FirstChild.Literal), tc.text)
}
}
}
func TestHeadingNodeParsingSetext(t *testing.T) {
tests := []struct {
input string
level int
text string
}{
{"Setext Heading 1\n===============\n", 1, "Setext Heading 1"},
{"Setext Heading 2\n---------------\n", 2, "Setext Heading 2"},
}
for _, tc := range tests {
p := blackfriday.New()
doc := p.Parse([]byte(tc.input))
var headingNode *blackfriday.Node
doc.Walk(func(node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
if node.Type == blackfriday.Heading && entering {
headingNode = node
return blackfriday.Terminate
}
return blackfriday.GoToNext
})
if headingNode == nil {
t.Fatalf("expected Heading node for setext input %q, found none", tc.input)
}
if headingNode.Type != blackfriday.Heading {
t.Errorf("headingNode.Type = %v, want %v", headingNode.Type, blackfriday.Heading)
}
if headingNode.HeadingData.Level != tc.level {
t.Errorf("headingNode.HeadingData.Level = %d, want %d", headingNode.HeadingData.Level, tc.level)
}
if headingNode.FirstChild == nil || string(headingNode.FirstChild.Literal) != tc.text {
t.Errorf("heading text = %q, want %q", string(headingNode.FirstChild.Literal), tc.text)
}
}
}
func TestHeadingNodeWalkTraversal(t *testing.T) {
markdown := []byte("# Main Title\n")
p := blackfriday.New()
doc := p.Parse(markdown)
var entered, exited bool
doc.Walk(func(node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
if node.Type == blackfriday.Heading {
if entering {
entered = true
} else {
exited = true
}
}
return blackfriday.GoToNext
})
if !entered {
t.Error("expected Heading node to be entered during Walk")
}
if !exited {
t.Error("expected Heading node to be exited during Walk")
}
}
func TestHeadingAutoHeadingIDs(t *testing.T) {
markdown := []byte("# Getting Started Guide\n")
p := blackfriday.New(blackfriday.WithExtensions(blackfriday.AutoHeadingIDs))
doc := p.Parse(markdown)
var headingID string
doc.Walk(func(node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
if node.Type == blackfriday.Heading && entering {
headingID = node.HeadingData.HeadingID
return blackfriday.Terminate
}
return blackfriday.GoToNext
})
expectedID := "getting-started-guide"
if headingID != expectedID {
t.Errorf("HeadingID = %q, want %q", headingID, expectedID)
}
}
func TestHeadingExplicitHeadingIDs(t *testing.T) {
markdown := []byte("# Custom Section {#custom-anchor}\n")
p := blackfriday.New(blackfriday.WithExtensions(blackfriday.HeadingIDs))
doc := p.Parse(markdown)
var headingID string
doc.Walk(func(node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
if node.Type == blackfriday.Heading && entering {
headingID = node.HeadingData.HeadingID
return blackfriday.Terminate
}
return blackfriday.GoToNext
})
expectedID := "custom-anchor"
if headingID != expectedID {
t.Errorf("HeadingID = %q, want %q", headingID, expectedID)
}
}
func TestNewNodeHeadingCreation(t *testing.T) {
node := blackfriday.NewNode(blackfriday.Heading)
if node.Type != blackfriday.Heading {
t.Fatalf("node.Type = %v, want %v", node.Type, blackfriday.Heading)
}
node.HeadingData.Level = 3
node.HeadingData.HeadingID = "manual-h3"
textChild := blackfriday.NewNode(blackfriday.Text)
textChild.Literal = []byte("Manual Heading Content")
node.AppendChild(textChild)
if node.HeadingData.Level != 3 {
t.Errorf("node.HeadingData.Level = %d, want 3", node.HeadingData.Level)
}
if node.HeadingData.HeadingID != "manual-h3" {
t.Errorf("node.HeadingData.HeadingID = %q, want %q", node.HeadingData.HeadingID, "manual-h3")
}
if node.FirstChild != textChild {
t.Error("expected textChild to be first child of heading node")
}
if string(node.FirstChild.Literal) != "Manual Heading Content" {
t.Errorf("child literal = %q, want %q", string(node.FirstChild.Literal), "Manual Heading Content")
}
}
Origin Seeder
anonymous