Skip to content

v2.0.0 - Modern marked support

Latest

Choose a tag to compare

@abbott567 abbott567 released this 22 Jul 16:18
· 3 commits to main since this release

This one is a breaking change, but only if you use the MarkedJS integration. Everything else is identical to 1.6.0, so if you've never touched wcagify/markedjs, you can upgrade without reading any further.

The marked integration has been rewritten

The old integration was built for marked v3, back when you created a renderer and mutated it. Marked hasn't worked that way for years, so anybody installing a current version of marked was getting silently broken output. Not great!

wcagifyMarked is now a standard marked extension, which means it works with marked v13 and later, and the setup is much nicer:

Before (wcagify 1.x, marked 3):

const renderer = new marked.Renderer();
wcagifyMarked(renderer);
marked.setOptions({ renderer });

After (wcagify 2.x, marked 13+):

const { marked } = require('marked');
const wcagifyMarked = require('wcagify/markedjs');

marked.use(wcagifyMarked());

You can also pass a version option if you're referencing WCAG 2.1: marked.use(wcagifyMarked({ version: '2.1' })).

A few things worth knowing:

  • If you call it the old way, you get an error telling you exactly what changed, rather than something cryptic.
  • Marked is declared as an optional peer dependency, so if you don't use the markdown integration you won't see any install warnings.
  • If you're stuck on marked 3, stay on wcagify ^1.6.0. The 1.x line still works fine with the old renderer API.

Updating the marked dev dependency from v3 to v18 also cleared the last npm audit warning, so wcagify now audits clean.