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

prettier-plugin-md-title-case

v1.0.2

Published

Make Prettier convert your Markdown headings to title-case.

Downloads

191

Readme

GitHub Workflow Status

Prettier Plugin: Markdown Title Case

Make sure that your Markdown headings stay consistent no matter who writes them.

A plugin that makes Prettier convert your markdown headings to title case using the title-case npm package.

Features

  • 🚀 Zero config (but configurable).
  • 🤓 No more inconsistent headings.
  • 🤙 No more fixing other people's titles.

Caveat

This plugin overrides the built-in Prettier parser for markdown. This means that it is incompatible with other plugins that do the same; only the last loaded plugin that exports one of those parsers will function.

Installation

npm install --save-dev prettier-plugin-md-title-case

Note that prettier is a peer dependency, so make sure you have it installed in your project. Prettier 2 is not supported as this package is written with ESM syntax.

Usage

Configure Prettier to use the plugin according to the Plugins docs, for example by adding it to the plugins config:

// prettier.config.js

/** @type {import('prettier').Config} */
export default {
  plugins: ['prettier-plugin-md-title-case'],
};

It doesn't support inline HTML headings.

Configuration

You can pass the supported options of title-case (see npmjs.com/package/title-case#options) to your Prettier config as a JSON-stringified object via the titleCase option.

// prettier.config.js

/** @type {import('title-case').Options} */
const titleCaseOptions = { locale: 'en_US' };

/** @type {import('prettier').Config} */
export default {
  plugins: ['prettier-plugin-md-title-case'],
  titleCase: JSON.stringify(titleCaseOptions),
};

Debug Logs

If it doesn't work, you can try to prefix your prettier command with DEBUG=true (or any truthy value) which will make this plugin print runtime exception logs.

Rationale/Disclaimer

This plugin acts outside of Prettier's scope because "Prettier only prints code. It does not transform it.", and technically converting the case is a code transformation. In my opinion however, Markdown is just markup and not really code, and it doesn't change the AST of the Markdown file (just the content of some text node values). Therefore the practical benefits outweigh sticking with the philosophy in this case.

License

MIT.