Exemple
markdown-it 14.3.1: markdownit
Échantillon vérifié pour npm markdown-it 14.3.1: markdownit. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.
sha256:b73d7340e3686e36235b3993b01bee078aa93ab35bc6a48b7dae90edb406d9e7
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-19 |
Cas
HOW- Objectif
- verify markdownit in pkg:npm/markdown-it@14.3.1
- Paquets
- Symboles
-
- markdownit
- Environnement
- node 22.23.2
- Créé
- 2026-09-17T22:14:15Z
Contrat
- markdownit initializes as a parser function returning an instance with render and parse methods
- markdownit render converts markdown headings and paragraphs into standard HTML output
- markdownit render converts inline bold and italic formatting to strong and em tags
- markdownit renderInline renders inline markdown formatting without wrapping block tags
- markdownit parse produces structured syntax tokens for blocks and inline elements
- markdownit accepts configuration options such as html and linkify to control parsing behavior
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Code 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 markdownit in pkg:npm/markdown-it@14.3.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/markdown-it@14.3.1
Demonstrate these symbols/APIs:
- markdownit
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:cffaab59c70548297f6b07ca916d9949e9a30e2231fc62f2268232a4486539b8","contract":["markdownit initializes as a parser function returning an instance with render and parse methods","markdownit render converts markdown headings and paragraphs into standard HTML output","markdownit render converts inline bold and italic formatting to strong and em tags","markdownit renderInline renders inline markdown formatting without wrapping block tags","markdownit parse produces structured syntax tokens for blocks and inline elements","markdownit accepts configuration options such as html and linkify to control parsing behavior"],"goal":"verify markdownit in pkg:npm/markdown-it@14.3.1","kind":"HOW","packages":["pkg:npm/markdown-it@14.3.1"],"schemaVersion":1,"symbols":["markdownit"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/markdown-it@14.3.1"],"schemaVersion":1,"subject":"pkg:npm/markdown-it@14.3.1","symbols":["markdownit"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-markdown-it",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-markdown-it",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"markdown-it": "14.3.1"
}
},
"node_modules/argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"license": "Python-2.0"
},
"node_modules/entities": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
"integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=0.12"
},
"funding": {
"url": "https://github.com/fb55/entities?sponsor=1"
}
},
"node_modules/linkify-it": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.2.tgz",
"integrity": "sha512-ONTm2jCMAVZjgQa/Fy1kScXsuOoF5NPTsoFBdE1KVIZ2vAh/r9+Bqo+0jINCBYnavTPQZz38QzFTme79ENoN3Q==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/puzrin"
},
{
"type": "github",
"url": "https://github.com/sponsors/markdown-it"
}
],
"license": "MIT",
"dependencies": {
"uc.micro": "^2.0.0"
}
},
"node_modules/markdown-it": {
"version": "14.3.1",
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.3.1.tgz",
"integrity": "sha512-4Ej49aYTDFIQ+uBkfX8GBvJGccoARxxPep+7aWTs55ozbjQJpW9M26Fe53vnGgvLeVzva/amzjQQaQu9w0vMhA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/puzrin"
},
{
"type": "github",
"url": "https://github.com/sponsors/markdown-it"
}
],
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1",
"entities": "^4.5.0",
"linkify-it": "^5.0.2",
"mdurl": "^2.0.0",
"punycode.js": "^2.3.1",
"uc.micro": "^2.1.0"
},
"bin": {
"markdown-it": "bin/markdown-it.mjs"
}
},
"node_modules/mdurl": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.1.0.tgz",
"integrity": "sha512-1+HBaOx0zi/dQWht8rNv9MYf9qqpqL/kxI0hXImU6Y547zM6Sni8BQibt7ifgMcYtQg41ao3Ivd6cnSM86inpg==",
"license": "MIT"
},
"node_modules/punycode.js": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz",
"integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/uc.micro": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz",
"integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==",
"license": "MIT"
}
}
}
{
"name": "sample-markdown-it",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of markdown-it",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"markdown-it": "14.3.1"
}
}
{
"schemaVersion": 1,
"goal": "verify markdownit in pkg:npm/markdown-it@14.3.1",
"kind": "HOW",
"packages": [
"pkg:npm/markdown-it@14.3.1"
],
"symbols": [
"markdownit"
]
}
const markdownit = require('markdown-it');
/**
* Creates a configured markdown-it instance.
*
* @param {object} [options] - markdown-it configuration options.
* @returns {object} Configured markdown-it instance.
*/
function createParser(options = {}) {
return markdownit(options);
}
/**
* Renders full markdown source into an HTML string.
*
* @param {string} source - Markdown input.
* @param {object} [options] - Optional parser settings.
* @returns {string} Rendered HTML.
*/
function renderMarkdown(source, options = {}) {
const md = createParser(options);
return md.render(source);
}
/**
* Renders inline markdown elements without wrapping paragraph tags.
*
* @param {string} source - Markdown input.
* @param {object} [options] - Optional parser settings.
* @returns {string} Rendered HTML snippet.
*/
function renderInlineMarkdown(source, options = {}) {
const md = createParser(options);
return md.renderInline(source);
}
/**
* Parses markdown into an array of token objects.
*
* @param {string} source - Markdown input.
* @param {object} [options] - Optional parser settings.
* @returns {Array<object>} Parsed token stream.
*/
function parseTokens(source, options = {}) {
const md = createParser(options);
return md.parse(source, {});
}
module.exports = {
markdownit,
createParser,
renderMarkdown,
renderInlineMarkdown,
parseTokens,
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const {
markdownit,
createParser,
renderMarkdown,
renderInlineMarkdown,
parseTokens,
} = require('../src/index.js');
async function runContract() {
// 1. markdownit initializes as a parser function returning an instance with render and parse methods
assert.strictEqual(typeof markdownit, 'function');
const mdDefault = markdownit();
assert.strictEqual(typeof mdDefault.render, 'function');
assert.strictEqual(typeof mdDefault.renderInline, 'function');
assert.strictEqual(typeof mdDefault.parse, 'function');
// 2. markdownit render converts markdown headings and paragraphs into standard HTML output
const headingAndPara = '# Hello World\n\nThis is a sample paragraph.';
const renderedDoc = renderMarkdown(headingAndPara);
assert.strictEqual(renderedDoc, '<h1>Hello World</h1>\n<p>This is a sample paragraph.</p>\n');
// 3. markdownit render converts inline bold and italic formatting to strong and em tags
const styledText = '**bold text** and *italic text*';
const renderedStyled = renderMarkdown(styledText);
assert.strictEqual(renderedStyled, '<p><strong>bold text</strong> and <em>italic text</em></p>\n');
// 4. markdownit renderInline renders inline markdown formatting without wrapping block tags
const inlineOnly = renderInlineMarkdown('**emphasized** snippet');
assert.strictEqual(inlineOnly, '<strong>emphasized</strong> snippet');
// 5. markdownit parse produces structured syntax tokens for blocks and inline elements
const tokens = parseTokens('# Title\n\nContent');
assert.ok(Array.isArray(tokens));
assert.ok(tokens.length >= 3);
assert.strictEqual(tokens[0].type, 'heading_open');
assert.strictEqual(tokens[0].tag, 'h1');
assert.strictEqual(tokens[1].type, 'inline');
assert.strictEqual(tokens[1].content, 'Title');
assert.strictEqual(tokens[2].type, 'heading_close');
assert.strictEqual(tokens[2].tag, 'h1');
// 6. markdownit accepts configuration options such as html and linkify to control parsing behavior
const rawHtml = '<div>custom html</div>';
const defaultEscape = renderMarkdown(rawHtml);
assert.strictEqual(defaultEscape, '<p><div>custom html</div></p>\n');
const mdWithHtml = createParser({ html: true });
const renderedWithHtml = mdWithHtml.render(rawHtml);
assert.strictEqual(renderedWithHtml, '<div>custom html</div>');
console.log('All contract assertions passed successfully.');
}
runContract().catch((err) => {
console.error('Contract test failed:', err);
process.exit(1);
});
Seeder d'origine
anonyme