Search by

markup-carve / carve-grammars

dereuromark

Syntax-highlighting grammars for the Carve markup language (TextMate grammar for Torchlight / phiki, plus Prism and highlight.js definitions)

Package info

github.com/markup-carve/carve-grammars

Language:JavaScript

pkg:composer/markup-carve/carve-grammars

Statistics

Installs: 4 238

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 4


README

Syntax highlighting for Carve 0.2 in Prism, highlight.js, TextMate, and Shiki. The language name is carve; crv is its file extension alias. These grammars replace the 0.1 grammars. The package also ships a Tiptap editor kit for the 0.2 tree.

Install

npm install @markup-carve/carve-grammars prismjs

Prism

import Prism from 'prismjs'
import '@markup-carve/carve-grammars/prism/carve.js'

Prism.highlight(source, Prism.languages.carve, 'carve')

For highlight.js, import @markup-carve/carve-grammars/highlightjs/carve.js and register it as carve. For TextMate, load textmate/carve.tmLanguage.json. For Shiki, import carveMarkdown or carveGrammar from the package root or @markup-carve/carve-grammars/shiki.

The package also ships host helpers that work with any of these: diff and shiki/diff for {.diff} fences, diagrams for Graphviz, D2 and PlantUML blocks, and fence-languages.json, the fence-word table editor grammars embed by. See the reference.

Tiptap

@markup-carve/carve-grammars/tiptap loads Carve 0.2 into a Tiptap editor and writes it back. You pass in the carve-js engine, so the kit never bundles it.

import { Editor } from '@tiptap/core'
import * as carve from '@markup-carve/carve'
import { CarveKit, carveToProseMirror, serializeToCarve } from '@markup-carve/carve-grammars/tiptap'

const editor = new Editor({ extensions: [CarveKit], content: carveToProseMirror(source, { engine: carve }) })
const next = serializeToCarve(editor.getJSON(), { engine: carve, source })

See the Tiptap kit guide.

See the migration guide for every renamed path and removed surface.