navidown

module
v0.4.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2026 License: Apache-2.0

README

navidown

About

navidown is a reusable navigable markdown CLI component:

  • renders markdown to ANSI (for terminal output)
  • supports scrolling and pager-style navigation
  • finds links and allows Tab / Shift-Tab traversal
  • on activation (Enter), loads linked markdown via a pluggable loader and replaces current content

This repo contains:

  • core package github.com/boolean-maybe/navidown/navidown (UI-agnostic state machine + renderers)
  • optional TView adapter github.com/boolean-maybe/navidown/navidown/tview (TView primitive)

Installation

go get github.com/boolean-maybe/navidown/navidown

For the TView adapter:

go get github.com/boolean-maybe/navidown/navidown/tview

For the file/HTTP content loader:

go get github.com/boolean-maybe/navidown/loaders

Quick Start

Using the TView Adapter

Two adapters are available: BoxViewer (custom draw) and TextViewViewer (TextView paging). This example uses TextViewViewer.

package main

import (
	"github.com/boolean-maybe/navidown/loaders"
	nav "github.com/boolean-maybe/navidown/navidown"
	navtview "github.com/boolean-maybe/navidown/navidown/tview"
	"github.com/rivo/tview"
)

func main() {
	app := tview.NewApplication()
	viewer := navtview.NewTextView()

	// Set initial markdown content
	viewer.SetMarkdown(`# Welcome to navidown

Navigate through links with **Tab** and **Shift+Tab**.
Press **Enter** to follow links.

[Example Link](https://example.com)
[Local File](./README.md)

## Features
- ANSI terminal rendering
- Link navigation
- Scrolling support
`)

	// Handle link activation
	fetcher := nav.NewContentFetcher(&loaders.FileHTTP{}, nil)
	viewer.SetSelectHandler(func(v *navtview.TextViewViewer, elem nav.NavElement) {
		content, err := fetcher.FetchContent(elem)
		if err == nil {
			v.SetMarkdownWithSource(content, elem.URL, true)
		}
	})

	if err := app.SetRoot(viewer, true).Run(); err != nil {
		panic(err)
	}
}
Using the Core API (UI-agnostic)
package main

import (
	"fmt"
	"github.com/boolean-maybe/navidown/navidown"
)

func main() {
	session := navidown.New(navidown.Options{})

	// Set markdown content
	_ = session.SetMarkdown(`# Hello World

This is a [link](https://example.com).

## Section
More content here.`)

	// Get rendered ANSI lines
	lines := session.RenderedLines()
	for _, line := range lines {
		fmt.Println(line)
	}

	// Navigate through links
	session.MoveToNextLink(20)
	if selected := session.Selected(); selected != nil {
		fmt.Printf("Selected: %s -> %s\n", selected.Text, selected.URL)
	}
}

Build Status Go Report Card Go Reference

Directories

Path Synopsis
cmd
tview command
internal
glamour
Package glamour lets you render markdown documents & templates on ANSI compatible terminals.
Package glamour lets you render markdown documents & templates on ANSI compatible terminals.
glamour/ansi
Package ansi handle conversion of markdown to pretty ANSI output on the terminal.
Package ansi handle conversion of markdown to pretty ANSI output on the terminal.
glamour/internal/autolink
Package autolink provides a function to detect and format GitHub links into a more readable manner.
Package autolink provides a function to detect and format GitHub links into a more readable manner.
glamour/styles
Package styles provides default styles for the glamour package.
Package styles provides default styles for the glamour package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL