Code Hike Annotations
Code Hike Annotations
This post demonstrates every annotation type available in code blocks. Each annotation is triggered by a special comment inside a fenced code block.
Mark
Highlight specific lines or inline tokens with // !mark:
1function greet(name: string) {2return `Hello, ${name}!`;3}
Focus
Dim unfocused lines to draw attention with // !focus:
1function processItems(items: string[]) {2const results: string[] = [];3for (const item of items) {4results.push(item.toUpperCase());5}6return results;7}
Diff
Show additions and removals with // !diff + and // !diff -:
1function getApiUrl() {-2return "http://localhost:3000/api";+3return process.env.API_URL!;4}
Tooltip
Hover over a token for more info with // !tooltip:
1import { useState } from "react";
Link
Make tokens clickable with // !link:
1
Callout
Add callout boxes pointing at code with // !callout:
1function fibonacci(n: number): number {2if (n <= 1) return n;3return fibonacci(n - 1) + fibonacci(n - 2);This is a recursive call that extends the bounds of the overall text length4}
Fold
Collapse inline tokens with // !fold:
1const config = {2headers: ,3timeout: 5000,4};
Collapse
Collapse a range of lines with // !collapse:
1interface User {2id: string;3name: string;4}56function validateUser(user: User): boolean {11}1213function getUser(id: string): User {14return { id, name: "Alice" };15}
Class Name
Apply a custom CSS class to a line with // !className:
1// A styled comment line2const x = 42;
File Title
Pass a filename as the meta string to display a header:
1export default function Home() {2return <h1>Hello, world!</h1>;3}
Line Numbers
Line numbers appear on all code blocks automatically:
1def hello():2print("Hello from Python!")34hello()
Copy Button
Hover over any code block to see the copy button in the top-right corner. Try it on any example above!
A test
```ts
// !mark #ff0000
// !focus
function test() {
console.log("This is a test");
}
```