2026-05-12 15:58:07 +01:00
2026-05-12 15:58:07 +01:00
2026-05-12 15:58:07 +01:00
2026-05-12 15:58:07 +01:00
2026-05-12 15:58:07 +01:00
2026-05-12 15:58:07 +01:00
2026-05-12 15:58:07 +01:00
2026-05-12 15:58:07 +01:00
2026-05-12 15:58:07 +01:00

Microprints

Compact visual representations of source code files.

What is a microprint?

A microprint is a compact visual fingerprint where each line of code becomes a colored stripe based on its syntax elements. The result is a small, informative visualization that shows the structure and composition of a file at a glance.

Features

  • Syntax-aware colorization — Uses the Erlang/Elixir tokenizer for accurate token classification (functions, strings, comments, atoms, etc.)
  • Multi-language support — Works with Elixir, Erlang, and falls back to regex-based detection for other languages
  • Indentation-aware — Preserves indentation levels to show nesting structure
  • SVG rendering — Phoenix LiveView components for inline SVG visualization
  • Caching — ETS-based cache with automatic invalidation via PubSub
  • Zero dependencies — Core analysis has no external dependencies

Installation

Add to your mix.exs:

def deps do
  [
    {:microprints, "~> 0.1"}
  ]
end

Usage

Generate a microprint

Microprints.generate("path/to/file.ex")
# => {:ok, %{lines: [...], line_count: 42}}

Get color for a syntax type

Microprints.color_for(:function_def)
# => "#EF4444"

Get the color legend

Microprints.color_legend()
# => [{"Function", "#EF4444"}, {"Module", "#EC4899"}, ...]

Render in Phoenix LiveView

<%= live_component @live_view, MicroprintComponent,
  microprint: microprint,
  width: 200,
  max_height: 100,
  clickable: true,
  file_path: file_path %>

Cache with automatic invalidation

# Start the cache (usually in your dev tools supervision tree)
MicroprintCache.start_link(pubsub: MyApp.PubSub)

# Get or generate
{:ok, microprint} = MicroprintCache.get_microprint("path/to/file.ex")

Color Legend

Syntax Element Color
Function def 🔴 Red
Module 🩷 Pink
Keyword 🟣 Purple
String 🟢 Green
Comment Gray
Atom 🟠 Amber
Number 🔵 Blue
Other Light gray

Development

cd microprints-git
mix test

License

MIT

Description
Phoenix liveview implementation of microprints
Readme MIT 817 KiB
Languages
Elixir 100%