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

content-kit-compiler

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

content-kit-compiler

Parses and renders content to and from the JSON model that backs ContentKit's WYSIWYG Editor

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
3
Weekly downloads
 
Created
Source

ContentKit Compiler Build Status

Parses and renders content to and from the JSON model that backs ContentKit's WYSIWYG Editor

Examples

Parsing HTML:

<h2>My First Blog Post</h2>
<h3>The Subtitle</h3>
<p>This is a paragraph, with a <a href="http://google.com/">link</a> and some <b>formatting</b>.</p>
<img src="kittens.png" alt="Kittens"/>
<ul>
  <li>Item A</li>
  <li>Item B</li>
</ul>
var compiler = new ContentKit.Compiler();
var json = compiler.parse(html);

Output:

[
  {
    "type":2,
    "value":"My First Blog Post",
    "markup":[]
  },
  {
    "type":3,
    "value":"The Subtitle",
    "markup":[]
  },
  {
    "type":1,
    "value":"This is a paragraph, with a link and some formatting.",
    "markup":[
      {
        "start":28,
        "end":32,
        "type":4,
        "attributes":{
          "href":"http://google.com/"
        }
      },
      {
        "start":42,
        "end":52,
        "type":1
      }
    ]
  },
  {
    "type":4,
    "value":"",
    "markup":[],
    "attributes":{
      "src":"kittens.png",
      "alt":"Kittens"
    }
  },
  {
    "type":6,
    "value":"Item A Item B",
    "markup":[
      {
        "start":0,
        "end":6,
        "type":6
      },
      {
        "start":7,
        "end":13,
        "type":6
      }
    ]
  }
]

Rendering JSON to HTML:

var html = compiler.render(json);

Output:

<h2>My First Blog Post</h2><h3>The Subtitle</h3><p>This is a paragraph, with a <a href="http://google.com/">link</a> and some <b>formatting</b>.</p><img src="kittens.png" alt="Kittens"/><ul><li>Item A</li> <li>Item B</li></ul>

Building / Testing

  • bower install
  • npm install
  • npm run serve && open http://localhost:4200/tests or
  • npm test (uses testem to run tests in phantom and chrome)

Keywords

FAQs

Package last updated on 30 Jun 2015

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