4.0.4 • Published 7 days ago

@cartamd/plugin-code v4.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
7 days ago

Carta Code Plugin

This plugin adds support for code blocks syntax highlighting. It uses the same highlighter from the core package(Shiki).

npm i @cartamd/plugin-code

Setup

Styles

Import the default styles:

import '@cartamd/plugin-code/default.css';

Using the default highlighter

Carta comes with a default highlighter that matches the one used to highlight markdown in the editor and is used by default (Shiki). If you want to use a theme different from the one used to highlight Markdown, you can specify it in the options. Remember to also have it loaded into the highlighter, by specifying it in shikiOptions.

const carta = new Carta({
	// ...
	extensions: [
		code({
			theme: 'ayu-light'
		})
	],
	shikiOptions: {
		themes: ['ayu-light']
	}
});

Using a custom highlighter

It is no longer possible to specify a custom highlighter in this plugin. However, there are many different Remark plugins that provide syntax highlighting.

Extension

<script lang="ts">
	import { Carta, MarkdownEditor } from 'carta-md';
	import { code } from '@cartamd/plugin-code';

	const carta = new Carta({
		extensions: [code()]
	});
</script>

<MarkdownEditor {carta} />

Documentation

Checkout the docs for examples, options and more.

4.0.4

7 days ago

4.0.3

25 days ago

4.0.2

25 days ago

4.0.1

27 days ago

2.3.0

9 months ago

2.2.1

9 months ago

2.0.3

10 months ago

2.2.0

9 months ago

2.1.1

9 months ago

2.0.2

10 months ago

2.5.0

8 months ago

2.4.1

8 months ago

2.0.5

9 months ago

2.4.0

8 months ago

2.3.1

9 months ago

2.0.4

10 months ago

2.7.0

7 months ago

2.0.7

9 months ago

2.6.0

7 months ago

2.0.6

9 months ago

2.7.2

7 months ago

2.8.0

6 months ago

2.7.1

7 months ago

2.0.8

9 months ago

2.1.0

9 months ago

2.0.1

10 months ago

2.0.0

10 months ago

3.0.1

6 months ago

3.0.0

6 months ago

4.0.0

6 months ago

1.2.0

12 months ago

1.1.13

12 months ago

1.1.12

12 months ago

1.1.11

12 months ago

1.1.10

12 months ago

1.1.9

12 months ago

1.1.8

12 months ago

1.1.7

12 months ago

1.1.6

12 months ago

1.1.5

12 months ago

1.1.4

12 months ago

1.1.3

12 months ago

1.1.2

12 months ago

1.1.1

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

0.0.1

1 year ago