@scalar/code-highlight 0.0.25 → 0.0.27

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,17 @@
1
1
  # @scalar/code-highlight
2
2
 
3
+ ## 0.0.27
4
+
5
+ ### Patch Changes
6
+
7
+ - 799845f: feat(components): allow ScalarCodeblock to support different font sizes
8
+
9
+ ## 0.0.26
10
+
11
+ ### Patch Changes
12
+
13
+ - 0e888bc: feat: add dart to standard languages
14
+
3
15
  ## 0.0.25
4
16
 
5
17
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../src/code/highlight.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAW9C;;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,UA4CF"}
1
+ {"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../src/code/highlight.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAW9C;;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,UA+CF"}
@@ -39,7 +39,9 @@ function syntaxHighlight(codeString, options) {
39
39
  const htmlString = html.toString();
40
40
  // Replace any credentials with a wrapper element
41
41
  return credentials.length
42
- ? credentials.reduce((acc, credential) => acc.split(credential).join(`<span class="credentials">${credential}</span>`), htmlString)
42
+ ? credentials.reduce((acc, credential) => acc
43
+ .split(credential)
44
+ .join(`<span class="credential"><span class="credential-value">${credential}</span></span>`), htmlString)
43
45
  : htmlString;
44
46
  }
45
47
  /**
package/dist/css/code.css CHANGED
@@ -1,6 +1,6 @@
1
1
  .scalar-app {
2
- code.hljs * {
3
- font-size: var(--scalar-small);
2
+ :where(code.hljs) * {
3
+ font-size: inherit;
4
4
  font-family: var(--scalar-font-code);
5
5
  text-align: left;
6
6
  white-space: pre;
@@ -12,7 +12,7 @@
12
12
  }
13
13
  code.hljs {
14
14
  all: unset;
15
- font-size: var(--scalar-small);
15
+ font-size: inherit;
16
16
  color: var(--scalar-color-2);
17
17
  font-family: var(--scalar-font-code);
18
18
  display: inline-block;
@@ -139,15 +139,14 @@
139
139
  }
140
140
 
141
141
  /** Hide credentials */
