CLI tool that renders markdown files in the browser with mermaid diagram support. Rails 8 + Hotwire.
  • HTML 54.9%
  • Ruby 30.4%
  • CSS 6.3%
  • Dockerfile 4%
  • JavaScript 3.2%
  • Other 1.2%
Find a file
Lucas Draney be9a3de47c
Some checks are pending
CI / scan_ruby (push) Waiting to run
CI / scan_js (push) Waiting to run
CI / lint (push) Waiting to run
Bind puma to 0.0.0.0 and allow Tailscale host (#6)
2026-05-19 11:18:07 +00:00
.github init: mdview -- CLI markdown renderer with mermaid support 2026-05-18 20:20:21 -06:00
app Support relative markdown link navigation (#4) 2026-05-19 02:34:07 +00:00
bin docs: add learning docs, fix CLI symlink resolution 2026-05-18 20:50:26 -06:00
config Bind puma to 0.0.0.0 and allow Tailscale host (#6) 2026-05-19 11:18:07 +00:00
docs docs: add learning docs, fix CLI symlink resolution 2026-05-18 20:50:26 -06:00
lib/tasks init: mdview -- CLI markdown renderer with mermaid support 2026-05-18 20:20:21 -06:00
log init: mdview -- CLI markdown renderer with mermaid support 2026-05-18 20:20:21 -06:00
public init: mdview -- CLI markdown renderer with mermaid support 2026-05-18 20:20:21 -06:00
script init: mdview -- CLI markdown renderer with mermaid support 2026-05-18 20:20:21 -06:00
tmp init: mdview -- CLI markdown renderer with mermaid support 2026-05-18 20:20:21 -06:00
vendor init: mdview -- CLI markdown renderer with mermaid support 2026-05-18 20:20:21 -06:00
.dockerignore init: mdview -- CLI markdown renderer with mermaid support 2026-05-18 20:20:21 -06:00
.gitattributes init: mdview -- CLI markdown renderer with mermaid support 2026-05-18 20:20:21 -06:00
.gitignore init: mdview -- CLI markdown renderer with mermaid support 2026-05-18 20:20:21 -06:00
.rubocop.yml init: mdview -- CLI markdown renderer with mermaid support 2026-05-18 20:20:21 -06:00
.ruby-version init: mdview -- CLI markdown renderer with mermaid support 2026-05-18 20:20:21 -06:00
config.ru init: mdview -- CLI markdown renderer with mermaid support 2026-05-18 20:20:21 -06:00
Dockerfile init: mdview -- CLI markdown renderer with mermaid support 2026-05-18 20:20:21 -06:00
Gemfile init: mdview -- CLI markdown renderer with mermaid support 2026-05-18 20:20:21 -06:00
Gemfile.lock init: mdview -- CLI markdown renderer with mermaid support 2026-05-18 20:20:21 -06:00
Rakefile init: mdview -- CLI markdown renderer with mermaid support 2026-05-18 20:20:21 -06:00
README.md docs: add learning docs, fix CLI symlink resolution 2026-05-18 20:50:26 -06:00

mdview

CLI tool that renders any markdown file in the browser with mermaid diagram support. Built on Rails 8 + Hotwire. Gruvbox dark theme.

Install

cd ~/mdview
bundle install
ln -sf ~/mdview/bin/mdview ~/.local/bin/mdview

Requires Ruby 3.4+ and Bundler. No Node.js, no database, no other system dependencies. bundle install handles everything.

Usage

mdview path/to/file.md

Opens http://localhost:3137. Re-running mdview with a different file automatically stops the previous server and starts a new one -- no manual cleanup needed.

Relative links to other .md files work. If your README links to docs/guide.md, clicking it navigates to the rendered guide. Click "back to root" to return.

Ctrl-C stops the server.

mdview ~/mdview/README.md     # read these docs through the tool itself
mdview ~/some-project/README.md   # render any project's docs

Docs

Learn how this app works -- and learn Rails along the way:

  • The Filetree -- every file, what it does, what's idle, what "convention" means, and why Rails ships so much
  • Dependencies -- every gem, what it does, which ones we actually use, and how Gemfile/Bundler work
  • Request Lifecycle -- what happens from URL to rendered page
  • MVC in Practice -- how Model-View-Controller plays out in this app
  • Hotwire Explained -- Turbo Drive, Stimulus, and importmaps
  • CSS Architecture -- design tokens, Propshaft, and the gruvbox theme
  • File Map -- quick reference table of every file

Architecture

graph TD
    CLI["bin/mdview file.md"] --> ENV["MDVIEW_FILE env var"]
    ENV --> Puma["Puma :3137"]
    Puma --> Router["config/routes.rb"]
    Router --> Controller["MarkdownController"]
    Controller --> Redcarpet["Redcarpet: MD → HTML"]
    Redcarpet --> LinkRewrite["Rewrite .md links"]
    LinkRewrite --> ERB["show.html.erb"]
    ERB --> Layout["application.html.erb"]
    Layout --> Browser["Browser"]
    Browser --> Stimulus["mermaid_controller.js"]
    Stimulus --> MermaidJS["Mermaid.js CDN"]
    MermaidJS --> SVG["SVG diagrams"]

    style CLI fill:#3c3836,stroke:#d79921,color:#ebdbb2
    style Browser fill:#3c3836,stroke:#8ec07c,color:#ebdbb2
    style Controller fill:#3c3836,stroke:#83a598,color:#ebdbb2

Stack

Layer Tool Role
Language Ruby 3.4 Server-side logic
Framework Rails 8.1 MVC structure, routing, asset pipeline
Server Puma HTTP server (listens on :3137)
Markdown Redcarpet Converts .md to HTML server-side
Diagrams Mermaid.js 11 Converts fenced blocks to SVG client-side
JS Framework Stimulus Manages mermaid rendering lifecycle
Page Navigation Turbo Drive SPA-like page transitions without a SPA
Assets Propshaft Serves CSS/JS as static files, no build step
JS Delivery Importmap ESM imports without bundling (Webpack/esbuild)
Theme Gruvbox Dark Warm dark palette via CSS custom properties