CodeSampleX

Exemple

markdown-it 14.3.1

Échantillon vérifié pour npm markdown-it 14.3.1. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.

sha256:21bfca448a81bcec7fc1e6b4309fc4779e9e9b70a166ba3a14d4efec36e50924

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é linux 24 · ubuntu · glibc 2.39 x64 npm

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 pkg:npm/markdown-it@14.3.1
Paquets
Créé
2026-09-17T21:46:58Z

Contrat

  1. MarkdownIt is exported and can be instantiated with default options
  2. MarkdownIt.render converts headings, paragraphs, lists, and inline formatting into HTML
  3. MarkdownIt.renderInline converts inline formatting without wrapping in block elements
  4. MarkdownIt respects configuration options such as html, linkify, and breaks
  5. MarkdownIt.use allows plugin registration and custom token rule extensions

Fichiers

  • PROMPT.md
  • csx.json
  • index.mjs
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Télécharger l’artefact source (tar.gz)

Code source

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 pkg:npm/markdown-it@14.3.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/markdown-it@14.3.1

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:7662b52b89eec92853f0bb2702f4cd2ec4706459de2126ae73ada5c06a80aede","contract":["MarkdownIt is exported and can be instantiated with default options","MarkdownIt.render converts headings, paragraphs, lists, and inline formatting into HTML","MarkdownIt.renderInline converts inline formatting without wrapping in block elements","MarkdownIt respects configuration options such as html, linkify, and breaks","MarkdownIt.use allows plugin registration and custom token rule extensions"],"goal":"verify pkg:npm/markdown-it@14.3.1","kind":"HOW","packages":["pkg:npm/markdown-it@14.3.1"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/markdown-it@14.3.1"],"schemaVersion":1,"subject":"pkg:npm/markdown-it@14.3.1","verifierAdapter":"node-typescript@1"}
index.mjs
import MarkdownIt from 'markdown-it';

/**
 * Creates a configured MarkdownIt instance.
 *
 * @param {Object} [options] - MarkdownIt configuration options.
 * @returns {MarkdownIt} Instance of MarkdownIt.
 */
export function createRenderer(options) {
  return new MarkdownIt(options);
}

/**
 * Renders a Markdown string to an HTML block.
 *
 * @param {string} source - Markdown text to render.
 * @param {Object} [options] - MarkdownIt configuration options.
 * @returns {string} Rendered HTML string.
 */
export function renderMarkdown(source, options) {
  const md = new MarkdownIt(options);
  return md.render(source);
}

/**
 * Renders an inline Markdown string to HTML without block-level wrapper tags.
 *
 * @param {string} source - Inline markdown text to render.
 * @param {Object} [options] - MarkdownIt configuration options.
 * @returns {string} Rendered HTML string.
 */
export function renderInlineMarkdown(source, options) {
  const md = new MarkdownIt(options);
  return md.renderInline(source);
}

export default MarkdownIt;
package-lock.json
{
  "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"
    }
  }
}
package.json
{
  "name": "sample-markdown-it",
  "version": "1.0.0",
  "type": "module",
  "description": "Clean-room sample verifying pkg:npm/markdown-it@14.3.1 functionality",
  "main": "index.mjs",
  "license": "MIT-0",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "markdown-it": "14.3.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/markdown-it@14.3.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/markdown-it@14.3.1"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import MarkdownIt, { createRenderer, renderMarkdown, renderInlineMarkdown } from '../index.mjs';

// 1. MarkdownIt is exported and can be instantiated with default options
const mdDefault = createRenderer();
assert.equal(typeof MarkdownIt, 'function');
assert.ok(mdDefault instanceof MarkdownIt);
assert.equal(typeof mdDefault.render, 'function');
assert.equal(typeof mdDefault.renderInline, 'function');

// 2. MarkdownIt.render converts headings, paragraphs, lists, and inline formatting into HTML
const headingHtml = renderMarkdown('# Hello World');
assert.equal(headingHtml, '<h1>Hello World</h1>\n');

const paragraphHtml = renderMarkdown('This is **bold** and *italic*.');
assert.equal(paragraphHtml, '<p>This is <strong>bold</strong> and <em>italic</em>.</p>\n');

const listMarkdown = '- item 1\n- item 2\n';
const listHtml = renderMarkdown(listMarkdown);
assert.equal(listHtml, '<ul>\n<li>item 1</li>\n<li>item 2</li>\n</ul>\n');

const codeMarkdown = '```js\nconsole.log(42);\n```';
const codeHtml = renderMarkdown(codeMarkdown);
assert.ok(codeHtml.includes('<pre><code class="language-js">console.log(42);\n</code></pre>\n'));

// 3. MarkdownIt.renderInline converts inline formatting without wrapping in block elements
const inlineBold = renderInlineMarkdown('**inline bold**');
assert.equal(inlineBold, '<strong>inline bold</strong>');

const inlineCode = renderInlineMarkdown('`inline code`');
assert.equal(inlineCode, '<code>inline code</code>');

assert.ok(!inlineBold.startsWith('<p>') && !inlineBold.endsWith('</p>\n'));

// 4. MarkdownIt respects configuration options such as html, linkify, and breaks
const mdNoHtml = createRenderer({ html: false });
assert.equal(mdNoHtml.render('<div>safe</div>'), '<p>&lt;div&gt;safe&lt;/div&gt;</p>\n');

const mdHtml = createRenderer({ html: true });
assert.equal(mdHtml.render('<div>raw</div>'), '<div>raw</div>');

const mdLinkify = createRenderer({ linkify: true });
assert.equal(
  mdLinkify.render('Visit https://example.com for info.'),
  '<p>Visit <a href="https://example.com">https://example.com</a> for info.</p>\n'
);

const mdBreaks = createRenderer({ breaks: true });
assert.equal(mdBreaks.render('first line\nsecond line'), '<p>first line<br>\nsecond line</p>\n');

// 5. MarkdownIt.use allows plugin registration and custom token rule extensions
const customPlugin = md => {
  md.core.ruler.push('test_plugin', state => {
    state.env.pluginApplied = true;
  });
};

const mdPlugin = createRenderer();
mdPlugin.use(customPlugin);
const env = {};
mdPlugin.render('Testing plugin', env);
assert.equal(env.pluginApplied, true);

console.log('All markdown-it contract assertions passed.');

Seeder d'origine

anonyme