@igorskyflyer/strip-md-headings
v1.1.0
Published
⛸ Remove Markdown headings h1-h6 safely. Strip all heading syntax or keep clean text. Perfect for parsing, SEO cleanup, and text extraction. 🏹
Maintainers
Readme
📃 Table of Contents
🤖 Features
- 🧹 Strips markdown headings h1-h6 completely
- ✂️ Removes only heading syntax keeps text clean
- 🧼 Safe input handling always returns string
- 📚 Ideal for markdown parsing text extraction seo
🕵🏼 Usage
Install it by executing any of the following, depending on your preferred package manager:
pnpm add @igorskyflyer/strip-md-headingsyarn add @igorskyflyer/strip-md-headingsnpm i @igorskyflyer/strip-md-headings🤹🏼 API
function stripHeadings(value: string): stringStrips Markdown headings completely.
value: string - the Markdown string to process.
Returns the processed string.
function stripHeadingsCode(value: string): stringStrips only the Markdown code while keeping the heading text.
value: string - the Markdown string to process.
Returns the processed string.
🗒️ Examples
index.ts
import { stripHeadings, stripHeadingsCode } from '@igorskyflyer/strip-md-headings'
// 🧹 strip all markdown headings completely
console.log(stripHeadings('# Hello\nWorld'))
// 'World'
// ✂️ keep heading text, remove only syntax
console.log(stripHeadingsCode('## Hello'))
// 'Hello'
// 📚 multiple headings handled
console.log(stripHeadingsCode('# A\n## B\n### C'))
// 'A\nB\nC'
// 🧼 whitespace trimmed
console.log(stripHeadingsCode(' ### Trimmed '))
// 'Trimmed'
// 🚫 safe on bad input
// @ts-expect-error
console.log(stripHeadings()) // ''
// @ts-expect-error
console.log(stripHeadingsCode(null)) // ''📝 Changelog
📑 Read about the latest changes in the CHANGELOG.
🪪 License
Licensed under the MIT license.
💖 Support
🧬 Related
@igorskyflyer/strip-yaml-front-matter
🦓 Strips YAML front matter from a String or a file. 👾
@igorskyflyer/strip-html-headings
🍛 Lightweight utility to strip HTML heading tags (h1-h6). Remove headings completely or extract their text content while cleaning up markup. Perfect for transforming HTML, parsing content, or preparing plain text output. 🍤
🔦 Provides frequently used types for your TypeScript projects. 🦄
🥞 Removes HTML code from the given string. Can even extract text-only from the given an HTML string. ✨
🕶️ Reads a JSON file into a Map. 🌻
👨🏻💻 Author
Created by Igor Dimitrijević (@igorskyflyer).
