Download the PHP package markup-carve/carve-grammars without Composer
On this page you can find all versions of the php package markup-carve/carve-grammars. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download markup-carve/carve-grammars
More information about markup-carve/carve-grammars
Files in markup-carve/carve-grammars
Package carve-grammars
Short Description Syntax-highlighting grammars for the Carve markup language (TextMate grammar for Torchlight / phiki, plus Prism and highlight.js definitions)
License MIT
Homepage https://github.com/markup-carve/carve-grammars
Informations about the package carve-grammars
Carve Grammars
Grammars for the Carve markup language:
- a Tiptap integration (editor kit, Carve loader and serializer) that converts between Carve markup and Tiptap/ProseMirror JSON;
- Prism and highlight.js syntax-highlighting grammars for rendering Carve source on the web;
- a TextMate grammar (
textmate/carve.tmLanguage.json) for TextMate-based highlighters such as Shiki (used by VitePress).
Modeled on djot-grammars, adapted to Carve's syntax. The Tiptap mark mapping mirrors carve-php's HtmlToCarve converter; the highlighting grammars mirror the canonical token set in carve/resources/grammar.ebnf and the TextMate grammar in vscode-carve.
Status: Tiptap integration, plus Prism, highlight.js and TextMate grammars. Sibling editor grammars live in their own repos: editor-bundled TextMate copies in vscode-carve and intellij-carve; Tree-sitter in tree-sitter-carve and zed-carve.
Install
All peer dependencies are optional - install only what you use:
@tiptap/core + @tiptap/starter-kit (v2 or v3) for the editor, prismjs (v1)
for Prism, highlight.js (v11) for highlight.js. CI runs the suite against both
Tiptap majors.
On Tiptap 3, CarveKit disables StarterKit's bundled Underline and Link, since
it registers its own (underline carries Carve's _text_ mapping). Pass
starterKit: { underline: true } to opt back in, at the cost of a duplicate
mark name.
CarveKit also pulls in several standalone Tiptap marks/extensions (highlight,
subscript, superscript, underline, link, image, table, task-list); install the
@tiptap/extension-* packages you use, or disable them via
CarveKit.configure({ underline: false, ... }).
Usage
Individual extensions
Mark mapping
| Tiptap mark | Carve token | Renders as |
|---|---|---|
| bold | *text* / {*text*} |
<strong> |
| italic | /text/ / {/text/} |
<em> |
| underline | _text_ / {_text_} |
<u> |
| code | `text` | <code> |
|
| highlight | =text= / {=text=} |
<mark> |
| strike | ~text~ / {~text~} |
<s> |
| subscript | {,text,} (braced only) |
<sub> |
| superscript | {^text^} (braced only) |
<sup> |
| insert | {+text+} |
<ins> |
| delete | {-text-} |
<del> |
| link | [text](url) / [text](url "title") |
<a> |
| image |  /  |
<img> |
| span | [text]{.class} |
<span class> |
| abbreviation | [text]{abbr="..."} |
<abbr title> *** |
*** [text]{abbr="..."} renders a real <abbr title> only when carve's
SemanticSpanExtension is enabled (the same opt-in extension also maps {kbd}
-> <kbd>, {dfn} -> <dfn>, {samp} -> <samp>, {var} -> <var>).
Without it, the attribute stays literal: <span abbr="...">. The mark's
parseHTML reads back the <abbr title> form.
The tokens target carve-php's parser (the contract: serialized Carve must parse
back to the same elements). Carve's inline syntax differs notably from Djot's:
emphasis is /text/ (Djot uses _), _text_ is underline, ~text~ is
strikethrough, highlight is =text=, and subscript/superscript are the
braced {,text,} / {^text^} only (a bare , or ^ is literal text since
carve #259).
Each single-char delimiter has two equivalent forms: a bare form
(=text=) and a forced brace form ({=text=}) that also works intraword;
both parse to the same element. The two columns above list bare / forced.
serializeToCarve emits the bare form for * / _ ~ and the forced {…} form
for = , ^ (round-trip-safe — those delimiters are likelier to be inert bare);
{+…+} / {-…-} (insert / delete) have only the brace form, since + / -
are not emphasis delimiters.
Escaping
To honor that round-trip contract, serializeToCarve escapes literal Carve
syntax in plain text so it parses back as text rather than markup - inline code,
links, footnotes, CriticMarkup, mentions/tags/emoji, and an emphasis delimiter
appearing inside its own span. Escaping is contextual: Carve's flanking rules
already make most lone delimiters inert (price * 2, intraword x_1,
comma,, two, C:\path, [email protected]), so those stay clean. The same logic is
exposed as escapeCarve(text).
Block elements
Headings (#), bullet / ordered / task lists, blockquotes (>), fenced code
blocks (`` js
import {
CarveKit,
carveToProseMirror,
serializeToCarve,
} from '@markup-carve/carve-grammars/tiptap'
const content = carveToProseMirror(source, { unsupported: 'preserve' })
const editor = new Editor({ extensions: [CarveKit], content, })
const saved = serializeToCarve(editor.getJSON()) js import { defineCarveEditor } from '@markup-carve/carve-grammars/editor'
defineCarveEditor() const editor = document.querySelector('carve-editor') editor.value = '# Hello' editor.addEventListener('input', event => save(event.detail.value)) html