CodeSampleX

Beispiel

prosemirror-markdown 1.13.7

Verifiziertes Beispiel für npm prosemirror-markdown 1.13.7. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.

sha256:836c7f7ec78cd3c00858c28d5ad1bf1afed5795cf60498147d90179c19963fda

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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

Fall

HOW
Ziel
verify pkg:npm/prosemirror-markdown@1.13.7
Pakete
Erstellt
2026-09-15T03:03:13Z

Contract

  1. assert defaultMarkdownParser parses markdown headings and paragraphs into schema-conforming ProseMirror document nodes
  2. assert defaultMarkdownParser parses inline formatting marks including strong, em, and inline code
  3. assert defaultMarkdownParser parses blockquotes and lists into nested ProseMirror document structures
  4. assert defaultMarkdownSerializer serializes ProseMirror document nodes back to markdown strings
  5. assert defaultMarkdownSerializer round-trips markdown formatting for headings, paragraphs, and inline marks
  6. assert schema defines standard CommonMark nodes and marks for markdown document representation

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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/prosemirror-markdown@1.13.7
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/prosemirror-markdown@1.13.7

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:e112880139ce6c2180f82df715af07c00856c50f89c0be2b3ce3449db81f342a","contract":["assert defaultMarkdownParser parses markdown headings and paragraphs into schema-conforming ProseMirror document nodes","assert defaultMarkdownParser parses inline formatting marks including strong, em, and inline code","assert defaultMarkdownParser parses blockquotes and lists into nested ProseMirror document structures","assert defaultMarkdownSerializer serializes ProseMirror document nodes back to markdown strings","assert defaultMarkdownSerializer round-trips markdown formatting for headings, paragraphs, and inline marks","assert schema defines standard CommonMark nodes and marks for markdown document representation"],"goal":"verify pkg:npm/prosemirror-markdown@1.13.7","kind":"HOW","packages":["pkg:npm/prosemirror-markdown@1.13.7"],"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/prosemirror-markdown@1.13.7"],"schemaVersion":1,"subject":"pkg:npm/prosemirror-markdown@1.13.7","verifierAdapter":"node-typescript@1"}
index.mjs
import {
  defaultMarkdownParser,
  defaultMarkdownSerializer,
  schema,
  MarkdownParser,
  MarkdownSerializer,
  MarkdownSerializerState,
} from 'prosemirror-markdown';

/**
 * Parses markdown text into a ProseMirror Node using the default CommonMark parser.
 *
 * @param {string} markdown - The markdown string to parse.
 * @returns {import('prosemirror-model').Node} The parsed ProseMirror document node.
 */
export function parseMarkdown(markdown) {
  return defaultMarkdownParser.parse(markdown);
}

/**
 * Serializes a ProseMirror document Node into markdown text using the default serializer.
 *
 * @param {import('prosemirror-model').Node} doc - The document node to serialize.
 * @param {object} [options] - Serialization options (e.g. { tightLists: true }).
 * @returns {string} The serialized markdown string.
 */
export function serializeToMarkdown(doc, options) {
  return defaultMarkdownSerializer.serialize(doc, options);
}

export {
  defaultMarkdownParser,
  defaultMarkdownSerializer,
  schema,
  MarkdownParser,
  MarkdownSerializer,
  MarkdownSerializerState,
};

