diff --git a/README.md b/README.md index 490c02d..e199d4a 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,5 @@ ![default workflow](https://github.com/stiang/remove-markdown/actions/workflows/default.yaml/badge.svg) -## *** 2022-10-18: Important message about the future of this package *** -Hello all, I don’t use this package in my own projects any longer and I have come to the realization that I basically don’t have the bandwidth to maintain the package. - -However, the package is used quite a bit and I don’t want to just abandon it. So I’m looking for suggestions on how to move forward with someone else in charge of maintaining the package on a day-to-day basis. I’m open to adding collaborators to this repo or moving the entire repo to a more fitting home. - -Please contact me directly or post a comment on [the issue I created about this](https://github.com/stiang/remove-markdown/issues/61) (#61). - ## 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. @@ -50,5 +43,6 @@ PRs are very much welcome. Here are some ideas for future enhancements: ## Credits The code is based on [Markdown Service Tools - Strip Markdown](http://brettterpstra.com/2013/10/18/a-markdown-service-to-strip-markdown/) by Brett Terpstra. -## Author -Stian Grytøyr +## Authors +Stian Grytøyr (original creator) +[zuchka](https://github.com/zuchka) (maintainer since 2023) diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..bff398b --- /dev/null +++ b/index.d.ts @@ -0,0 +1,13 @@ +declare module "remove-markdown" { + export function removeMd(md: string, options?: { + stripListLeaders?: boolean; + listUnicodeChar?: string; + gfm?: boolean; + useImgAltText: boolean; + abbr?: boolean; + replaceLinksWithURL?: boolean; + htmlTagsToSkip?: string[]; + }): string; + + export = removeMd; +} \ No newline at end of file diff --git a/index.js b/index.js index 6a13bb0..256acc5 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ module.exports = function(md, options) { options.abbr = options.hasOwnProperty('abbr') ? options.abbr : false; options.replaceLinksWithURL = options.hasOwnProperty('replaceLinksWithURL') ? options.replaceLinksWithURL : false; options.htmlTagsToSkip = options.hasOwnProperty('htmlTagsToSkip') ? options.htmlTagsToSkip : []; + options.throwError = options.hasOwnProperty('throwError') ? options.throwError : false; var output = md || ''; @@ -48,7 +49,7 @@ module.exports = function(md, options) { htmlReplaceRegex = new RegExp( '<' + joinedHtmlTagsToSkip + - '[^>]*>', + '[^>]*>', 'ig' ); } @@ -89,7 +90,9 @@ module.exports = function(md, options) { // Replace strike through .replace(/~(.*?)~/g, '$1'); } catch(e) { - console.error(e); + if (options.throwError) throw e; + + console.error("remove-markdown encountered error: %s", e); return md; } return output; diff --git a/package-lock.json b/package-lock.json index 5204c1c..b98442f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -70,12 +70,23 @@ } }, "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "requires": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" + }, + "dependencies": { + "fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + } } }, "browser-stdout": { @@ -243,15 +254,6 @@ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, - "requires": { - "to-regex-range": "^5.0.1" - } - }, "find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", diff --git a/package.json b/package.json index 2ffec2d..80d7b57 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "remove-markdown", - "version": "0.5.0", + "version": "0.5.1", "description": "Remove Markdown formatting from text", "main": "index.js", "scripts": { @@ -8,7 +8,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/stiang/remove-markdown.git" + "url": "https://github.com/zuchka/remove-markdown.git" }, "keywords": [ "markdown" @@ -16,9 +16,9 @@ "author": "Stian Grytøyr", "license": "MIT", "bugs": { - "url": "https://github.com/stiang/remove-markdown/issues" + "url": "https://github.com/zuchka/remove-markdown/issues" }, - "homepage": "https://github.com/stiang/remove-markdown", + "homepage": "https://github.com/zuchka/remove-markdown", "devDependencies": { "chai": "^4.0.2", "mocha": "^10.2.0",