Skip to content

Commit bd74827

Browse files
committed
feat: update capitalization examples and syntax highlighting; enhance localization support for Japanese
1 parent 453c189 commit bd74827

6 files changed

Lines changed: 42 additions & 22 deletions

File tree

pages/src/pages/[lang]/capitalize.astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ const { lang } = Astro.params as { lang: Lang };
2424
<p set:html={t(lang, "cap.basicDesc")} />
2525
<CodeBlock
2626
lang="nsjs"
27-
code={`const name ^- ^2^3hello^2;\n// ^3h → H,残りはそのまま`}
27+
code={lang === "ja"
28+
? `const name ^- ^2^3hello^2;\n// ^3h → H,残りはそのまま`
29+
: `const name ^- ^2^3hello^2;\n// ^3h → H, rest stays as-is`}
2830
/>
2931
<p>{lang === "ja" ? "コンパイル後:" : "Compiles to:"}</p>
3032
<CodeBlock lang="javascript" code={`const name = "Hello";`} />

pages/src/pages/[lang]/classes.astro

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const { lang } = Astro.params as { lang: Lang };
3434
^]
3535
^]
3636
37-
const dog ^- new ^3animal^8^2Dog^2^9;
37+
const dog ^- new ^3animal^8^2^3dog^2^9;
3838
dog.speak^8^9;`}
3939
/>
4040
<p>{lang === "ja" ? "コンパイル後:" : "Compiles to:"}</p>
@@ -68,7 +68,7 @@ dog.speak();`}
6868
^]
6969
^]
7070
71-
const d ^- new ^3dog^8^2Rex^2^9;
71+
const d ^- new ^3dog^8^2^3rex^2^9;
7272
d.bark^8^9;`}
7373
/>
7474
<p>{lang === "ja" ? "コンパイル後:" : "Compiles to:"}</p>
@@ -92,30 +92,36 @@ d.bark();`}
9292
<p set:html={t(lang, "classes.methodDesc")} />
9393
<CodeBlock
9494
lang="nsjs"
95-
code={`class ^3counter ^[
96-
^;count ^- 0;
95+
code={`class ^3person ^[
96+
constructor^8name, age^9 ^[
97+
this.name ^- name;
98+
this.age ^- age;
99+
^]
97100
98-
get^3count^8^9 ^[
99-
return this.^;count;
101+
get^3info^8^9 ^[
102+
return ^@^4^[this.name^] ^8^4^[this.age^]^9^@;
100103
^]
101104
102-
set^3count^8value^9 ^[
103-
this.^;count ^- value;
105+
set^3name^8new^3name^9 ^[
106+
this.name ^- new^3name;
104107
^]
105108
^]`}
106109
/>
107110
<p>{lang === "ja" ? "コンパイル後:" : "Compiles to:"}</p>
108111
<CodeBlock
109112
lang="javascript"
110-
code={`class Counter {
111-
#count = 0;
113+
code={`class Person {
114+
constructor(name, age) {
115+
this.name = name;
116+
this.age = age;
117+
}
112118
113-
getCount() {
114-
return this.#count;
119+
getInfo() {
120+
return \`\${this.name} (\${this.age})\`;
115121
}
116122
117-
setCount(value) {
118-
this.#count = value;
123+
setName(newName) {
124+
this.name = newName;
119125
}
120126
}`}
121127
/>

pages/src/pages/[lang]/syntax.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const templateExprLabel =
9393

9494
<h2>{t(lang, "syntax.helloTitle")}</h2>
9595
<p>{t(lang, "syntax.helloInput")}</p>
96-
<CodeBlock lang="nsjs" code="console.log^8^2Hello World!^2^9;" />
96+
<CodeBlock lang="nsjs" code="console.log^8^2^3hello ^3world^1^2^9;" />
9797
<p>{t(lang, "syntax.helloOutput")}</p>
9898
<CodeBlock lang="javascript" code={`console.log("Hello World!");`} />
9999
</DocsLayout>

pages/src/pages/index.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ const lang: Lang = "en";
165165
<CodeBlock
166166
lang="nsjs"
167167
code={`// src/index.nsjs
168-
const name ^- ^2NoShift.js^2;
169-
console.log^8^2Hello from ^2 ^; name ^; ^2!^2^9;`}
168+
const name ^- ^2^3no^3shift.js^2;
169+
console.log^8^2^3hello from ^2 ^; name ^; ^2^1^2^9;`}
170170
/>
171171

172172
<p id="compiles-to">{t("en", "home.compilesTo")}</p>

vscode-extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "noshift-vscode",
33
"displayName": "NoShift.js",
44
"description": "Syntax highlighting + auto-complete for NoShift.js (.nsjs) files",
5-
"version": "0.4.2",
5+
"version": "0.4.3",
66
"publisher": "otoneko1102",
77
"engines": {
88
"vscode": "^1.70.0"

vscode-extension/syntaxes/noshift.tmLanguage.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,17 +288,29 @@
288288
"match": "(?:\\b|(?<=\\^\\d))(this|super|arguments)\\b"
289289
},
290290
{
291+
"comment": "UPPER_SNAKE_CASE constants",
291292
"name": "variable.other.constant.noshift",
292293
"match": "(?:\\b|(?<=\\^\\d))[A-Z][A-Z0-9_]{2,}\\b"
293294
},
294295
{
295-
"comment": "PascalCase: starts with ^3 (= uppercase first letter) or raw [A-Z]",
296+
"comment": "^3-capitalized ALL_CAPS constant (e.g. ^3m^3a^3x_^3s^3i^3z^3e)",
297+
"name": "variable.other.constant.noshift",
298+
"match": "(?:\\b|(?=\\^3))(?:\\^3[a-zA-Z])(?:\\^3[a-zA-Z0-9]|_)*(?![a-zA-Z0-9_$])"
299+
},
300+
{
301+
"comment": "Class/type name after class/extends/new keyword",
302+
"name": "entity.name.type.noshift",
303+
"match": "(?<=\\b(?:class|extends|new)\\s)((?:\\^3)?[a-zA-Z_$](?:(?:\\^3)?[a-zA-Z0-9_$])*)"
304+
},
305+
{
306+
"comment": "Raw PascalCase identifier (starts with uppercase letter)",
296307
"name": "entity.name.type.noshift",
297-
"match": "(?:\\b|(?<=\\^\\d)|(?=\\^3))(?:\\^3[a-zA-Z](?:(?:\\^3)?[a-zA-Z0-9_$])*|[A-Z][a-zA-Z0-9_$]*)"
308+
"match": "(?:\\b|(?<=\\^\\d))[A-Z][a-zA-Z0-9_$]*\\b"
298309
},
299310
{
311+
"comment": "Regular variable (may contain ^3 for camelCase)",
300312
"name": "variable.other.noshift",
301-
"match": "(?:\\b|(?<=\\^\\d))[a-zA-Z_$](?:(?:\\^3)?[a-zA-Z0-9_$])*"
313+
"match": "(?:\\b|(?<=\\^\\d)|(?=\\^3))(?:\\^3)?[a-zA-Z_$](?:(?:\\^3)?[a-zA-Z0-9_$])*"
302314
}
303315
]
304316
}

0 commit comments

Comments
 (0)