markup-carve / carve-php
PHP parser for Carve, a human-centered lightweight markup language derived from Markdown and Djot.
Fund package maintenance!
Requires
- php: ^8.2
Requires (Dev)
- brianium/paratest: ^7.8
- nikic/php-fuzzer: ^0.0.11
- php-collective/code-sniffer: ^0.6.8
- phpstan/phpstan: ^2.1.32
- phpunit/phpunit: ^11.0 || ^12.0 || ^13.0
Suggests
- ext-intl: Recommended for heading-ID transliteration: enables ICU romanization of non-Latin scripts (e.g. CJK, Arabic). Without it, a baked map covers Latin/Cyrillic/punctuation identically and other scripts fall back to the generated `section` id.
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 0.1.9
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- 0.1.0-RC1
- dev-fix/ast-unicode-annotation-contract
- dev-fix/2466-forwarded-marker-column-s1e59760e
- dev-fix-2333-directive-children
- dev-fix-2461-continuation-marker
- dev-automation/bump-spec
- dev-fix-2459-empty-title-on-the-wire
- dev-move-2456-entry-1e59760e
- dev-changelog-envelope-1e59760e
- dev-feat/ast-editor-sidecars-patches
- dev-fix-guards-trustworthy-1e59760e
- dev-feat/ast-envelope-1790373352
- dev-chore/spec-pin-34e9333-specpin
- dev-docs/cite-2448-1e59760e
- dev-fix/2446-md-list-continuation
- dev-docs/2440-2443-changelog-1e59760e
- dev-fix/2439-soft-break-boundaries
- dev-fix/2442-comment-content
- dev-chore/cut-0.1.10-notes
- dev-fix/2062-ordered-task-row-message
- dev-fix/2431-blank-break-row
- dev-fix/2432-cell-list-text
- dev-docs/encoding-assumed-code-name-s1e59760e
- dev-fix/document-raw-report
- dev-fix/2360-trusted-source-report
- dev-fix/2385-break-separator-every-block
- dev-fix/2403-cpu-scaling-guard
- dev-fix/2360-raw-keep-identity
- dev-fix/2388-cell-flatten-report
- dev-fix/2369-diagnostic-cap
- dev-fix/2397-quoted-title-backslash
- dev-fix/2397-quoted-title-written-once
- dev-fix/2389-kept-mathml-report
- dev-fix/2384-2385-markdown-import-format
- dev-lane/2270-divergence-reason-kinds
- dev-fix/2396-generated-toc-indent
- dev-chore/pin-spec-main-s1e59760e
- dev-fix/2414-references-placement-lint
- dev-fix/p11047-every-paragraph-interrupter
- dev-fix/task-item-import-readings-s1e59760e
- dev-style/readability-audit
- dev-fix/2288-empty-ordered-task-report
- dev-fix/2400-opaque-json-objects
- dev-fix/2399-prosemirror-map-contract
- dev-fix/2380-markdown-list-tightness
- dev-docs/2372-placement-wording
- dev-fix/2347-prosemirror-schema-map
- dev-fix/2375-quoted-title-double-quote
- dev-fix/2372-footnotes-marker-top-level-only
- dev-fix/2368-style-refusal-in-kept-bytes
- dev-fix-2365-followup-row-run
- dev-lane/2284b
- dev-fix-2366-task-checkbox-scope
- dev-fix-2365-closed-row-no-paragraph
- dev-lane/2371
- dev-fix/2330-directive-title-wire-pin
- dev-docs/prose-quality-pass-1e59760e
- dev-fix/2362-raw-region-in-a-table-cell
- dev-fix/2356-tilde-fence-behind-a-task-checkbox
- dev-fix/2359-closed-pipe-row-under-open-paragraph
- dev-fix/prosemirror-definition-nodes
- dev-fix/2355-quoted-item-quoted-setext-fold
- dev-fix/2261-raw-keep-report-reads-the-output
- dev-fix/2340-keep-an-interrupting-marker-interrupting
- dev-fix/2345-directive-title-placement
- dev-fix/2349-delimiter-row-needs-a-pipe
- dev-next
This package is auto-updated.
Last update: 2026-09-26 01:41:34 UTC
README
PHP parser and renderer for Carve, a lightweight markup language for readable source and structured documents.
Implements Carve spec 0.1 (see Versioning & Changelog).
Installation
composer require markup-carve/carve-php
Usage
use MarkupCarve\Carve\CarveConverter; $converter = new CarveConverter(); $html = $converter->convert('# Hello /Carve/');
The HTML, Markdown, Djot and BBCode importers return a versioned
migration-fidelity report from each converter's convertWithFidelityReport()
method. One preserved / normalized / degraded / dropped vocabulary spans
all four, with format-specific diagnostic codes underneath. The report envelope
and the --check-loss gate are in docs/cli.md;
HTML also has a detailed import report, in docs/html-import.md.
Besides HTML the converter renders Markdown, plain text and ANSI. The Markdown writer's options are in docs/markdown-output.md, and every node can carry its source line - docs/source-lines.md.
A document can pull in other files with {{ chapter.crv }}. It is opt-in and
off by default - the core parser performs no file I/O - and the resolver you
supply is the security boundary: docs/includes.md.
Source-aware tools can prepare stale-safe structured formatting changes through
CarveConverter::toCarvePatch(); see the
source-preserving patch guide.
CLI
vendor/bin/carve README.crv > README.html # render (HTML by default) vendor/bin/carve --markdown README.crv # or --plain, --ansi, --json vendor/bin/carve lint README.crv # report problems, change nothing vendor/bin/carve migrate --from html p.html # convert into Carve
Every subcommand and flag is in docs/cli.md.
Sandbox
Try this implementation live in the Carve sandbox - explore syntax and extensions, inspect output, and share snippets via pastebin-style links. It also powers the wp-carve WordPress plugin.
ProseMirror / Tiptap
The AST converts to a ProseMirror document and back, so a Tiptap editor in the browser and PHP rendering on the server share one source of truth with no Node runtime. See docs/prosemirror.md.
Untrusted input
Rendering attacker-controlled Carve needs the safe path, which escapes raw HTML instead of emitting it and bounds nesting depth. The threat model, the defaults and the full checklist are in docs/security.md.
Linting
carve lint reports constructs that parse but render differently from what
the author intended. The rules and options are in docs/lint.md.
Documentation
- Importing HTML - the loss report and the diagnostic path locator.
- Extensions - the extension set, and writing a parse-stage matcher.
- Command line - every subcommand and flag.
- Untrusted input - the threat model and the safe path.
- Linting - the lint rules and options.
- Markdown output - the Markdown writer's options.
- Source-line tracking - carrying source positions on the AST.
- Source-preserving patches - stale-safe UTF-8 edits.
- Stored documents - spec versions and stored content.
- ProseMirror / Tiptap - editor interchange.
- AST JSON - the interchange format.
- Integrated definition layout - collecting and resolving reference, footnote and abbreviation definitions.
- Configured conversion fast path - reusing a configured converter.
Development
Local setup, the test suites, the style and static-analysis gates, and the rules for a spec-affecting change are in CONTRIBUTING.md.