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

@heiwa4126/md2drupal

v0.0.12

Published

Convert Markdown to Drupal-compatible HTML using the Unified ecosystem (remark/rehype)

Readme

md2drupal (@heiwa4126/md2drupal)

NPM - Version NPM Type Definitions NPM Unpacked Size

Markdown から、ある特殊な Drupal 入力用の HTML に変換するツール。

Unified と TypeScript のパッケージングの練習でもある。ほんとうに特定の状況向けに作ってるので、変な処理がいろいろ入ってるのでごめんなさい。

Install

npm install -g @heiwa4126/md2drupal
md2drupal --help
# or
npx @heiwa4126/md2drupal --help

Usage

md2drupal <変換元のmarkdownファイル> [options]

# 例: 同じディレクトリに拡張子.htmlとして変換
md2drupal input.md

# 出力先を指定
md2drupal input.md -o output.html
md2drupal input.md --output /path/to/output.html

# GitHub Markdown CSS付きでスタンドアロンHTMLとして出力
md2drupal input.md --css
md2drupal input.md -c -o preview.html

デフォルトでは、入力ファイルと同じディレクトリに拡張子を.htmlに変更したファイル名で出力します。

オプション

  • -o, --output <file> - 出力 HTML ファイルのパス
  • -c, --css - GitHub Markdown CSS を CDN から読み込むリンクを追加(スタンドアロン HTML プレビュー用)

機能

自動タイトル生成

変換される HTML の <title> タグは、Markdown ファイル内の最初のヘッダ要素(h1-h6)のテキストから自動的に生成されます。

# プロジェクトのドキュメント

本文...

↓ 変換後

<!DOCTYPE html>
<html>
  <head>
    <title>プロジェクトのドキュメント</title>
  </head>
  <body>
    <h1 id="プロジェクトのドキュメント">プロジェクトのドキュメント</h1>
    ...
  </body>
</html>
  • ヘッダ内のインライン要素(リンク、強調など)はプレーンテキストとして抽出されます
  • ヘッダが見つからない場合は、デフォルトで "Converted HTML" が使用されます

YAML Front Matter サポート

Markdown ファイルの先頭に YAML Front Matter を記述することで、HTML の <meta> タグを自動生成できます。

---
description: "この記事の説明文"
keywords:
  - markdown
  - drupal
  - html
author: "著者名"
---

# 記事のタイトル

本文...

↓ 変換後の <head>

<head>
  <meta charset="utf-8" />
  <title>記事のタイトル</title>
  <meta name="description" content="この記事の説明文" />
  <meta name="keywords" content="markdown, drupal, html" />
  <meta name="author" content="著者名" />
</head>

対応フィールド:

  • description - <meta name="description"> タグとして出力
  • keywords - 文字列または配列(配列の場合はカンマ区切りに変換)。<meta name="keywords"> タグとして出力
  • author - <meta name="author"> タグとして出力

セキュリティ: すべてのメタタグの content 属性値は HTML エスケープされます(XSS 対策)。

エラーハンドリング: YAML Front Matter のパースに失敗した場合、警告を stderr に出力し、Front Matter 全体を無視して変換を続行します。

文字エンコーディング

全ての HTML 出力に <meta charset="utf-8"> タグが自動的に追加されます(<head> の最初の要素)。

スタイル付きプレビュー(--cssオプション)

--css(または-c)オプションを使用すると、GitHub Markdown CSS を含むスタンドアロン HTML ファイルとして出力します。これはブラウザで直接開いてプレビューする場合に便利です。

md2drupal document.md --css

このオプションを指定すると、以下が追加されます:

  • GitHub Markdown CSS(CDN: https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.8.1/github-markdown.min.css
  • <body>タグにclass="markdown-body"属性
  • <body>タグにpadding: 1.5emのインラインスタイル

注意: デフォルト(CSS なし)の出力は Drupal CMS への貼り付け用です。--cssオプションはスタンドアロン HTML プレビュー専用として使用してください。

開発

pnpm i
pnpm run prepublishOnly

# バージョニング
git add --all && git commit -am '...'
pnpm version patch
git push --follow-tags

# npmjs.com に発行
pnpm publish --access=public

メモ: chokidar の件

(この件、tsup やめて tsdown にしました)

Provenance is missing in 4.0.2 & 4.0.3 · Issue #1440 · paulmillr/chokidar の件で、package.json に

	"pnpm": {
		"overrides": {
			"chokidar": "4.0.1"
		}
	},

が入ってます。tsup が chokidar@5 依存になったら取る。tsdown にする手もある

他参考: (1) X ユーザーの pnpm さん: 「We have discovered that chokidar has switched off provenance a year ago and now it fails with the trustPolicy setting set to no-downgrade. We'll need to think about a way to deal with these cases. https://t.co/fSEJQYWr1e」 / X

上の設定消したら

pnpm install --no-frozen-lockfile

を実行するのを忘れないこと。package.json から消しても pnpm-lock.yaml には残る。

メモ: v0.0.9 以前でコミット間違えてた...

(v0.0.10 で修正のはず) npm 上で Provenance 切れるかもしれません。ごめん