A simple markdown viewer web application built with Go, using:
- templ for HTML templating
- goldmark for markdown processing with syntax highlighting
- Pico CSS for beautiful, semantic styling
- urfave/cli/v2 for command-line interface
- 📁 Case-insensitive file matching - Access files without worrying about exact case
- 🎨 Beautiful styling with Pico CSS framework
- 🌓 Dark/light mode support automatically
- 🔍 Syntax highlighting for code blocks
- 📋 GitHub Flavored Markdown support including:
- Tables
- Task lists
- Strikethrough
- Auto-linking
- Footnotes
- Definition lists
- 📊 Mermaid diagrams with client-side rendering support:
- Flowcharts
- Sequence diagrams
- Pie charts
- Class diagrams
- And all other Mermaid diagram types
- 📱 Responsive design works on mobile and desktop
- 🚀 Fast and lightweight - pure Go with minimal dependencies
- Clone or download this application
- Install dependencies:
go mod download
- Generate templates:
templ generate
- Build the application:
go build -o mdviewer
./mdviewerThis starts the server on port 8888 serving markdown files from the current directory.
./mdviewer --dir /path/to/markdown/files --port 3000--dir, -d: Directory containing markdown files (default: current directory)--port, -p: Port to serve on (default: 8888)--help, -h: Show help
The application recognizes these markdown file extensions:
.md.markdown.mdown.mkd.mkdn.mdwn.mdtxt.mdtext
Files can be accessed via URLs without the markdown extension. For example:
README.md→http://localhost:8888/READMEdocs/guide.md→http://localhost:8888/docs/guide
The matching is case-insensitive, so readme, README, or ReAdMe will all match README.md.
MDViewer supports Mermaid diagrams with client-side rendering. Simply use fenced code blocks with the mermaid language:
```mermaid
graph TD
A[Start] --> B{Decision}
B -->|Yes| C[Success]
B -->|No| D[Try Again]
D --> A
``````mermaid
sequenceDiagram
participant User
participant App
participant Server
User->>App: Request
App->>Server: Process
Server->>App: Response
App->>User: Display
```Diagrams are rendered client-side using MermaidJS, so no server-side processing is required. All diagram types supported by Mermaid are available.
- Create some markdown files in a directory
- Run the server:
./mdviewer --dir ./my-docs - Open your browser to
http://localhost:8888 - Browse and view your markdown files with beautiful formatting!
To run in development mode with live reloading:
templ generate --watch --proxy="http://localhost:8888" --cmd="go run ."This will:
- Watch for changes to
.templfiles and regenerate Go code - Restart the server when Go files change
- Provide live browser reloading