Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

canvas-native

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvas-native

Utilities for working with the native Canvas format

  • 2.4.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
34
increased by750%
Maintainers
2
Weekly downloads
 
Created
Source

Canvas Native Circle CI

Canvas Native is a set of utilities for parsing and converting between the native Canvas format and other formats.

Usage

Install canvas-native from npm:

npm i --save canvas-native

Parsing

A canvas can be parsed from its native text form into an array of objects that can then be converted into other formats:

import { parse } from 'canvas-native/lib/parser';
parse(myCanvasString);

Formatting

A parsed canvas can be converted into other formats. The available formatters can be found in lib/formatters:

import format      from 'canvas-native/lib/formatters/markdown';
import { parse   } from 'canvas-native/lib/parser';

const parsed   = parse(myCanvasString);
const markdown = format(parsed);

Creating Types

To create a new type, create a subclass of lib/types/type and add the missing getters and methods (see that file for latest format):

// lib/types/my-type.js

import Type     from './type';
import { wrap } from '../brackets';

export default class MyType extends Type {
  toMarkdown(/* prevLine, nextLine */) {
    return 'My type as Markdown';
  }

  static get name() {
    return 'my-type';
  }

  static get pattern() {
    return new RegExp(`^${wrap('my-type')}(.*)$`);
  }
}

Prefixed Lines

In the above example, we make use of the wrap function exported from lib/brackets. That function wraps a given string in the special brackets used for parsing some lines in the Canvas native format.

Keywords

FAQs

Package last updated on 19 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc