@scalar/code-highlight 0.0.19 → 0.0.20

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @scalar/code-highlight
2
2
 
3
+ ## 0.0.20
4
+
5
+ ### Patch Changes
6
+
7
+ - 109e320: fix: removes regex for highlight credentials
8
+
3
9
  ## 0.0.19
4
10
 
5
11
  ### Patch Changes
@@ -1,4 +1,7 @@
1
1
  import type { LanguageFn } from 'highlight.js';
2
+ /**
3
+ * Syntax highlights a code string using the `rehype-highlight` library.
4
+ */
2
5
  export declare function syntaxHighlight(codeString: string, options: {
3
6
  lang: string;
4
7
  languages: Record<string, LanguageFn>;
@@ -1 +1 @@
1
- {"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../src/code/highlight.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAQ9C,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;IACP,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IACrC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CACpC,UA8CF"}
1
+ {"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../src/code/highlight.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAQ9C;;GAEG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;IACP,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IACrC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CACpC,UAiDF"}
@@ -6,6 +6,9 @@ import { visit } from 'unist-util-visit';
6
6
  import { codeBlockLinesPlugin } from './line-numbers.js';
7
7
  import { rehypeHighlight } from '../rehype-highlight/rehype-highlight.js';
8
8
 
9
+ /**
10
+ * Syntax highlights a code string using the `rehype-highlight` library.
11
+ */
9
12
  function syntaxHighlight(codeString, options) {
10
13
  // Simple restriction on credentials to prevent unexpected behavior
11
14
  const credentials = (typeof options?.maskCredentials === 'string'
@@ -38,7 +41,9 @@ function syntaxHighlight(codeString, options) {
38
41
  const htmlString = html.toString();
39
42
  // Replace any credentials with a wrapper element
40
43
  return credentials.length
41
- ? htmlString.replace(new RegExp(credentials.join('|'), 'g'), (m) => `<span class="credentials">${m}</span>`)
44
+ ? credentials.reduce((acc, credential) => acc
45
+ .split(credential)
46
+ .join(`<span class="credentials">${credential}</span>`), htmlString)
42
47
  : htmlString;
43
48
  }
44
49
  /**
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "lowlight",
17
17
  "highlightjs"
18
18
  ],
19
- "version": "0.0.19",
19
+ "version": "0.0.20",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -93,7 +93,7 @@
93
93
  "vite": "^5.4.10",
94
94
  "vue": "^3.5.12",
95
95
  "@scalar/build-tooling": "0.1.12",
96
- "@scalar/themes": "0.9.58"
96
+ "@scalar/themes": "0.9.61"
97
97
  },
98
98
  "scripts": {
99
99
  "build": "scalar-build-rollup",