Motto Code Block

by bugen
5
4
3
2
1
Score: 50/100
New Plugin

Description

A code block enhancement plugin for Obsidian

Reviews

No reviews yet.

Stats

0
stars
downloads
0
forks
0
days
0
days
0
days
0
total PRs
0
open PRs
0
closed PRs
0
merged PRs
0
total issues
0
open issues
0
closed issues
15
commits

Latest Version

17 hours ago

Changelog

Maintenance release focused on Obsidian compatibility.

  • Address source-code issues identified by Obsidian's plugin review.
  • Add settings search support for Obsidian 1.13 and later.
  • Improve DOM handling and CSS compatibility.

The minimum supported Obsidian version remains 1.5.0.

Full Changelog: https://github.com/bugen/obsidian-motto-code-block/compare/0.1.0...0.1.1

README file from

Github

Obsidian Motto Code Block

command_block_figlet

Motto Code Block makes code blocks easier to read in Obsidian with theme-aware headers, line numbers, and folding. It also displays shell commands and their output in a terminal-style layout.

Features

  • Code block headers with language icons and custom titles.
  • Line numbers, folding, and partial previews.
  • ⭐ Command Block - Terminal-style command blocks with collapsible output.
  • ANSI colors for terminal output.
  • One-click copying for code, commands, and output.
  • Theme-aware styling in Live Preview and Reading view.

Code block enhancements

Code blocks adapt to your active Obsidian theme's colors and styling, in both light and dark modes.

Light mode Dark mode
Code block in light mode Code block in dark mode
  • Headers display language icons, language names, and optional custom titles. By default, they appear only when supported options such as title: or file: are present. Set Header display to Always in settings to show them on all eligible blocks.
  • Line numbers make code easier to follow, while preserving existing line wrapping.
  • Folding keeps long blocks compact. Click the header to fold or expand a block, or use a partial preview to show only the first few lines. Click Show all to reveal the rest.

Code block with a partial preview

Command Block

Command Block presents shell commands and their output in a terminal-style layout. Copy individual commands without prompts, show or hide output with a click, and display ANSI-colored output. Commands are displayed, not executed.

Command Block with shell commands and output

Extended syntax

Add options after the language name on the opening code fence. Quote values that contain spaces.

Option Description
title:"My code" or file:example.py Set the header title.
fold / expand Start folded / fully expanded.
expand:5 Show a partial preview of the first five lines.
header-style:info Color the header using an Obsidian callout type.
cmd Render a sh, bash, zsh, csh, or fish block as a Command Block.
prompt:"user@host:~/project" Show the user, host, and working directory in a Command Block header.
user:, host:, cwd: Set the prompt fields individually.
exclude Disable this plugin's enhancements for the block.

For example, ```python file:mandelbrot.py adds a file name to a Python block's header:

Python code block with a file name in the header

For a Command Block, combine cmd with an optional title and prompt. To include output, paste it into an ansi block directly after the shell block, with no blank line between the blocks:

```bash cmd title:"Plot Mandelbrot" prompt:"user@localhost"
python mandelbrot.py
```
```ansi
... pasted output ...
```

Command Block displaying the output of a Python script

Theme and plugin compatibility

Code blocks retain Obsidian's syntax highlighting and use your active theme's colors by default, rather than a separate plugin color scheme.

Use Language include list and Language exclude list in settings to choose which languages are enhanced. Exclude languages handled by other plugins to help avoid rendering conflicts. Mermaid is excluded by default.

Acknowledgements

Thanks to these projects and their contributors:

See THIRD_PARTY_NOTICES for attribution and license details.

Code blocks styled to match the active theme