1.0.1 • Published 4 years ago

refractor-canvas v1.0.1

Weekly downloads
2
License
MIT
Repository
-
Last release
4 years ago

refractor-canvas

Render refractor nodes to canvas

Installation

yarn add refractor-canvas

Usage

import refractor from 'refractor/core';
import ts from 'refractor/lang/typescript';
import { refractorCanvas } from 'refractor-canvas';
import theme from "./themes/prism-vsc-dark-plus.json";

refractor.register(ts);

const canvas = document.createElement("canvas");
const context = canvas.getContext('2d');e

const tokens = refractor.highlight(area.textContent, 'ts');refractorCanvas(tokens, { context, theme });

document.body.append(canvas);

License

MIT - Copyright 2020 Mario Nebl hello@mario-nebl.de