CodeSampleX

Exemple

prosemirror-markdown 1.13.7: schema

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

sha256:26104d868d8ed583af77f1d56844ac531ab7fbbb39f3027ad98ec4d0f819dddc

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-15

Cas

HOW
Objectif
verify prosemirror-markdown.schema in pkg:npm/prosemirror-markdown@1.13.7
Paquets
Symboles
  • prosemirror-markdown.schema
Créé
2026-09-15T08:11:01Z

Contrat

  1. schema is an instance of Schema from prosemirror-model configured for CommonMark markdown
  2. schema defines standard CommonMark block nodes: doc, paragraph, blockquote, horizontal_rule, heading, and code_block
  3. schema defines standard CommonMark inline nodes: text, image, and hard_break
  4. schema defines standard CommonMark list nodes: ordered_list, bullet_list, and list_item
  5. schema defines standard CommonMark mark types: em, strong, link, and code
  6. schema creates and validates conforming ProseMirror document trees while rejecting invalid structures and marks

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 prosemirror-markdown.schema in pkg:npm/prosemirror-markdown@1.13.7
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/prosemirror-markdown@1.13.7
Demonstrate these symbols/APIs:
  - prosemirror-markdown.schema

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:a2944ec1b36e379ba42fae6fc21965b7beca997e7ee979df08b01dda169d562d","contract":["schema is an instance of Schema from prosemirror-model configured for CommonMark markdown","schema defines standard CommonMark block nodes: doc, paragraph, blockquote, horizontal_rule, heading, and code_block","schema defines standard CommonMark inline nodes: text, image, and hard_break","schema defines standard CommonMark list nodes: ordered_list, bullet_list, and list_item","schema defines standard CommonMark mark types: em, strong, link, and code","schema creates and validates conforming ProseMirror document trees while rejecting invalid structures and marks"],"goal":"verify prosemirror-markdown.schema in pkg:npm/prosemirror-markdown@1.13.7","kind":"HOW","packages":["pkg:npm/prosemirror-markdown@1.13.7"],"schemaVersion":1,"symbols":["prosemirror-markdown.schema"]},"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/prosemirror-markdown@1.13.7"],"schemaVersion":1,"subject":"pkg:npm/prosemirror-markdown@1.13.7","symbols":["prosemirror-markdown.schema"],"verifierAdapter":"node-typescript@1"}
index.mjs
import { schema } from 'prosemirror-markdown';

/**
 * Returns the CommonMark ProseMirror schema defined by prosemirror-markdown.
 *
 * @returns {import('prosemirror-model').Schema} The CommonMark schema instance.
 */
export function getMarkdownSchema() {
  return schema;
}

/**
 * Creates a ProseMirror document node adhering to the markdown schema.
 *
 * @param {Array<import('prosemirror-model').Node>} content - Child block nodes.
 * @returns {import('prosemirror-model').Node} Validated doc node.
 */
export function createDocument(content = []) {
  const doc = schema.node('doc', null, content);
  doc.check();
  return doc;
}

/**
 * Creates a paragraph node with optional text and marks.
 *
 * @param {string} text - Paragraph text content.
 * @param {Array<import('prosemirror-model').Mark>} [marks] - Optional marks to apply.
 * @returns {import('prosemirror-model').Node} The paragraph node.
 */
export function createParagraph(text, marks = []) {
  const textNode = text ? [schema.text(text, marks)] : [];
  return schema.node('paragraph', null, textNode);
}

/**
 * Creates a heading node with a specified level and text.
 *
 * @param {number} level - Heading level (1-6).
 * @param {string} text - Heading text.
 * @returns {import('prosemirror-model').Node} The heading node.
 */
export function createHeading(level, text) {
  const textNode = text ? [schema.text(text)] : [];
  return schema.node('heading', { level }, textNode);
}

export { schema };

