Markdown Extensions: A Small Utility for a Common Problem
A lightweight JavaScript utility for detecting Markdown files reliably across extensions like .md, .markdown, and .mkd. Built for real-world workflows.
Markdown is widely used across documentation, blogging, static sites, and developer tooling. At a glance, identifying a Markdown file seems straightforward. In practice, it is not.
Different tools, ecosystems, and historical conventions have introduced multiple file extensions for Markdown content. While .md is the most common, variations such as .markdown, .mkd, and .mdown appear frequently in repositories and content pipelines.
This creates a small but persistent problem:
how do you reliably determine whether a file is Markdown?
This utility exists to solve that problem in a simple and predictable way.
Explore the package:
View the repo on Github:
The Problem
Most implementations rely on assumptions such as:
“Check if the file ends with .md.”
That approach breaks quickly in real-world environments.
Repositories often contain mixed formats. Documentation systems may use different extensions. Automated workflows, such as content ingestion, indexing, or validation, can silently miss files if extension handling is incomplete.
The result is inconsistency. Files are skipped, pipelines behave unpredictably, and edge cases accumulate over time.
The Approach
This package provides a canonical list of Markdown extensions and a small set of helper functions to work with them.
Instead of hardcoding assumptions, it standardizes detection through:
- A single source of truth for known Markdown extensions
- Normalization of inputs such as
.MD, filenames, and file paths - Simple helper functions for extension and file detection
The goal is not to be complex. The goal is to be correct.
Example
import { isMarkdownFile } from '@brandonhimpfen/markdown-extensions';
isMarkdownFile('README.md'); // true
isMarkdownFile('docs/guide.mkd'); // true
isMarkdownFile('notes.txt'); // false
Where This Fits
This utility is designed to be used as a small building block within larger systems.
Common use cases include:
- Static site generators and content-driven websites.
- Repository automation and validation scripts.
- Markdown parsing and transformation pipelines.
- AI and search indexing workflows.
- CLI tools that process or organize files.
It is intentionally narrow in scope, but broadly applicable.
How to Think About It
This project reflects a broader approach to building systems.
Instead of large, monolithic solutions, it focuses on:
- Solving small problems clearly.
- Creating reusable components.
- Reducing ambiguity in common tasks.
- Building reliable foundations for larger workflows.
Many systems fail not because of major flaws, but because of small inconsistencies that compound over time.
This is a small attempt to remove one of those inconsistencies.