Skip to content

Commit e4cf6e8

Browse files
committed
Add syntax highlighting for web and data languages
1 parent 9c1dbe6 commit e4cf6e8

30 files changed

Lines changed: 1210 additions & 1 deletion

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM node:22-alpine AS dependencies
2+
3+
WORKDIR /app
4+
5+
RUN corepack enable
6+
7+
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
8+
COPY anycode/package.json anycode/package.json
9+
COPY anycode-base/package.json anycode-base/package.json
10+
COPY anycode-react/package.json anycode-react/package.json
11+
12+
RUN pnpm install --frozen-lockfile
13+
14+
FROM dependencies AS build
15+
16+
ARG APP_ENV=production
17+
ENV NODE_ENV=${APP_ENV}
18+
19+
COPY . .
20+
21+
RUN pnpm --dir anycode build
22+
23+
FROM node:22-alpine AS runtime
24+
25+
WORKDIR /app
26+
ENV NODE_ENV=production
27+
28+
COPY --from=build /app/anycode/dist ./dist
29+
30+
EXPOSE 3000
31+
32+
CMD ["node", "server.js"]

TestComponent.vue

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<template>
2+
<main class="counter">
3+
<h1>{{ title }}</h1>
4+
5+
<button
6+
class="counter__button"
7+
:disabled="count >= limit"
8+
@click="increment"
9+
>
10+
Count: {{ count }}
11+
</button>
12+
13+
<p v-if="count >= limit" class="counter__message">
14+
Limit reached
15+
</p>
16+
17+
<ul>
18+
<li v-for="item in history" :key="item">
19+
{{ item }}
20+
</li>
21+
</ul>
22+
</main>
23+
</template>
24+
25+
<script setup lang="ts">
26+
import { computed, ref } from "vue";
27+
28+
const limit = 5;
29+
const count = ref<number>(0);
30+
const history = ref<number[]>([]);
31+
32+
const title = computed(() => `Vue counter: ${count.value}/${limit}`);
33+
34+
function increment(): void {
35+
if (count.value >= limit) return;
36+
37+
count.value += 1;
38+
history.value.push(count.value);
39+
}
40+
</script>
41+
42+
<style scoped>
43+
.counter {
44+
display: grid;
45+
gap: 12px;
46+
max-width: 420px;
47+
padding: 24px;
48+
}
49+
50+
.counter__button {
51+
color: white;
52+
background: #42b883;
53+
border: 0;
54+
border-radius: 6px;
55+
padding: 10px 16px;
56+
}
57+
58+
.counter__button:disabled {
59+
cursor: not-allowed;
60+
opacity: 0.5;
61+
}
62+
63+
.counter__message {
64+
color: #e06c75;
65+
}
66+
</style>

anycode-base/src/code.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ import zig from './langs/zig';
4141
import csharp from './langs/csharp';
4242
import c from './langs/c';
4343
import cpp from './langs/cpp';
44+
import markdown from './langs/markdown';
45+
import markdownInline from './langs/markdown_inline';
46+
import php from './langs/php';
47+
import ruby from './langs/ruby';
48+
import vue from './langs/vue';
49+
import dockerfile from './langs/dockerfile';
50+
import sql from './langs/sql';
4451

