Skip to content

yozlog/md-preview-with-frontmatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English | 繁體中文 | 한국어

Markdown Preview with Frontmatter for Yazi

A custom preview script for Yazi designed to be used with the piper.yazi or faster-piper.yazi plugins. It renders Markdown files with syntax-highlighted YAML frontmatter using bat, followed by the rendered Markdown body using glow.

Features

  • Syntax highlighting for YAML frontmatter (via bat).
  • Beautiful Markdown rendering (via glow).
  • Automatic terminal width detection.
  • Dracula theme integration.
  • Proper padding/alignment for terminal display.

Installation

1. Clone the repository

Clone this repository to the preferred scripts directory (e.g., ~/scripts):

mkdir -p ~/scripts
git clone https://github.com/yozlog/md-preview-with-frontmatter.git ~/scripts/md-preview-with-frontmatter

2. Grant execution permission

Ensure the script is executable:

chmod +x ~/scripts/md-preview-with-frontmatter/main.sh

3. Requirements

This script depends on bat and glow.

macOS

Can be installed via Homebrew:

brew install bat glow

Usage in Yazi

For instructions on how to install piper.yazi or faster-piper.yazi, please refer to their respective GitHub pages:

Once the plugins are installed and configured, add the following to yazi.toml:

[plugin]
prepend_preloaders = [
  { url = "*.md", run = 'faster-piper -- ~/scripts/md-preview-with-frontmatter/main.sh "$1" $w' },
]

Important

Note on Path: Please update the script path (~/scripts/md-preview-with-frontmatter/main.sh) in the configuration to match the actual storage location.

Standalone Usage

The script can be used independently in the terminal:

# Usage: ./main.sh <file_path> [terminal_width]
./main.sh my-file.md 80

Customization

  • Theme: The default theme is set to Dracula.
    • To change the Markdown theme, edit the glow command in main.sh (e.g., -s nord).
    • To change the Frontmatter theme, bat will use the global default (configured in ~/.config/bat/config) or you can add --theme to the bat command in main.sh.

About

A standalone or Yazi-integrated Markdown preview script featuring bat-powered YAML highlighting and glow rendering.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages