Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/mdx/dev/files.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from "fs"
import { remarkCodeHike } from "../src/index"
import { compile } from "@mdx-js/mdx"
import theme from "shiki/themes/nord.json"
import theme from "shiki/themes/rose-pine-moon.json"
import { withDebugger } from "mdx-debugger"

export async function getFiles() {
Expand Down
10 changes: 9 additions & 1 deletion packages/mdx/src/mini-editor/editor-frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const EditorFrame = React.forwardRef<
style={{
background: getColor(
theme,
ColorName.EditorGroupHeaderBackground
ColorName.EditorBackground
),
...style,
}}
Expand All @@ -72,6 +72,10 @@ export const EditorFrame = React.forwardRef<
className={"ch-frame-title-bar"}
style={{
color: getColor(theme, ColorName.IconForeground),
background: getColor(
theme,
ColorName.EditorGroupHeaderBackground
),
}}
>
<TabsContainer
Expand All @@ -98,6 +102,10 @@ export const EditorFrame = React.forwardRef<
theme,
ColorName.IconForeground
),
background: getColor(
theme,
ColorName.EditorGroupHeaderBackground
),
}}
>
<TabsContainer
Expand Down
24 changes: 18 additions & 6 deletions packages/mdx/src/remark/comment-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,25 @@ export function getCommentData(
}
}

function getTextAfter(
line: Code["lines"][0],
prefix: string
) {
const firstIndex = line.tokens.findIndex(t =>
t.content.trim().startsWith(prefix)
)
if (firstIndex === -1) {
return undefined
}
return line.tokens
.slice(firstIndex)
.map(t => t.content)
.join("")
}

const commentRegex = /\/\/\s+(\w+)(\S*)\s*(.*)/
function otherComment(line: Code["lines"][0]) {
const comment = line.tokens.find(t =>
t.content.trim().startsWith("//")
)?.content
const comment = getTextAfter(line, "//")

if (!comment) {
return []
Expand All @@ -56,9 +70,7 @@ const bashLikeLangs = [
]
const bashLikeCommentRegex = /#\s+(\w+)(\S*)\s*(.*)/
function bashLikeComment(line: Code["lines"][0]) {
const comment = line.tokens.find(t =>
t.content.trim().startsWith("#")
)?.content
const comment = getTextAfter(line, "#")

if (!comment) {
return []
Expand Down
2 changes: 1 addition & 1 deletion playground/src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function App() {
<CodeHikeLogo />
<h1>
Code Hike
<span>v0.5.1</span>
<span>v0.5.2</span>
</h1>
</a>
<a href="https://codehike.org/docs">Docs</a>
Expand Down