4552
export enum Operation {
4653
Insert = "insert",
@@ -651,6 +658,13 @@ export class Code {
651658
if (lang === 'csharp') return csharp
652659
if (lang === 'c') return c
653660
if (lang === 'cpp') return cpp
661+
if (lang === 'markdown') return markdown
662+
if (lang === 'markdown_inline') return markdownInline
663+
if (lang === 'php') return php
664+
if (lang === 'ruby') return ruby
665+
if (lang === 'vue') return vue
666+
if (lang === 'dockerfile') return dockerfile
667+
if (lang === 'sql') return sql
654668
return null
655669
}
656670

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import type { Lang } from "../lang";
2+
3+
const query = `
4+
[
5+
"FROM"
6+
"AS"
7+
"RUN"
8+
"CMD"
9+
"LABEL"
10+
"EXPOSE"
11+
"ENV"
12+
"ADD"
13+
"COPY"
14+
"ENTRYPOINT"
15+
"VOLUME"
16+
"USER"
17+
"WORKDIR"
18+
"ARG"
19+
"ONBUILD"
20+
"STOPSIGNAL"
21+
"HEALTHCHECK"
22+
"SHELL"
23+
"MAINTAINER"
24+
"CROSS_BUILD"
25+
(heredoc_marker)
26+
(heredoc_end)
27+
] @keyword
28+
29+
(comment) @comment
30+
31+
[
32+
(double_quoted_string)
33+
(single_quoted_string)
34+
(json_string)
35+
(heredoc_line)
36+
] @string
37+
38+
(image_name) @type
39+
(image_tag) @constant
40+
(image_digest) @constant
41+
(image_alias) @type
42+
43+
[
44+
(path)
45+
(expose_port)
46+
] @string.special
47+
48+
(expansion
49+
(variable) @variable)
50+
51+
[
52+
":"
53+
"@"
54+
"="
55+
] @operator
56+
57+
(run_instruction
58+
(shell_command) @injection.content.bash)
59+
60+
(cmd_instruction
61+
(shell_command) @injection.content.bash)
62+
63+
(entrypoint_instruction
64+
(shell_command) @injection.content.bash)
65+
`;
66+
67+
const foldsQuery = `
68+
[
69+
(run_instruction)
70+
(cmd_instruction)
71+
(entrypoint_instruction)
72+
(copy_instruction)
73+
(add_instruction)
74+
(heredoc_block)
75+
] @fold
76+
`;
77+
78+
const indent = { width: 4, unit: " " };
79+
const comment = "#";
80+
81+
export default {
82+
query, foldsQuery, indent, comment
83+
} satisfies Lang;

anycode-base/src/langs/markdown.ts

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import type { Lang } from "../lang";
2+
3+
const query = `
4+
(setext_heading
5+
(paragraph) @type
6+
[(setext_h1_underline) (setext_h2_underline)] @punctuation.special)
7+
8+
(atx_heading) @type
9+
[
10+
(atx_h1_marker)
11+
(atx_h2_marker)
12+
(atx_h3_marker)
13+
(atx_h4_marker)
14+
(atx_h5_marker)
15+
(atx_h6_marker)
16+
] @punctuation.special
17+
18+
(info_string) @type
19+
(indented_code_block) @string
20+
(fenced_code_block) @string
21+
(fenced_code_block_delimiter) @punctuation.special
22+
23+
[
24+
(link_destination)
25+
(link_title)
26+
(link_label)
27+
] @string.special
28+
29+
[
30+
(list_marker_plus)
31+
(list_marker_minus)
32+
(list_marker_star)
33+
(list_marker_dot)
34+
(list_marker_parenthesis)
35+
(task_list_marker_unchecked)
36+
(task_list_marker_checked)
37+
] @punctuation.special
38+
39+
(thematic_break) @punctuation.special
40+
(block_quote) @comment
41+
(block_quote_marker) @punctuation.special
42+
(backslash_escape) @string.escape
43+
44+
((html_block) @injection.content.html)
45+
46+
([
47+
(inline)
48+
(pipe_table_cell)
49+
] @injection.content.markdown_inline)
50+
51+
(fenced_code_block
52+
(info_string (language) @_language)
53+
(code_fence_content) @injection.content.javascript
54+
(#any-of? @_language "js" "jsx" "javascript"))
55+
56+
(fenced_code_block
57+
(info_string (language) @_language)
58+
(code_fence_content) @injection.content.typescript
59+
(#any-of? @_language "ts" "tsx" "typescript"))
60+
61+
(fenced_code_block
62+
(info_string (language) @_language)
63+
(code_fence_content) @injection.content.python
64+
(#any-of? @_language "py" "python"))
65+
66+
(fenced_code_block
67+
(info_string (language) @_language)
68+
(code_fence_content) @injection.content.rust
69+
(#eq? @_language "rust"))
70+
71+
(fenced_code_block
72+
(info_string (language) @_language)
73+
(code_fence_content) @injection.content.bash
74+
(#any-of? @_language "bash" "sh" "shell"))
75+
76+
(fenced_code_block
77+
(info_string (language) @_language)
78+
(code_fence_content) @injection.content.json
79+
(#eq? @_language "json"))
80+
81+
(fenced_code_block
82+
(info_string (language) @_language)
83+
(code_fence_content) @injection.content.yaml
84+
(#any-of? @_language "yaml" "yml"))
85+
86+
(fenced_code_block
87+
(info_string (language) @_language)
88+
(code_fence_content) @injection.content.html
89+
(#eq? @_language "html"))
90+
91+
(fenced_code_block
92+
(info_string (language) @_language)
93+
(code_fence_content) @injection.content.css
94+
(#eq? @_language "css"))
95+
`;
96+
97+
const foldsQuery = `
98+
[
99+
(section)
100+
(fenced_code_block)
101+
(block_quote)
102+
(list)
103+
] @fold
104+
`;
105+
106+
const indent = { width: 2, unit: " " };
107+
const comment = "";
108+
109+
export default {
110+
query, foldsQuery, indent, comment
111+
} satisfies Lang;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import type { Lang } from "../lang";
2+
3+
const query = `
4+
(code_span) @string
5+
(code_span_delimiter) @punctuation.special
6+
7+
(emphasis) @keyword
8+
(strong_emphasis) @type
9+
(strikethrough) @comment
10+
(emphasis_delimiter) @punctuation.special
11+
12+
[
13+
(backslash_escape)
14+
(hard_line_break)
15+
] @string.escape
16+
17+
[
18+
(link_destination)
19+
(uri_autolink)
20+
] @string.special
21+
22+
[
23+
(link_label)
24+
(link_text)
25+
(link_title)
26+
(image_description)
27+
] @string
28+
29+
(entity_reference) @constant
30+
`;
31+
32+
const indent = { width: 2, unit: " " };
33+
const comment = "";
34+
35+
export default {
36+
query, indent, comment
37+
} satisfies Lang;

0 commit comments

Comments
 (0)