react-lib-tools 0.0.10 → 0.0.11
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/dist/react-lib-tools.cjs +3 -3
- package/dist/react-lib-tools.cjs.map +1 -1
- package/dist/react-lib-tools.d.ts +2 -0
- package/dist/react-lib-tools.js +13 -10
- package/dist/react-lib-tools.js.map +1 -1
- package/package.json +1 -1
- package/scripts/compile-examples.ts +4 -2
- package/scripts/utils/syntax-highlight.ts +7 -1
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import { syntaxHighlight } from "./utils/syntax-highlight.ts";
|
|
|
5
5
|
import { trimExcludedText } from "./utils/examples/trimExcludedText.ts";
|
|
6
6
|
|
|
7
7
|
export async function compileExamples({
|
|
8
|
-
fileExtensions = [".html", ".ts", ".tsx"],
|
|
8
|
+
fileExtensions = [".css", ".html", ".ts", ".tsx"],
|
|
9
9
|
inputPath = ["src", "routes"],
|
|
10
10
|
outputDirName = "examples"
|
|
11
11
|
}: {
|
|
@@ -45,7 +45,9 @@ export async function compileExamples({
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
let html;
|
|
48
|
-
if (file.endsWith(".
|
|
48
|
+
if (file.endsWith(".css")) {
|
|
49
|
+
html = await syntaxHighlight(rawText, "CSS");
|
|
50
|
+
} else if (file.endsWith(".html")) {
|
|
49
51
|
html = await syntaxHighlight(rawText, "HTML");
|
|
50
52
|
} else if (file.endsWith(".js") || file.endsWith(".jsx")) {
|
|
51
53
|
html = await syntaxHighlight(
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cssLanguage } from "@codemirror/lang-css";
|
|
1
2
|
import { htmlLanguage } from "@codemirror/lang-html";
|
|
2
3
|
import {
|
|
3
4
|
jsxLanguage,
|
|
@@ -16,7 +17,7 @@ type Token = {
|
|
|
16
17
|
value: string;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
export type Language = "HTML" | "JS" | "JSX" | "TS" | "TSX";
|
|
20
|
+
export type Language = "CSS" | "HTML" | "JS" | "JSX" | "TS" | "TSX";
|
|
20
21
|
|
|
21
22
|
type State = {
|
|
22
23
|
parsedTokens: Token[];
|
|
@@ -30,6 +31,11 @@ export async function syntaxHighlight(code: string, language: Language) {
|
|
|
30
31
|
let extension: LRLanguage;
|
|
31
32
|
let prettierParser: BuiltInParserName;
|
|
32
33
|
switch (language) {
|
|
34
|
+
case "CSS": {
|
|
35
|
+
extension = cssLanguage.configure({ dialect: "selfClosing" });
|
|
36
|
+
prettierParser = "css";
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
33
39
|
case "HTML": {
|
|
34
40
|
extension = htmlLanguage.configure({ dialect: "selfClosing" });
|
|
35
41
|
prettierParser = "html";
|