export default {
  schema,
  getMarkdownSchema,
  createDocument,
  createParagraph,
  createHeading,
};
package-lock.json
{
  "name": "sample-prosemirror-markdown-schema",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-prosemirror-markdown-schema",
      "version": "1.0.0",
      "dependencies": {
        "prosemirror-markdown": "1.13.7"
      }
    },
    "node_modules/@types/linkify-it": {
      "version": "5.0.0",
      "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz",
      "integrity": "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==",
      "license": "MIT"
    },
    "node_modules/@types/markdown-it": {
      "version": "14.2.0",
      "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-14.2.0.tgz",
      "integrity": "sha512-NoQ2yGlLWj4wpxMs+TYmRKk3thDrQ97agr7sFqfLsAlvoS8SNQuTrlObhFqG9iugdTtgOE9jpJ6FNM4ZGsa5xQ==",
      "license": "MIT",
      "dependencies": {
        "@types/linkify-it": "^5",
        "@types/mdurl": "^2"
      }
    },
    "node_modules/@types/mdurl": {
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-2.0.0.tgz",
      "integrity": "sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg==",
      "license": "MIT"
    },
    "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.2",
      "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.3.2.tgz",
      "integrity": "sha512-sHHjZ5fJKlgrG4qns2YwVcdNep35h5fERrfkD2YNsb9UFk0UIHarbiTaHKVMlPuWAoiilyK8Fv/jAm11slsY7Q==",
      "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/orderedmap": {
      "version": "2.1.1",
      "resolved": "https://registry.npmjs.org/orderedmap/-/orderedmap-2.1.1.tgz",
      "integrity": "sha512-TvAWxi0nDe1j/rtMcWcIj94+Ffe6n7zhow33h40SKxmsmozs6dz/e+EajymfoFcHd7sxNn8yHM8839uixMOV6g==",
      "license": "MIT"
    },
    "node_modules/prosemirror-markdown": {
      "version": "1.13.7",
      "resolved": "https://registry.npmjs.org/prosemirror-markdown/-/prosemirror-markdown-1.13.7.tgz",
      "integrity": "sha512-NV57Oxe3fXR+bNGXS5XW4sKt/XGIyY3n0eHVUoJORcismeF4FFMpLBnl0YESy2BvJQHloexX+9P+zT3VqFj/CQ==",
      "license": "MIT",
      "dependencies": {
        "@types/markdown-it": "^14.0.0",
        "markdown-it": "^14.0.0",
        "prosemirror-model": "^1.25.0"
      }
    },
    "node_modules/prosemirror-model": {
      "version": "1.25.11",
      "resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.25.11.tgz",
      "integrity": "sha512-QWg9RhnpLlogAmp3p96uEFrE5txQpFynd4vhBAELkwgOCWQs/X0yCzB3/hrHqiPwf91RG5KyWq6553zs9JqIOQ==",
      "license": "MIT",
      "dependencies": {
        "orderedmap": "^2.0.0"
      }
    },
    "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-prosemirror-markdown-schema",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "prosemirror-markdown": "1.13.7"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify prosemirror-markdown.schema in pkg:npm/prosemirror-markdown@1.13.7",
  "kind": "HOW",
  "packages": [
    "pkg:npm/prosemirror-markdown@1.13.7"
  ],
  "symbols": [
    "prosemirror-markdown.schema"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import {
  schema,
  getMarkdownSchema,
  createDocument,
  createParagraph,
  createHeading,
} from '../index.mjs';

// 1. schema is an instance of Schema from prosemirror-model configured for CommonMark markdown
{
  assert.ok(schema, 'schema must be defined');
  assert.strictEqual(getMarkdownSchema(), schema, 'getMarkdownSchema must return the schema');
  assert.ok(schema.nodes, 'schema.nodes must be defined');
  assert.ok(schema.marks, 'schema.marks must be defined');
  assert.ok(schema.spec, 'schema.spec must be defined');
  assert.strictEqual(schema.topNodeType, schema.nodes.doc, 'Top-level node type must be doc');
}

// 2. schema defines standard CommonMark block nodes: doc, paragraph, blockquote, horizontal_rule, heading, and code_block
{
  assert.ok(schema.nodes.doc, 'schema must define doc');
  assert.ok(schema.nodes.paragraph, 'schema must define paragraph');
  assert.strictEqual(schema.nodes.paragraph.isBlock, true, 'paragraph must be a block node');
  assert.strictEqual(schema.nodes.paragraph.isTextblock, true, 'paragraph must be a textblock');

  assert.ok(schema.nodes.blockquote, 'schema must define blockquote');
  assert.strictEqual(schema.nodes.blockquote.isBlock, true, 'blockquote must be a block node');

  assert.ok(schema.nodes.horizontal_rule, 'schema must define horizontal_rule');
  assert.strictEqual(schema.nodes.horizontal_rule.isBlock, true, 'horizontal_rule must be a block node');

  assert.ok(schema.nodes.heading, 'schema must define heading');
  assert.strictEqual(schema.nodes.heading.isBlock, true, 'heading must be a block node');
  const h2 = createHeading(2, 'Heading 2');
  assert.strictEqual(h2.attrs.level, 2);
  assert.strictEqual(h2.textContent, 'Heading 2');

  assert.ok(schema.nodes.code_block, 'schema must define code_block');
  assert.strictEqual(schema.nodes.code_block.isBlock, true, 'code_block must be a block node');
  assert.strictEqual(schema.nodes.code_block.isTextblock, true, 'code_block must be a textblock');
  const cb = schema.node('code_block', { params: 'javascript' }, [schema.text('const x = 1;')]);
  assert.strictEqual(cb.attrs.params, 'javascript');
}

// 3. schema defines standard CommonMark inline nodes: text, image, and hard_break
{
  assert.ok(schema.nodes.text, 'schema must define text');
  assert.strictEqual(schema.nodes.text.isInline, true, 'text must be an inline node');
  assert.strictEqual(schema.nodes.text.isText, true, 'text.isText must be true');

  assert.ok(schema.nodes.image, 'schema must define image');
  assert.strictEqual(schema.nodes.image.isInline, true, 'image must be an inline node');
  assert.strictEqual(schema.nodes.image.isBlock, false, 'image must not be a block node');
  const img = schema.node('image', { src: 'https://example.com/pic.png', alt: 'Alt text', title: 'Image Title' });
  assert.strictEqual(img.attrs.src, 'https://example.com/pic.png');
  assert.strictEqual(img.attrs.alt, 'Alt text');
  assert.strictEqual(img.attrs.title, 'Image Title');

  assert.ok(schema.nodes.hard_break, 'schema must define hard_break');
  assert.strictEqual(schema.nodes.hard_break.isInline, true, 'hard_break must be an inline node');
  assert.strictEqual(schema.nodes.hard_break.spec.selectable, false, 'hard_break must be non-selectable');
}

// 4. schema defines standard CommonMark list nodes: ordered_list, bullet_list, and list_item
{
  assert.ok(schema.nodes.ordered_list, 'schema must define ordered_list');
  assert.ok(schema.nodes.bullet_list, 'schema must define bullet_list');
  assert.ok(schema.nodes.list_item, 'schema must define list_item');

  const item1 = schema.node('list_item', null, [createParagraph('First item')]);
  const item2 = schema.node('list_item', null, [createParagraph('Second item')]);

  const bulletList = schema.node('bullet_list', null, [item1, item2]);
  assert.strictEqual(bulletList.childCount, 2);
  assert.strictEqual(bulletList.type.name, 'bullet_list');

  const orderedList = schema.node('ordered_list', { order: 1 }, [item1, item2]);
  assert.strictEqual(orderedList.childCount, 2);
  assert.strictEqual(orderedList.attrs.order, 1);
}

// 5. schema defines standard CommonMark mark types: em, strong, link, and code
{
  assert.ok(schema.marks.em, 'schema must define em mark');
  assert.ok(schema.marks.strong, 'schema must define strong mark');
  assert.ok(schema.marks.link, 'schema must define link mark');
  assert.ok(schema.marks.code, 'schema must define code mark');

  const emMark = schema.mark('em');
  const strongMark = schema.mark('strong');
  const codeMark = schema.mark('code');
  const linkMark = schema.mark('link', { href: 'https://example.com', title: 'Example Site' });

  assert.strictEqual(emMark.type.name, 'em');
  assert.strictEqual(strongMark.type.name, 'strong');
  assert.strictEqual(codeMark.type.name, 'code');
  assert.strictEqual(linkMark.type.name, 'link');
  assert.strictEqual(linkMark.attrs.href, 'https://example.com');
  assert.strictEqual(linkMark.attrs.title, 'Example Site');
  assert.strictEqual(schema.marks.link.spec.inclusive, false, 'link mark must be non-inclusive');

  const markedText = schema.text('styled link text', [strongMark, linkMark]);
  assert.strictEqual(markedText.marks.length, 2);
}

// 6. schema creates and validates conforming ProseMirror document trees while rejecting invalid structures and marks
{
  const p1 = schema.node('paragraph', null, [
    schema.text('Normal text, '),
    schema.text('bold text', [schema.mark('strong')]),
    schema.node('hard_break'),
    schema.text('and a link', [schema.mark('link', { href: 'https://example.com' })]),
  ]);
  const h1 = createHeading(1, 'Sample Title');
  const bq = schema.node('blockquote', null, [createParagraph('Quoted text')]);
  const code = schema.node('code_block', { params: 'typescript' }, [schema.text('const num: number = 42;')]);
  const hr = schema.node('horizontal_rule');
  const list = schema.node('bullet_list', null, [
    schema.node('list_item', null, [createParagraph('Bullet entry')]),
  ]);

  const doc = createDocument([h1, p1, bq, code, hr, list]);
  assert.strictEqual(doc.type.name, 'doc');
  assert.strictEqual(doc.childCount, 6);

  // Assert invalid top-level content (bare inline text in doc) throws RangeError
  assert.throws(() => {
    schema.node('doc', null, [schema.text('bare text without block wrapper')]).check();
  }, (err) => err instanceof RangeError && err.message.includes('Invalid content for node doc'));

  // Assert disallowed marks inside code_block throws RangeError
  assert.throws(() => {
    schema.node('code_block', null, [schema.text('marked code', [schema.mark('strong')])]).check();
  }, (err) => err instanceof RangeError && err.message.includes('Invalid content for node code_block'));
}

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

Seeder d'origine

anonyme