JSPM

@humandetail/code-viewer

0.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q30321F
  • License MIT

Display your code with Canvas Rendering.

Package Exports

  • @humandetail/code-viewer

Readme

Code Viewer

This is a library that utilizes Canvas to showcase code snippets, allowing you to visually display your code on web pages in an engaging way.

English | 简体中文

Features

  • Utilizes Canvas technology to draw code snippets, supporting custom styles and colors.

  • Supports syntax highlighting for improved code readability.

  • Can be embedded into your web page using a simple API.

Playground

Here's a playground.

Installation

# add code-viewer
npm i @humandetail/code-viewer

# add highlight.js
npm i highlight.js

Usage

import { CodeViewer, githubThemes } from '@humandetail/code-viewer'

const cv = new CodeViewer({
  content: 'Your code string.',
  language: 'language'
})

cv.setThemes(githubThemes)
  .mount(document.querySelector('#container'))
  .render()

Options

...

API

...

Contributing

If you encounter any issues or wish to improve this library, feel free to submit issues and pull requests. Your contributions will be greatly appreciated!

LICENSE

This project is licensed under the MIT License.