0.6.0 • Published 12 months ago

remove-markdown v0.6.0

Weekly downloads
89,103
License
MIT
Repository
github
Last release
12 months ago
  • default workflow

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.

Authors

Stian Grytøyr (original creator) zuchka (maintainer since 2023)

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-2649fillout-shared-codewiznote-sdk-jswallet-appstrapi-admin-lightstac-componentvitepress-theme-celestajoplin-plugin-note-statsjoplin-plugin-notelistpreviewjoplin-plugin-tags-generatorhubot-command-mapperimdone-corehugo-elasticsearchhugo-lunr-indexerhugo-lunr-mlhugo-lunr-zhhugo-lovelt-algoliahugo-lunrhugo-lunr-diasporahugo-lunr-easterhugo-algoliahugo-algolia-fixhugo-algolia2hugo-algolia2-1hugo-lunr-indexhubspell-simplifier-markdowngulp-remove-markdownhs-admingrommet-cms-content-blockshadshads-plantumlhelp-center-uilunr-hugomarkdown-search-indexmarkdown-descriptionmarkdown-post-parsermarkedpageladomdds@walkaway-project/elmstatic@vuepress/theme-blog@thenumber/itinerator-expo-components@topgroup/diginext@theguild/algolia@versaprotocol/pdfgen@vibe-flats/vibe-common@xapp/stentor-gbm@telios/telios-client-backendanchor-markdown-headerapiconnect-explorer@petelc/learnstorybook-design-system@piscale/chat-reactfowler-chat-reactnativeforked-sourcecredgatsby-theme-amaranthgatsby-theme-advancedgatsby-theme-primer-wikigatsby-theme-gatsbyjs-websitegatsby-theme-materialgatsby-theme-wikinotes@survivejs/utils@svecodocs/kitdokumentjsdocarysdte-shared-componentsdte-shared-privateelmstaticelectric@preserve-sdk/react@celesta/vuepress-plugin-celestacandy-clicanvas-nativechangelog-toolschangelog-parsercli-help-from-readmecommand-line-applicationcrds-cypress-contentfulcrds-cypress-toolscra-template-vulcandbfs-strapi-admindbdocsdescriptiondesktop-dimmerdayone-to-quiverblogybloom-clibrocdiscord.rss-web@aldridged/docusaurus-plugin-lunrstudy-manager
0.6.0

12 months ago

0.5.4

1 year ago

0.5.3

1 year ago

0.5.5

1 year ago

0.5.2

1 year ago

0.5.0

4 years ago

0.3.0

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

10 years ago

0.0.6

10 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago