Skip to content

Commit

Permalink
support c/c++
Browse files Browse the repository at this point in the history
  • Loading branch information
JSerZANP committed Aug 13, 2023
1 parent 8080a35 commit 4917e07
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
28 changes: 26 additions & 2 deletions examples/web/components/CodeSnippet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const ALL_LANGS = [
// "bibtex",
// "bicep",
// "blade",
// "c",
"c",
// "cadence",
// "cdc",
// "clarity",
Expand All @@ -48,7 +48,7 @@ const ALL_LANGS = [
// "codeql",
// "ql",
// "coffee",
// "cpp",
"cpp",
// "crystal",
// "csharp",
// "c#",
Expand Down Expand Up @@ -585,6 +585,30 @@ function ThemePicker({
}

const defaultCode = {
c: `
// @dim
#include <stdio.h>
int main() {
int x = 10;
// -----------
// ^
// [Hello World!]
return 0;
}
`,
cpp: `
// @dim
#include <iostream>
int main() {
int x = 10;
// -----------
// ^
// [Hello World!]
return 0;
}
`,
javascript: `// @dim
import { useState } from 'react';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
```python annotate
// @dim
#include <stdio.h>

int main() {
int x = 10;
// -----------
// ^
// [Hello World!]
return 0;
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<pre class="shiki github-light" style="color:#24292e;background-color:#fff"><div class="code-container"><code><div class="line"><span style="color: #D73A49">//</span><span style="color: #24292E"> </span><span style="color: #D73A49">@</span><span style="color: #24292E">dim</span></div><div class="line"><span style="color: #6A737D">#include &lt;stdio.h&gt;</span></div><div class="line"></div><div class="line"><span style="color: #005CC5">int</span><span style="color: #24292E"> main() {</span></div><div class="line"><span style="color: #24292E"> </span><span style="color: #005CC5">int</span><span style="color: #24292E"> x = </span><span style="color: #005CC5">10</span><span style="color: #24292E">;</span></div><div class="line"><span style="color: #D73A49">//</span><span style="color: #24292E"> </span><span style="color: #B31D28">----------</span><span style="color: #D73A49">-</span></div><div class="line"><span style="color: #D73A49">//</span><span style="color: #24292E"> </span><span style="color: #D73A49">^</span></div><div class="line"><span style="color: #D73A49">//</span><span style="color: #24292E"> [Hello World!]</span></div><div class="line"><span style="color: #24292E"> </span><span style="color: #D73A49">return</span><span style="color: #24292E"> </span><span style="color: #005CC5">0</span><span style="color: #24292E">;</span></div><div class="line"><span style="color: #24292E">}</span></div></code></div></pre>
4 changes: 3 additions & 1 deletion packages/remark-shaku-code-annotate/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ function parseComment(line: IThemedToken[]): null | {
// find the first explanation that is not element tag
if (
explanation.scopes.every(
(scope) => !scope.scopeName.startsWith("punctuation.definition")
(scope) =>
!scope.scopeName.startsWith("punctuation.definition") &&
!isWhitespace(explanation.content)
)
) {
body = explanation.content;
Expand Down

1 comment on commit 4917e07

@vercel
Copy link

@vercel vercel bot commented on 4917e07 Aug 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

shaku-web – ./

shaku-web.vercel.app
shaku-web-git-main-jserzanp.vercel.app
shaku-web-jserzanp.vercel.app

Please sign in to comment.