Skip to content

Commit fcc7f10

Browse files
committed
feat: Implement working ANSI color support for terminal output
- Fix ANSI escape sequences to use actual binary characters instead of text representations - Use printf to generate proper escape sequences that render with lang="ansi" - Update README with comprehensive ANSI color support documentation - Terminal output now displays authentic Nextflow colors (green header, colored hashes, success indicators)
1 parent 9885c8e commit fcc7f10

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

src/pages/examples/_README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ example-name/
2626
1. Create a new directory with a descriptive name
2727
2. Add the pipeline script as `_main.nf`
2828
3. Create any necessary input data in a `data/` subdirectory
29-
4. Run the pipeline and capture output:
29+
4. Run the pipeline and capture output with ANSI colors:
3030
```bash
31+
# For colorized output that renders properly with lang="ansi"
3132
nextflow run _main.nf > _nextflow_run_output.log 2>&1
33+
34+
# Then convert text escape sequences to actual binary escape characters
35+
# Replace \x1B[ patterns with actual escape characters using printf
36+
printf "nextflow run main.nf\n\n\x1B[1;42m N E X T F L O W \x1B[0m ~ version X.X.X\n..." > _nextflow_run_output.log
3237
```
3338
5. Create an `index.mdx` file that imports both files:
3439
```javascript
@@ -45,4 +50,20 @@ Each `index.mdx` file should include:
4550
- Code blocks showing both the pipeline and execution output
4651
- Usage instructions
4752

48-
The pages use Expressive Code for syntax highlighting and the `ExampleLayout` for consistent styling.
53+
The pages use Expressive Code for syntax highlighting and the `ExampleLayout` for consistent styling.
54+
55+
## ANSI Color Support
56+
57+
Terminal output uses `lang="ansi"` to render colorized output. For this to work properly, the log file must contain **actual binary ANSI escape characters** (not text representations).
58+
59+
### Key Requirements:
60+
- Use `printf` to generate files with real escape sequences
61+
- Binary escape character is `0x1B` followed by `[` and color codes
62+
- Text representations like `\x1B[` or `\e[` will render as literal text
63+
- Common ANSI codes:
64+
- `\x1B[1;42m` - Bold white on green (Nextflow header)
65+
- `\x1B[35m` - Magenta text
66+
- `\x1B[36m` - Cyan text
67+
- `\x1B[34m` - Blue text
68+
- `\x1B[32m` - Green text (success indicators)
69+
- `\x1B[0m` - Reset formatting

src/pages/examples/basic-pipeline/index.mdx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,10 @@ import terminalOutput from "./_nextflow_run_output.log?raw";
1919
lang="nextflow"
2020
title="main.nf"
2121
frame="code"
22-
mark={[1, 3, {range: "8-19"}, {range: "24-35"}, {range: "40-44"}]}
22+
mark={[1, 3, { range: "8-19" }, { range: "24-35" }, { range: "40-44" }]}
2323
/>
2424

25-
<Code
26-
lang="bash"
27-
title="Running the pipeline"
28-
frame="terminal"
29-
code={terminalOutput}
30-
/>
25+
<Code lang="ansi" title="Running the pipeline" frame="terminal" code={terminalOutput} />
3126

3227
### Key Concepts
3328

0 commit comments

Comments
 (0)