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

@atjson/renderer-html

Package Overview
Dependencies
Maintainers
0
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atjson/renderer-html

Render HTML documents from atjson

  • 0.36.4
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

🧭 @atjson/renderer-html

Take an annotated document and render it into HTML. By default, this will take an offset document and render it to HTML.

🎈 Extending

The HTML renderer has a $ method that's designed to make it easy to extend and write your own output to HTML.

To extend the current HTML renderer to support YouTube embeds (the kind that show up when you use the share menu), we'd use the following code:

import { YouTubeEmbed } from '@atjson/offset-annotations';
import HTMLRenderer from '@atjson/renderer-html';

export default MyHTMLRenderer extends HTMLRenderer {
  *YoutubeEmbed(embed: YouTubeEmbed) {
    return yield* this.$('iframe', {
      attributes: {
        width: embed.attributes.width,
        height: embed.attributes.height,
        src: embed.attributes.url,
        frameborder: '0',
        allow: 'accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture',
        allowfullscreen: true
      }
    });
  }
}

Now when we put in a video, like https://www.youtube.com/watch?v=RrkL9e2w7gQ, we'll get the following:

<iframe
  width="560"
  height="315"
  src="https://www.youtube.com/embed/RrkL9e2w7gQ"
  frameborder="0"
  allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
  allowfullscreen
></iframe>

FAQs

Package last updated on 13 Dec 2024

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