CodeSampleX

Ejemplo

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

Muestra verificada para golang github.com/russross/blackfriday/v2 v2.1.0: blackfriday.Run. El contrato se ejecutó en go 1.26 · linux debian/x64 · docker y…

sha256:75d693324904db2f672734f0c381392e7a8e81b034887e8c428171f9b4088979

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado go linux 24 · ubuntu · glibc 2.39 x64 go go go

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a…
2026-09-02

Caso

HOW
Objetivo
verify blackfriday.Run in pkg:golang/github.com/russross/blackfriday/v2@v2.1.0
Paquetes
Símbolos
  • blackfriday.Run
Entorno
go
Creado
2026-09-02T07:49:44Z

Contrato

  1. blackfriday.Run converts standard markdown input into HTML bytes including headings, bold, and italic text.
  2. blackfriday.Run with WithExtensions(CommonExtensions) enables extensions such as tables, strikethrough, and autolinks.
  3. blackfriday.Run with WithRenderer and HrefTargetBlank flag renders links with target="_blank".
  4. blackfriday.Run with WithNoExtensions disables markdown extensions and treats syntax characters literally.
  5. blackfriday.Run safely handles nil, empty, and whitespace-only byte slice inputs returning empty output.

Archivos

  • NOTES.md
  • PROMPT.md
  • blackfriday_test.go
  • csx.json
  • go.mod
  • go.sum
  • spec.json

Descargar el artefacto de código fuente (tar.gz)

Código fuente

NOTES.md
# Blackfriday Markdown to HTML Rendering

A search for `blackfriday.Run` in `github.com/russross/blackfriday/v2@v2.1.0` required verification against the target package version.

This sample verifies markdown parsing and HTML rendering behavior using `blackfriday.Run` with various option configurations.

## Observed Behavior

1. **Basic Markdown to HTML Conversion (`blackfriday.Run`)**:
   - `blackfriday.Run(input []byte)` converts markdown input into HTML byte slice, rendering standard markdown elements such as headings, bold, and italic text.

2. **Extensions Configuration (`blackfriday.WithExtensions`)**:
   - Passing `blackfriday.WithExtensions(...)` allows configuring extensions such as `blackfriday.CommonExtensions` (enabling tables, strikethrough, autolinks, and fenced code blocks).

3. **Custom HTML Renderer Configuration (`blackfriday.WithRenderer`)**:
   - `blackfriday.WithRenderer(blackfriday.NewHTMLRenderer(params))` allows fine-grained customization of HTML generation, including flags like `blackfriday.HrefTargetBlank` which injects `target="_blank"` attributes on rendered links.

4. **Disabling Extensions (`blackfriday.WithNoExtensions`)**:
   - Passing `blackfriday.WithNoExtensions()` disables all markdown extension parsing, treating syntax like `~~text~~` as literal characters rather than strikethrough HTML tags.

5. **Empty and Nil Input Handling**:
   - Calling `blackfriday.Run(nil)` or `blackfriday.Run([]byte(""))` safely returns an empty byte slice without panicking or allocating unneeded buffers.
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 blackfriday.Run 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:
  - blackfriday.Run
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.
blackfriday_test.go
package blackfridaydemo_test

