npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

writers-mark-dom

v0.6.1

Published

Dom Renderer for Writer's Mark

Readme

Writer's Mark Dom Renderer

npm install size github actions Known Vulnerabilities codecov.io

A safe standalone DOM renderer for writers-mark.

Installation

npm install writers-mark writers-mark-dom

Usage

This library is meant to consume the output of the core writers-mark-ts library. It consists of a single render() function that accepts Writer's Mark IR and a target HTMLElement as parameters.

import {Context} from 'writers-mark'
import {render} from 'writers-mark-dom'

const ctx = new Context();

const style = ctx.compileStyle(styleString);
const text = ctx.compileText(contextString, [style]);

render(text, document.getElementById('root'));

N.B. Due to the way IFrame sandboxes work, the target HTML element must be in the dom already.

Rendering pre-compiled content:

It is possible to substantially speed up rendering by caching the results of ctx.compileText(). However, there is one important consideration:

render() expects the Writer's Mark IR to be valid. Unless you have full trust in the entire chain of custody between the call call to Context.compileText() and the call to render(), you should always check the validity of the IR before rendering it.

import {Context} from 'writers-mark'
import {render} from 'writers-mark-dom'

const ctx = new Context();

const style = ctx.compileStyle(styleString);
fetch("http://example.com/path_to_resource.json")
  .then(response => response.json())
  .then(text => {
    if(ctx.isTextValid(text)) {
      render(text, document.getElementById('root');
    }
  }));

Safety

Here are the measures the library takes to ensure rendered User-Generated Content is safe:

  • Writer's Mark is rendered in a sandboxed iframe.
    • The only policy enabled is allow-same-origin, which is currently required for the rendering to work.
  • All rendering is performed through the DOM api. No text-based rendering whatsoever is used, including when rendering style rules.
  • The list of tags used, and the attributes that are set is:
    • <p> : class
    • <span> : class
    • <a> : href
    • <style>
      • The only selectors used are classes.
      • The allowed attributes are determined by the Context .