summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mfm/parse/core/syntax-highlighter.ts4
-rw-r--r--src/prelude/string.ts3
2 files changed, 6 insertions, 1 deletions
diff --git a/src/mfm/parse/core/syntax-highlighter.ts b/src/mfm/parse/core/syntax-highlighter.ts
index 2b13608d2b..c5157ca1d3 100644
--- a/src/mfm/parse/core/syntax-highlighter.ts
+++ b/src/mfm/parse/core/syntax-highlighter.ts
@@ -1,3 +1,5 @@
+import { capitalize } from "../../../prelude/string";
+
function escape(text: string) {
return text
.replace(/>/g, '>')
@@ -89,7 +91,7 @@ const _keywords = [
];
const keywords = _keywords
- .concat(_keywords.map(k => k[0].toUpperCase() + k.substr(1)))
+ .concat(_keywords.map(capitalize))
.concat(_keywords.map(k => k.toUpperCase()))
.sort((a, b) => b.length - a.length);
diff --git a/src/prelude/string.ts b/src/prelude/string.ts
new file mode 100644
index 0000000000..2b89304f16
--- /dev/null
+++ b/src/prelude/string.ts
@@ -0,0 +1,3 @@
+export function capitalize(s: string): string {
+ return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
+}