feat: add nushell support
I love this tool! I added a small modification to support my favourite shell, [`nushell`](https://www.nushell.sh/), a new kind of shell where everything is structured data.
After some polishing and adding tests, I thought it was time to contribute my changes back.
Thank you so much for creating this great tool, @maaslalani! 🙏
I hope my contribution is up to your standards. Please let me know if I should change anything.
## Summary
- Added nushell language support for syntax highlighting in slides
- Added nushell support for .nu file extension mapping with `nu` command
- Follows the same pattern as recent language additions (Haskell https://github.com/maaslalani/slides/pull/299, Scala https://github.com/maaslalani/slides/pull/298)
<img width="2168" height="1238" alt="slides with nushell" src="https://github.com/user-attachments/assets/db6f0b6e-5848-4a41-a6b6-0c33d12db230" />
## Code Structure
```
slides/
├── internal/
│ ├── code/
│ │ ├── languages.go # Enhanced with nushell support
│ │ ├── execute_test.go # Added nushell execution tests
│ └── syntax/ # New module for syntax highlighting
│ ├── nushell.go # Nushell highlighting logic
│ └── nushell_test.go # Comprehensive test suite
└── examples/
└── code_blocks.md # Enhanced nushell examples
```
## 🎨 How Syntax Highlighting Works
### The Problem
- Chroma (used by Glamour) doesn't natively support nushell syntax highlighting
- Code blocks with `nu` identifiers showed as plain text
### The Solution
1. **Preprocessing**: Before markdown is rendered, replace ````nu` with ````bash`
2. **Fallback**: Bash syntax highlighting provides reasonable highlighting for most nushell syntax
3. **Future-Proof**: System ready for native nushell support when available in Chroma
### Code Flow
```
Markdown Input → Syntax Preprocessing → Glamour/Chroma → Highlighted Output
↓ ↓ ↓ ↓
```nu → ```bash → Chroma → Highlighted
echo "hi" echo "hi" Lexer Code Block
``` ```
```
## Testing
- [x] Built and tested locally with `make test`
- [x] Verified compilation with `make build`
- [x] Test with actual nushell code blocks in markdown presentations
- [x] Added nushell syntax highlighting
```shell
make test
go test ./... -short
? github.com/maaslalani/slides [no test files]
? github.com/maaslalani/slides/internal/cmd [no test files]
? github.com/maaslalani/slides/internal/model [no test files]
? github.com/maaslalani/slides/internal/server [no test files]
ok github.com/maaslalani/slides/internal/code 0.752s
ok github.com/maaslalani/slides/internal/file (cached)
ok github.com/maaslalani/slides/internal/meta (cached)
ok github.com/maaslalani/slides/internal/navigation (cached)
ok github.com/maaslalani/slides/internal/process (cached)
ok github.com/maaslalani/slides/internal/syntax 0.552s
ok github.com/maaslalani/slides/styles (cached)
```
🤖 Created with the help of `Claude Sonnet 4`
合并状态:未合并 1 条评论