142
- .credentials {
143
- font-size: 0 !important;
142
+ .credential .credential-value {
143
+ font-size: 0;
144
144
  color: transparent;
145
145
  }
146
146
 
147
147
  /** Show a few dots instead */
148
- .credentials::after {
148
+ .credential::after {
149
149
  content: "·····";
150
- font-size: var(--scalar-small);
151
150
  color: var(--scalar-color-3);
152
151
  user-select: none;
153
152
  }
@@ -15,9 +15,9 @@ import yaml from 'highlight.js/lib/languages/yaml';
15
15
  const basicLanguages = {
16
16
  bash,
17
17
  css,
18
+ html: xml,
18
19
  javascript,
19
20
  json,
20
- html: xml,
21
21
  less,
22
22
  markdown,
23
23
  plaintext,
@@ -25,8 +25,8 @@ const basicLanguages = {
25
25
  scss,
26
26
  shell,
27
27
  typescript,
28
- yaml,
29
28
  xml,
29
+ yaml,
30
30
  };
31
31
 
32
32
  export { basicLanguages };
@@ -1 +1 @@
1
- {"version":3,"file":"standard.d.ts","sourceRoot":"","sources":["../../src/languages/standard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAsC9C,QAAA,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAqCjD,CAAA;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
1
+ {"version":3,"file":"standard.d.ts","sourceRoot":"","sources":["../../src/languages/standard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAuC9C,QAAA,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAsCjD,CAAA;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
@@ -4,6 +4,7 @@ import clojure from 'highlight.js/lib/languages/clojure';
4
4
  import cpp from 'highlight.js/lib/languages/cpp';
5
5
  import csharp from 'highlight.js/lib/languages/csharp';
6
6
  import css from 'highlight.js/lib/languages/css';
7
+ import dart from 'highlight.js/lib/languages/dart';
7
8
  import elixir from 'highlight.js/lib/languages/elixir';
8
9
  import go from 'highlight.js/lib/languages/go';
9
10
  import graphql from 'highlight.js/lib/languages/graphql';
@@ -39,9 +40,10 @@ const standardLanguages = {
39
40
  c,
40
41
  clojure,
41
42
  cpp,
43
+ csharp,
42
44
  css,
43
45
  curl,
44
- csharp,
46
+ dart,
45
47
  elixir,
46
48
  go,
47
49
  graphql,
@@ -1 +1 @@
1
- {"version":3,"file":"rehype-alert.d.ts","sourceRoot":"","sources":["../../src/rehype-alert/rehype-alert.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AASjC,wBAAgB,WAAW,WACX,IAAI,UAkFnB"}
1
+ {"version":3,"file":"rehype-alert.d.ts","sourceRoot":"","sources":["../../src/rehype-alert/rehype-alert.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AASjC,wBAAgB,WAAW,WACX,IAAI,UAgGnB"}
@@ -13,29 +13,36 @@ function rehypeAlert() {
13
13
  }
14
14
  // Find the first non-whitespace child
15
15
  const headIndex = node.children.findIndex((child) => !isWhitespace(child));
16
- if (headIndex === -1)
16
+ if (headIndex === -1) {
17
17
  return;
18
+ }
18
19
  const head = node.children[headIndex];
19
- if (!head || head.type !== 'element' || head.tagName !== 'p')
20
+ if (!head || head.type !== 'element' || head.tagName !== 'p') {
20
21
  return;
22
+ }
21
23
  const text = head.children[0];
22
- if (!text || text.type !== 'text' || !text.value.startsWith('[!'))
24
+ if (!text || text.type !== 'text' || !text.value.startsWith('[!')) {
23
25
  return;
26
+ }
24
27
  const end = text.value.indexOf(']');
25
- if (end === -1)
28
+ if (end === -1) {
26
29
  return;
30
+ }
27
31
  // Extract the alert type
28
32
  const alertType = text.value.slice(2, end).toLowerCase();
29
- if (!ALERT_TYPES.includes(alertType))
33
+ if (!ALERT_TYPES.includes(alertType)) {
30
34
  return;
35
+ }
31
36
  // Remove the blockquote if it's empty
32
37
  if (end + 1 === text.value.length) {
33
38
  const next = head.children[1];
34
39
  if (next) {
35
- if (next.type !== 'element' || next.tagName !== 'br')
40
+ if (next.type !== 'element' || next.tagName !== 'br') {
36
41
  return;
37
- if (!head.children[2])
42
+ }
43
+ if (!head.children[2]) {
38
44
  return;
45
+ }
39
46
  head.children = head.children.slice(2);
40
47
  const node = head.children[0];
41
48
  if (node && node.type === 'text' && node.value.charAt(0) === '\n') {
@@ -1 +1 @@
1
- {"version":3,"file":"rehype-highlight.d.ts","sourceRoot":"","sources":["../../src/rehype-highlight/rehype-highlight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA2B,IAAI,EAAE,MAAM,MAAM,CAAA;AAEzD,OAAO,EAAE,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAIlC,KAAK,gBAAgB,GAAG;IACtB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,U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C,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAA;IACrF,2EAA2E;IAC3E,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAA;IACnE,yGAAyG;IACzG,SAAS,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,CAAA;IACpD,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAClC,qFAAqF;IACrF,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,CAAA;IACjD,qCAAqC;IACrC,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAID;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,IAAI,GAAG,SAAS,UAuBvE,IAAI,QAAQ,KAAK,UAsDhC"}
@@ -20,8 +20,9 @@ function rehypeHighlight(options) {
20
20
  let name = 'hljs';
21
21
  // Create a lowlight instance if not provided
22
22
  const lowlight = options?.lowlight ?? createLowlight(languages);
23
- if (aliases)
23
+ if (aliases) {
24
24
  lowlight.registerAlias(aliases);
25
+ }
25
26
  if (prefix) {
26
27
  const pos = prefix.indexOf('-');
27
28
  name = pos > -1 ? prefix.slice(0, pos) : prefix;
@@ -75,18 +76,23 @@ function rehypeHighlight(options) {
75
76
  /** Get the programming language of `node` or an empty string */
76
77
  function language(node) {
77
78
  const list = node.properties.className;
78
- if (!Array.isArray(list))
79
+ if (!Array.isArray(list)) {
79
80
  return '';
81
+ }
80
82
  const name = list.reduce((result, _item) => {
81
- if (result)
83
+ if (result) {
82
84
  return result;
85
+ }
83
86
  const item = String(_item);
84
- if (item === 'no-highlight' || item === 'nohighlight')
87
+ if (item === 'no-highlight' || item === 'nohighlight') {
85
88
  return 'no-highlight';
86
- if (item.slice(0, 5) === 'lang-')
89
+ }
90
+ if (item.slice(0, 5) === 'lang-') {
87
91
  return item.slice(5);
88
- if (item.slice(0, 9) === 'language-')
92
+ }
93
+ if (item.slice(0, 9) === 'language-') {
89
94
  return item.slice(9);
95
+ }
90
96
  return result;
91
97
  }, '');
92
98
  return lowlightLanguageMappings[name || ''] || name;
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "lowlight",
17
17
  "highlightjs"
18
18
  ],
19
- "version": "0.0.25",
19
+ "version": "0.0.27",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -98,7 +98,7 @@
98
98
  "vite": "^5.4.10",
99
99
  "vue": "^3.5.12",
100
100
  "@scalar/build-tooling": "0.1.17",
101
- "@scalar/themes": "0.9.78"
101
+ "@scalar/themes": "0.9.84"
102
102
  },
103
103
  "scripts": {
104
104
  "build": "scalar-build-rollup",