CodeSampleX

Exemplo

github.com/russross/blackfriday/v2 v2.1.0: HTMLRendererParameters

Amostra verificada para golang github.com/russross/blackfriday/v2 v2.1.0: HTMLRendererParameters. O contrato rodou em go 1.26 · linux alpine/x64 · docker e…

sha256:89ff22ea5a6382d462aecdf74bb1dcec5cf15160834b19f5c1d3ac4cadd8dfac

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado go linux 24 · ubuntu · glibc 2.39 x64 go go go

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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

Caso

HOW
Objetivo
verify github.com/russross/blackfriday/v2.HTMLRendererParameters in pkg:golang/github.com/russross/blackfriday/v2@v2.1.0
Pacotes
Símbolos
  • github.com/russross/blackfriday/v2.HTMLRendererParameters
Ambiente
go
Criado
2026-08-28T00:14:56Z

Contrato

  1. blackfriday.HTMLRendererParameters configures HTML rendering options including complete page generation with Title, CSS stylesheet links, and Icon.
  2. blackfriday.HTMLRendererParameters.HeadingLevelOffset adjusts the heading tag level of markdown headers in the rendered HTML.
  3. blackfriday.HTMLRendererParameters.Flags configures renderer behavior such as setting target="_blank" on links with HrefTargetBlank.

Arquivos

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • renderer_test.go
  • spec.json

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

PROMPT.md
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.HTMLRendererParameters 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.HTMLRendererParameters

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.
csx.json
{"case":{"caseId":"case:sha256:936d41169e1f88633eaa98a1b98da0f8f7a94032dc06e6191c5861fb51294fed","contract":["blackfriday.HTMLRendererParameters configures HTML rendering options including complete page generation with Title, CSS stylesheet links, and Icon.","blackfriday.HTMLRendererParameters.HeadingLevelOffset adjusts the heading tag level of markdown headers in the rendered HTML.","blackfriday.HTMLRendererParameters.Flags configures renderer behavior such as setting target=\"_blank\" on links with HrefTargetBlank."],"goal":"verify github.com/russross/blackfriday/v2.HTMLRendererParameters 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.HTMLRendererParameters"]},"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.HTMLRendererParameters"],"verifierAdapter":"golang@1"}
go.mod
module example.com/htmlrendererparams

go 1.22

require github.com/russross/blackfriday/v2 v2.1.0
go.sum
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=
renderer_test.go
package htmlrendererparams_test

import (
	"strings"
	"testing"

	"github.com/russross/blackfriday/v2"
)

func TestHTMLRendererParametersCompletePage(t *testing.T) {
	params := blackfriday.HTMLRendererParameters{
		Flags: blackfriday.CompletePage,
		Title: "Sample Document",
		CSS:   "https://example.com/style.css",
		Icon:  "https://example.com/favicon.ico",
	}

	renderer := blackfriday.NewHTMLRenderer(params)
	input := []byte("# Hello World\n\nThis is a test paragraph.")
	output := blackfriday.Run(input, blackfriday.WithRenderer(renderer))
	outputStr := string(output)

	if !strings.Contains(outputStr, "<!DOCTYPE html>") {
		t.Errorf("expected complete HTML document with DOCTYPE, got:\n%s", outputStr)
	}
	if !strings.Contains(outputStr, "<title>Sample Document</title>") {
		t.Errorf("expected title to contain 'Sample Document', got:\n%s", outputStr)
	}
	if !strings.Contains(outputStr, `<link rel="stylesheet" type="text/css" href="https://example.com/style.css"`) {
		t.Errorf("expected stylesheet link to contain CSS path, got:\n%s", outputStr)
	}
	if !strings.Contains(outputStr, `<link rel="icon" type="image/x-icon" href="https://example.com/favicon.ico"`) {
		t.Errorf("expected icon link to contain Icon path, got:\n%s", outputStr)
	}
	if !strings.Contains(outputStr, "<h1>Hello World</h1>") {
		t.Errorf("expected rendered heading '<h1>Hello World</h1>', got:\n%s", outputStr)
	}
}

func TestHTMLRendererParametersHeadingLevelOffset(t *testing.T) {
	params := blackfriday.HTMLRendererParameters{
		HeadingLevelOffset: 2,
	}

	renderer := blackfriday.NewHTMLRenderer(params)
	input := []byte("# Main Title\n\n## Sub Title")
	output := blackfriday.Run(input, blackfriday.WithRenderer(renderer))
	outputStr := string(output)

	// Level 1 heading with offset 2 should render as <h3>
	if !strings.Contains(outputStr, "<h3>Main Title</h3>") {
		t.Errorf("expected '# Main Title' with offset 2 to render as '<h3>Main Title</h3>', got:\n%s", outputStr)
	}
	// Level 2 heading with offset 2 should render as <h4>
	if !strings.Contains(outputStr, "<h4>Sub Title</h4>") {
		t.Errorf("expected '## Sub Title' with offset 2 to render as '<h4>Sub Title</h4>', got:\n%s", outputStr)
	}
}

func TestHTMLRendererParametersFlags(t *testing.T) {
	params := blackfriday.HTMLRendererParameters{
		Flags: blackfriday.HrefTargetBlank,
	}

	renderer := blackfriday.NewHTMLRenderer(params)
	input := []byte("[Example Link](https://example.com)")
	output := blackfriday.Run(input, blackfriday.WithRenderer(renderer))
	outputStr := string(output)

	if !strings.Contains(outputStr, `target="_blank"`) {
		t.Errorf("expected link to have target=\"_blank\" when HrefTargetBlank flag is set, got:\n%s", outputStr)
	}
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify github.com/russross/blackfriday/v2.HTMLRendererParameters 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.HTMLRendererParameters"
  ]
}

Seeder de origem

anônimo