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

@wsxjs/wsx-marked-components

v0.1.0

Published

Markdown rendering components built with WSXJS for marked library

Readme

@wsxjs/wsx-marked-components

Markdown rendering components built with WSXJS for the marked library.

Installation

pnpm add @wsxjs/wsx-marked-components marked

Components

Heading

Renders markdown headings (h1-h6) with customizable styling.

Tag: <wsx-marked-heading>

Attributes:

  • level (number): Heading level (1-6)
  • text (string): Heading text content

Example:

<wsx-marked-heading level="1" text="Hello World"></wsx-marked-heading>

Code

Renders code blocks with syntax highlighting support.

Tag: <wsx-marked-code>

Attributes:

  • code (string): Code content
  • language (string): Programming language identifier

Example:

<wsx-marked-code code="console.log('Hello');" language="javascript"></wsx-marked-code>

Blockquote

Renders blockquotes with styling.

Tag: <wsx-marked-blockquote>

Example:

<wsx-marked-blockquote>
  <p>This is a quote</p>
</wsx-marked-blockquote>

Paragraph

Renders paragraphs with HTML content support.

Tag: <wsx-marked-paragraph>

Attributes:

  • content (string): HTML content for the paragraph

Example:

<wsx-marked-paragraph content="This is a <strong>paragraph</strong>"></wsx-marked-paragraph>

List

Renders ordered or unordered lists.

Tag: <wsx-marked-list>

Attributes:

  • ordered (boolean): Whether the list is ordered
  • items (string): JSON stringified array of HTML item content

Example:

<wsx-marked-list ordered="false" items='["Item 1", "Item 2"]'></wsx-marked-list>

Error

Displays error messages during markdown rendering.

Tag: <wsx-marked-error>

Attributes:

  • message (string): Error message

Example:

<wsx-marked-error message="Failed to parse markdown"></wsx-marked-error>

Markdown

A complete markdown renderer component that converts markdown to WSX marked components.

Tag: <wsx-markdown>

Attributes:

  • markdown (string): Markdown content to render

Methods:

  • setCustomRenderers(renderers: CustomRenderers): Set custom token renderers
  • getCustomRenderers(): Get current custom renderers

Example - Basic Usage:

<wsx-markdown markdown="# Hello World"></wsx-markdown>

Example - With Custom Renderers:

import { Markdown, type TokenRenderer } from "@wsxjs/wsx-marked-components";
import type { Tokens } from "marked";

const markdown = document.querySelector("wsx-markdown") as Markdown;

const customHeadingRenderer: TokenRenderer = (token, defaultRender) => {
    if (token.type === "heading") {
        const headingToken = token as Tokens.Heading;
        // Custom rendering logic
        const customElement = document.createElement("div");
        customElement.className = "custom-heading";
        customElement.textContent = `Custom: ${headingToken.text}`;
        return customElement;
    }
    return null; // Use default for other types
};

markdown.setCustomRenderers({
    heading: customHeadingRenderer,
});

Utilities

extractInlineTokens(tokens: Tokens.Generic[]): Tokens.Generic[]

Extracts inline tokens from a list of tokens, handling paragraph tokens by extracting their inline tokens.

renderInlineTokens(tokens: Tokens.Generic[]): string

Renders inline tokens to HTML string.

escapeHtml(text: string): string

Escapes HTML special characters for safe attribute values.

Usage

Using Individual Components

import "@wsxjs/wsx-marked-components";
import { marked } from "marked";

// Components are automatically registered as custom elements
// You can use them in HTML strings or JSX
const html = marked.parse("# Hello World");
// Returns: '<wsx-marked-heading level="1" text="Hello World"></wsx-marked-heading>'

// Or with code block:
const codeHtml = marked.parse("```js\nconsole.log('Hello');\n```");
// Returns: '<wsx-marked-code code="console.log(\'Hello\');" language="js"></wsx-marked-code>'

Using Markdown Component

The Markdown component provides a complete solution for rendering markdown:

<!-- Simple usage -->
<wsx-markdown markdown="# Hello World"></wsx-markdown>

<!-- With custom renderers -->
<script type="module">
import { Markdown, type TokenRenderer } from "@wsxjs/wsx-marked-components";
import type { Tokens } from "marked";

const markdown = document.querySelector("wsx-markdown");
const customRenderer: TokenRenderer = (token, defaultRender) => {
    // Your custom logic here
    return defaultRender();
};
markdown.setCustomRenderers({ heading: customRenderer });
</script>

Customization

The Markdown component is designed to be extensible. You can customize rendering for any token type:

import { Markdown, type TokenRenderer, type CustomRenderers } from "@wsxjs/wsx-marked-components";
import type { Tokens } from "marked";

const markdown = document.querySelector("wsx-markdown") as Markdown;

// Custom renderers can override default behavior
const customRenderers: CustomRenderers = {
    heading: (token, defaultRender) => {
        // Custom heading rendering
        return defaultRender();
    },
    code: (token, defaultRender) => {
        // Custom code block rendering
        return defaultRender();
    },
};

markdown.setCustomRenderers(customRenderers);

License

MIT