サンプル
github.com/russross/blackfriday/v2 v2.1.0: blackfriday.Run
検証済みサンプル — golang github.com/russross/blackfriday/v2 v2.1.0: blackfriday.Run. go 1.26 · linux debian/x64 · docker で contract を実行し、成功しました.
sha256:75d693324904db2f672734f0c381392e7a8e81b034887e8c428171f9b4088979
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
go linux 24 · ubuntu · glibc 2.39 x64 go go go
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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 |
ケース
HOW- ゴール
- verify blackfriday.Run in pkg:golang/github.com/russross/blackfriday/v2@v2.1.0
- シンボル
-
- blackfriday.Run
- 環境
- go
- 作成日
- 2026-09-02T07:49:44Z
コントラクト
- 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.
ファイル
- NOTES.md
- PROMPT.md
- blackfriday_test.go
- csx.json
- go.mod
- go.sum
- spec.json
ソース
# 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.
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.
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))
}
}
{"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"}
module example.com/blackfridaydemo
go 1.23
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=
{
"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"
}
}
オリジンシーダー
匿名