import (
	"bytes"
	"strings"
	"testing"

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

// TestBlackfridayRunBasicMarkdown verifies blackfriday.Run converts standard markdown to HTML bytes.
func TestBlackfridayRunBasicMarkdown(t *testing.T) {
	input := []byte("# Hello World\n\nThis is **bold** and *italic* text.")
	output := blackfriday.Run(input)

	outputStr := string(output)
	if !strings.Contains(outputStr, "<h1>Hello World</h1>") {
		t.Errorf("expected <h1>Hello World</h1> in output, got %q", outputStr)
	}
	if !strings.Contains(outputStr, "<strong>bold</strong>") {
		t.Errorf("expected <strong>bold</strong> in output, got %q", outputStr)
	}
	if !strings.Contains(outputStr, "<em>italic</em>") {
		t.Errorf("expected <em>italic</em> in output, got %q", outputStr)
	}
}

// TestBlackfridayRunWithExtensions verifies blackfriday.Run with WithExtensions enables tables, strikethrough, and autolink.
func TestBlackfridayRunWithExtensions(t *testing.T) {
	tableInput := []byte("| Header 1 | Header 2 |\n|---|---|\n| Cell 1 | Cell 2 |\n\n~~deleted text~~\n\nhttps://example.com")
	
	// Blackfriday default Run uses CommonExtensions (which includes Tables, Strikethrough, Autolink, etc.)
	output := blackfriday.Run(tableInput, blackfriday.WithExtensions(blackfriday.CommonExtensions))
	outputStr := string(output)

	if !strings.Contains(outputStr, "<table>") || !strings.Contains(outputStr, "<td>Cell 1</td>") {
		t.Errorf("expected table rendering in output, got %q", outputStr)
	}
	if !strings.Contains(outputStr, "<del>deleted text</del>") {
		t.Errorf("expected strikethrough <del> in output, got %q", outputStr)
	}
	if !strings.Contains(outputStr, `<a href="https://example.com">https://example.com</a>`) {
		t.Errorf("expected autolink in output, got %q", outputStr)
	}
}

// TestBlackfridayRunWithRenderer verifies blackfriday.Run accepts custom HTML renderer parameters.
func TestBlackfridayRunWithRenderer(t *testing.T) {
	input := []byte("[Example](https://example.com)")

	renderer := blackfriday.NewHTMLRenderer(blackfriday.HTMLRendererParameters{
		Flags: blackfriday.HrefTargetBlank,
	})

	output := blackfriday.Run(input, blackfriday.WithRenderer(renderer))
	outputStr := string(output)

	if !strings.Contains(outputStr, `target="_blank"`) {
		t.Errorf("expected target=\"_blank\" in rendered link, got %q", outputStr)
	}
}

// TestBlackfridayRunWithNoExtensions verifies blackfriday.Run with WithNoExtensions ignores markdown extensions.
func TestBlackfridayRunWithNoExtensions(t *testing.T) {
	input := []byte("~~not deleted~~")

	output := blackfriday.Run(input, blackfriday.WithNoExtensions())
	outputStr := string(output)

	if strings.Contains(outputStr, "<del>") {
		t.Errorf("expected no <del> tag with WithNoExtensions, got %q", outputStr)
	}
	if !strings.Contains(outputStr, "~~not deleted~~") {
		t.Errorf("expected literal tildes in output, got %q", outputStr)
	}
}

// TestBlackfridayRunEmptyAndNilInput verifies blackfriday.Run gracefully handles empty and nil byte slices.
func TestBlackfridayRunEmptyAndNilInput(t *testing.T) {
	nilOutput := blackfriday.Run(nil)
	if len(nilOutput) != 0 {
		t.Errorf("expected empty output for nil input, got %q", string(nilOutput))
	}

	emptyOutput := blackfriday.Run([]byte(""))
	if len(emptyOutput) != 0 {
		t.Errorf("expected empty output for empty slice input, got %q", string(emptyOutput))
	}

	whitespaceOutput := blackfriday.Run([]byte("   \n\n  \t "))
	trimmed := bytes.TrimSpace(whitespaceOutput)
	if len(trimmed) != 0 {
		t.Errorf("expected empty trimmed output for whitespace input, got %q", string(whitespaceOutput))
	}
}
csx.json
{"case":{"caseId":"case:sha256:e38e3ca28685be247f8e14b4c224799ce2e0a4023ba7e341007c9ddab19571db","contract":["blackfriday.Run converts standard markdown input into HTML bytes including headings, bold, and italic text.","blackfriday.Run with WithExtensions(CommonExtensions) enables extensions such as tables, strikethrough, and autolinks.","blackfriday.Run with WithRenderer and HrefTargetBlank flag renders links with target=\"_blank\".","blackfriday.Run with WithNoExtensions disables markdown extensions and treats syntax characters literally.","blackfriday.Run safely handles nil, empty, and whitespace-only byte slice inputs returning empty output."],"goal":"verify blackfriday.Run 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":["blackfriday.Run"]},"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":["blackfriday.Run"],"verifierAdapter":"golang@1"}
go.mod
module example.com/blackfridaydemo

go 1.23

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=
spec.json
{
  "schemaVersion": 1,
  "goal": "verify blackfriday.Run 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": [
    "blackfriday.Run"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}

Seeder de origen

anónimo