0.5.0 • Published 2 years ago

remove-markdown v0.5.0

Weekly downloads
89,103
License
MIT
Repository
github
Last release
2 years ago

CircleCI

What is it?

remove-markdown is a node.js module that will remove (strip) Markdown formatting from text. Markdown formatting means pretty much anything that doesn’t look like regular text, like square brackets, asterisks etc.

When do I need it?

The typical use case is to display an excerpt from some Markdown text, without any of the actual Markdown syntax - for example in a list of posts.

Installation

npm install remove-markdown

Usage

const removeMd = require('remove-markdown');
const markdown = '# This is a heading\n\nThis is a paragraph with [a link](http://www.disney.com/) in it.';
const plainText = removeMd(markdown); // plainText is now 'This is a heading\n\nThis is a paragraph with a link in it.'

You can also supply an options object to the function. Currently, the following options are supported:

const plainText = removeMd(markdown, {
  stripListLeaders: true , // strip list leaders (default: true)
  listUnicodeChar: '',     // char to insert instead of stripped list leaders (default: '')
  gfm: true                // support GitHub-Flavored Markdown (default: true)
  useImgAltText: true      // replace images with alt-text, if present (default: true)
});

Setting stripListLeaders to false will retain any list characters (*, -, +, (digit).).

TODO

PRs are very much welcome. Here are some ideas for future enhancements:

  • Allow the RegEx expressions to be customized per rule
  • Make the rules more robust, support more edge cases
  • Add more (comprehensive) tests

Credits

The code is based on Markdown Service Tools - Strip Markdown by Brett Terpstra.

Author

Stian Grytøyr

euaaaiocodybonney.comvulcan-cra-startercaptain-dashboardsglue-js-documentation-builder@nona-creative/semantic-release-latest-release-notessourcecred-for-samudaitealess-dashboard@infinitebrahmanuniverse/nolb-remo@paiondata/nextwiki@everything-registry/sub-chunk-2649zenapi-admin@walkaway-project/elmstatic@survivejs/utils@vuepress/theme-blogelectricelmstatic@telios/telios-client-backend@theguild/algoliadte-shared-componentsdte-shared-private@thenumber/itinerator-expo-components@topgroup/diginextgatsby-theme-gatsbyjs-websitegatsby-theme-wikinotesgatsby-theme-advancedgatsby-theme-amaranthgatsby-theme-materialgatsby-theme-primer-wiki@aldridged/docusaurus-plugin-lunranchor-markdown-header@xapp/stentor-gbmforked-sourcecredfillout-shared-codeghost-algoliaapiconnect-explorergit-ssb-webgitee-ent-viewdayone-to-quiverdbfs-strapi-admindbdocsmudawanahmongoose-markdown-descriptionmonitorss-webmonobaselunr-hugodokumentjsdiscord.rss-webdesktop-dimmerdocarysladocanvas-nativeblogybloom-cli@dao-dao/statefulimdone-corecandy-clichangelog-toolschangelog-parsernewsletter-cli@fiction/core@financial-times/g-componentsmergeloggamarkdown-post-parsermarkdown-search-indexmarkdown-descriptionmarkedpagemillrunmiksermikser-core-render-markdownminimist-minimdds@frontender-magazine/article-builderninjs-md@foxythemes/hugo-lunrdescription@elucidata/tilt@emundo/emubotgulp-remove-markdownhelp-center-ui@docs-gov-sg/doc-theme-defaultcommand-line-applicationjoplin-plugin-notelistpreviewjoplin-plugin-tags-generatorjoplin-plugin-note-stats@crisog/sourcecred@communi/chat-reacthubot-command-mapperhs-adminbrochubspell-simplifier-markdownhugo-algoliahugo-algolia-fixhugo-algolia2hugo-lovelt-algoliahugo-lunrhugo-lunr-diasporahugo-lunr-easterhugo-lunr-indexhugo-lunr-indexer
0.5.0

2 years ago

0.3.0

6 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

8 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago