@graphql-markdown/utils
Advanced tools
Comparing version
@@ -96,2 +96,4 @@ /** | ||
* Returns a string with MDX special characters converted to HTML unicode using {@link toHTMLUnicode}. | ||
* Characters within code notation should not be converted. | ||
* List of special characters: `{`, `<`, `>`, `}` | ||
* | ||
@@ -110,2 +112,5 @@ * @internal | ||
* // Expected result: "{MDX} <special> characters" | ||
* | ||
* escapeMDX("`{MDX}` `<special>` characters"); | ||
* // Expected result: "`{MDX}` `<special>` characters" | ||
* ``` | ||
@@ -112,0 +117,0 @@ * |
@@ -147,2 +147,4 @@ "use strict"; | ||
* Returns a string with MDX special characters converted to HTML unicode using {@link toHTMLUnicode}. | ||
* Characters within code notation should not be converted. | ||
* List of special characters: `{`, `<`, `>`, `}` | ||
* | ||
@@ -161,2 +163,5 @@ * @internal | ||
* // Expected result: "{MDX} <special> characters" | ||
* | ||
* escapeMDX("`{MDX}` `<special>` characters"); | ||
* // Expected result: "`{MDX}` `<special>` characters" | ||
* ``` | ||
@@ -166,3 +171,3 @@ * | ||
const escapeMDX = (str) => { | ||
return `${String(str)}`.replace(/[<>{}]/g, exports.toHTMLUnicode); | ||
return `${String(str)}`.replace(/(?<!`)([{<>}])(?=(?:[^`]*`[^`]*`)*[^`]*$)/g, exports.toHTMLUnicode); | ||
}; | ||
@@ -169,0 +174,0 @@ exports.escapeMDX = escapeMDX; |
{ | ||
"name": "@graphql-markdown/utils", | ||
"homepage": "https://graphql-markdown.github.io", | ||
"homepage": "https://graphql-markdown.dev", | ||
"description": "GraphQL-Markdown common libraries.", | ||
@@ -8,3 +8,3 @@ "bugs": { | ||
}, | ||
"version": "1.6.3", | ||
"version": "1.6.4", | ||
"license": "MIT", | ||
@@ -60,3 +60,3 @@ "repository": { | ||
"devDependencies": { | ||
"@graphql-markdown/types": "^1.2.0" | ||
"@graphql-markdown/types": "^1.3.1" | ||
}, | ||
@@ -63,0 +63,0 @@ "peerDependencies": { |
# @graphql-markdown/utils | ||
[](https://www.npmjs.com/package/@graphql-markdown/utils) | ||
[](https://raw.githubusercontent.com/graphql-markdown/graphql-markdown/main/LICENSE) | ||
[](https://www.npmjs.com/package/@graphql-markdown/utils) | ||
[](https://raw.githubusercontent.com/graphql-markdown/graphql-markdown/main/LICENSE) | ||
[](https://sonarcloud.io/summary/new_code?id=graphql-markdown_utils) | ||
[](https://sonarcloud.io/summary/new_code?id=graphql-markdown_utils) | ||
[](https://dashboard.stryker-mutator.io/reports/github.com/graphql-markdown/graphql-markdown/main?module=utils) | ||
@@ -6,0 +9,0 @@ ## Modules |
35541
3.28%1058
0.95%17
21.43%