export default {
  parseMarkdown,
  serializeToMarkdown,
  defaultMarkdownParser,
  defaultMarkdownSerializer,
  schema,
};
package-lock.json
{
  "name": "sample-prosemirror-markdown-verify",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-prosemirror-markdown-verify",
      "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-verify",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "prosemirror-markdown": "1.13.7"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/prosemirror-markdown@1.13.7",
  "kind": "HOW",
  "packages": [
    "pkg:npm/prosemirror-markdown@1.13.7"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import {
  parseMarkdown,
  serializeToMarkdown,
  defaultMarkdownParser,
  defaultMarkdownSerializer,
  schema,
  MarkdownParser,
  MarkdownSerializer,
  MarkdownSerializerState,
} from '../index.mjs';

// 1. assert defaultMarkdownParser parses markdown headings and paragraphs into schema-conforming ProseMirror document nodes
{
  const markdown = '# Main Heading\n\nThis is a standard paragraph with basic text.';
  const doc = parseMarkdown(markdown);

  assert.ok(doc, 'Parsed document should not be null');
  assert.strictEqual(doc.type.name, 'doc', 'Root node must be doc');
  assert.strictEqual(doc.childCount, 2, 'Document should have 2 children');

  const headingNode = doc.child(0);
  assert.strictEqual(headingNode.type.name, 'heading');
  assert.strictEqual(headingNode.attrs.level, 1);
  assert.strictEqual(headingNode.textContent, 'Main Heading');

  const paragraphNode = doc.child(1);
  assert.strictEqual(paragraphNode.type.name, 'paragraph');
  assert.strictEqual(paragraphNode.textContent, 'This is a standard paragraph with basic text.');
}

// 2. assert defaultMarkdownParser parses inline formatting marks including strong, em, and inline code
{
  const markdown = 'Text with **strong**, *emphasized*, and `code` spans.';
  const doc = parseMarkdown(markdown);
  const paragraph = doc.child(0);

  let hasStrong = false;
  let hasEm = false;
  let hasCode = false;

  paragraph.forEach((child) => {
    for (const mark of child.marks) {
      if (mark.type.name === 'strong' && child.text === 'strong') {
        hasStrong = true;
      }
      if (mark.type.name === 'em' && child.text === 'emphasized') {
        hasEm = true;
      }
      if (mark.type.name === 'code' && child.text === 'code') {
        hasCode = true;
      }
    }
  });

  assert.ok(hasStrong, 'Expected strong mark on text "strong"');
  assert.ok(hasEm, 'Expected em mark on text "emphasized"');
  assert.ok(hasCode, 'Expected code mark on text "code"');
}

// 3. assert defaultMarkdownParser parses blockquotes and lists into nested ProseMirror document structures
{
  const markdown = '> Blockquote line\n\n- item one\n- item two';
  const doc = parseMarkdown(markdown);

  assert.strictEqual(doc.childCount, 2);

  const blockquoteNode = doc.child(0);
  assert.strictEqual(blockquoteNode.type.name, 'blockquote');
  assert.strictEqual(blockquoteNode.child(0).type.name, 'paragraph');
  assert.strictEqual(blockquoteNode.child(0).textContent, 'Blockquote line');

  const listNode = doc.child(1);
  assert.strictEqual(listNode.type.name, 'bullet_list');
  assert.strictEqual(listNode.childCount, 2);
  assert.strictEqual(listNode.child(0).type.name, 'list_item');
  assert.strictEqual(listNode.child(0).child(0).textContent, 'item one');
  assert.strictEqual(listNode.child(1).child(0).textContent, 'item two');
}

// 4. assert defaultMarkdownSerializer serializes ProseMirror document nodes back to markdown strings
{
  const doc = parseMarkdown('# Title\n\nA simple paragraph.\n\n> Quoted text');
  const serialized = serializeToMarkdown(doc);

  assert.ok(typeof serialized === 'string');
  assert.ok(serialized.includes('# Title'), 'Serialized text must include heading');
  assert.ok(serialized.includes('A simple paragraph.'), 'Serialized text must include paragraph');
  assert.ok(serialized.includes('> Quoted text'), 'Serialized text must include blockquote');
}

// 5. assert defaultMarkdownSerializer round-trips markdown formatting for headings, paragraphs, and inline marks
{
  const original = '## Subtitle\n\nHello **world** with `inline code` and *italics*.';
  const doc1 = parseMarkdown(original);
  const serialized = serializeToMarkdown(doc1);
  const doc2 = parseMarkdown(serialized);

  assert.strictEqual(doc2.type.name, 'doc');
  assert.strictEqual(doc2.childCount, 2);
  assert.strictEqual(doc2.child(0).type.name, 'heading');
  assert.strictEqual(doc2.child(0).attrs.level, 2);
  assert.strictEqual(doc2.child(0).textContent, 'Subtitle');

  const p2 = doc2.child(1);
  assert.strictEqual(p2.type.name, 'paragraph');
  assert.strictEqual(p2.textContent, 'Hello world with inline code and italics.');
}

// 6. assert schema defines standard CommonMark nodes and marks for markdown document representation
{
  assert.ok(schema, 'CommonMark schema must be defined');
  assert.ok(schema.nodes.doc, 'schema must include doc node');
  assert.ok(schema.nodes.paragraph, 'schema must include paragraph node');
  assert.ok(schema.nodes.heading, 'schema must include heading node');
  assert.ok(schema.nodes.blockquote, 'schema must include blockquote node');
  assert.ok(schema.nodes.code_block, 'schema must include code_block node');
  assert.ok(schema.nodes.bullet_list, 'schema must include bullet_list node');
  assert.ok(schema.nodes.ordered_list, 'schema must include ordered_list node');
  assert.ok(schema.marks.em, 'schema must include em mark');
  assert.ok(schema.marks.strong, 'schema must include strong mark');
  assert.ok(schema.marks.link, 'schema must include link mark');
  assert.ok(schema.marks.code, 'schema must include code mark');
}

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

Ursprungs-Seeder

anonym