remove-markdown 0.5.3 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,3 @@
1
- ![default workflow](https://github.com/stiang/remove-markdown/actions/workflows/default.yaml/badge.svg)
2
-
3
1
  ## What is it?
4
2
  **remove-markdown** is a node.js module that will remove (strip) Markdown formatting from text.
5
3
  *Markdown formatting* means pretty much anything that doesn’t look like regular text, like square brackets, asterisks etc.
package/index.d.ts CHANGED
@@ -1,13 +1,11 @@
1
- declare module "remove-markdown" {
2
- export function removeMd(md: string, options?: {
3
- stripListLeaders?: boolean;
4
- listUnicodeChar?: string;
5
- gfm?: boolean;
6
- useImgAltText: boolean;
7
- abbr?: boolean;
8
- replaceLinksWithURL?: boolean;
9
- htmlTagsToSkip?: string[];
10
- }): string;
1
+ declare function removeMd(md: string, options?: {
2
+ stripListLeaders?: boolean;
3
+ listUnicodeChar?: string;
4
+ gfm?: boolean;
5
+ useImgAltText: boolean;
6
+ abbr?: boolean;
7
+ replaceLinksWithURL?: boolean;
8
+ htmlTagsToSkip?: string[];
9
+ }): string;
11
10
 
12
- export = removeMd;
13
- }
11
+ export = removeMd;
package/index.js CHANGED
@@ -49,7 +49,7 @@ module.exports = function(md, options) {
49
49
  htmlReplaceRegex = new RegExp(
50
50
  '<' +
51
51
  joinedHtmlTagsToSkip +
52
- '[^>]*>',
52
+ '[^>]*>',
53
53
  'ig'
54
54
  );
55
55
  }
@@ -75,8 +75,10 @@ module.exports = function(md, options) {
75
75
  .replace(/^(\n)?\s{0,}#{1,6}\s*( (.+))? +#+$|^(\n)?\s{0,}#{1,6}\s*( (.+))?$/gm, '$1$3$4$6')
76
76
  // Remove * emphasis
77
77
  .replace(/([\*]+)(\S)(.*?\S)??\1/g, '$2$3')
78
- // Remove _ emphasis
79
- .replace(/(_+)(.*?\S)(_+)/g, '$1$3$4$5')
78
+ // Remove _ emphasis. Unlike *, _ emphasis gets rendered only if
79
+ // 1. Either there is a whitespace character before opening _ and after closing _.
80
+ // 2. Or _ is at the start/end of the string.
81
+ .replace(/(^|\W)([_]+)(\S)(.*?\S)??\2($|\W)/g, '$1$3$4$5')
80
82
  // Remove code blocks
81
83
  .replace(/(`{3,})(.*?)\1/gm, '$2')
82
84
  // Remove inline code
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remove-markdown",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "Remove Markdown formatting from text",
5
5
  "main": "index.js",
6
6
  "scripts": {