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 🙏

© 2024 – Pkg Stats / Ryan Hefner

zenn-markdown-html

v0.1.154

Published

Convert markdown to zenn flavor html.

Downloads

2,570

Readme

zenn-markdown-html

zenn-markdown-html は、Zenn 独自の記法を含む markdown を HTML に変換するためのパッケージです。

使い方

このパッケージは 2 つのインターフェイスを提供します。

  • markdownToHtml: Zenn の記事、本、コメントなどで使用する HTML に変換します。
  • markdownToSimpleHtml: Publication の定型メッセージなど、限られた装飾のみをサポートする HTML に変換します。

markdownToHtml

Markdown を HTML に変換します。

import markdownToHtml from 'zenn-markdown-html';
const html = markdownToHtml(markdown);

サポートする記法については、Zenn のMarkdown 記法一覧を参照してください。

埋め込み要素の挙動をカスタマイズする

customEmbed オプションを使うことで埋め込み要素の挙動をカスタマイズできます。 カスタマイズできる埋め込み要素については Zenn のドキュメントを参照してください。

import markdownToHtml from 'zenn-markdown-html';
const html = markdownToHtml(markdown, {
  customEmbed: {
    // @[tweet](...)に対応している埋め込み要素をカスタマイズする
    tweet(url) {
      // 注意: サニタイズによって<script src="https://platform.twitter.com/widgets.js" />は埋め込めないので、別の場所で埋め込み必要があります!
      return `
        <blockquote
          className="twitter-tweet"
          data-conversation="${
            src.split(/&|\?/).includes('conversation=none') ? 'none' : ''
          }"
        >
          <a href="${url}" rel="nofollow noopener noreferrer" target="_blank">
            ${url}
          </a>
        </blockquote>
      `;
    },
  },
});

zenn.dev と同じ埋め込み要素を使用する

埋め込み機能を使用する場合は、ホスティングされている埋め込みサーバーの Origin URL を embedOrigin を指定してください。 非商用の場合のみ Zenn が提供する埋め込みサーバーを指定できます。

import markdownToHtml from 'zenn-markdown-html';
const html = markdownToHtml(markdown, {
  embedOrigin: 'https://embed.zenn.studio',
});

markdownToSimpleHtml

Markdown を HTML に変換します。markdownToHtml と比べてサポートする記法が限られています。

import { markdownToSimpleHtml } from 'zenn-markdown-html';
const html = markdownToSimpleHtml(markdown);

サポートする記法

  • Markdown 記法(リンク、リスト、太字・斜体)
  • パラグラフ内の改行
  • URL をリンクに変換

開発者向けドキュメント

https://zenn-dev.github.io/zenn-docs-for-developers/guides/zenn-editor/zenn-markdown-html