Code Block Labels

by Sean Bowers
5
4
3
2
1
Score: 51/100

Description

Category: Coding & Technical Tools

The Code Block Labels plugin enhances the readability and organization of fenced code blocks in Obsidian by allowing users to assign custom labels. Labels can be added directly to the first line of a code block, providing a clear identifier for its content or purpose. The plugin also offers an option to automatically display the code language as a label if no custom label is specified. Users can style these labels with custom CSS for better integration with their Obsidian theme.

Reviews

No reviews yet.

Stats

12
stars
5,031
downloads
1
forks
1,603
days
1,612
days
1,612
days
0
total PRs
0
open PRs
0
closed PRs
0
merged PRs
0
total issues
0
open issues
0
closed issues
0
commits

Latest Version

4 years ago

Changelog

Initial release

README file from

Github

Obsidian Code Block Labels Plugin

This plugin renders labels for fenced code blocks.

Add a label to a code block by putting it inside curly braces ({}) at the end of the first line of the fenced code block (after the language if applicable).

Demo of named codeblock

The plugin can also be optionally configured to show the language as a label, if no explicit label was set (this is enabled by default - see settings panel to turn off).

Screenshot of language used as label

Labels are assigned the "codeblock-label" class and so can be styled with CSS:

/* style the label */
.markdown-preview-view .codeblock-label {
  color: magenta;
  background: green;
}

/* to style the code block itself, but leave unlabled codeblocks untouched, select the pre tag that comes directly after the label */
.markdown-preview-view .codeblock-label + pre {
  background: blue;
}

Screenshot of labeled codeblock with custom css

Refresh bug

There is a known issue where making a change to the label doesn't always cause the preview to update. I am looking in to a potential fix, but I want to make sure I do it in the correct way :)

Because Obsidian tries to be efficient in it's Markdown rendering, it only updates the preview when it detects a change to the Markdown. The syntax used here however doesn't always trigger this update, because Obsidian doesn't consider it valid Markdown syntax.

Specifically Obsidian only checks the first line of the code block up to the first space or newline for the language to use for syntax highlighting. This means that if you have a space between the language and label (or if your label has a space in it), when you modify anything past that first space it won't update the preview automatically. To manually fix this, just make a change to any other part of the code block and it should trigger an update.

Animation showing the bug in action

Live preview

Currently this plugin does not support live preview. The live preview works in a significantly different way than the "normal" preview, and I don't personally use live preview so have little incentive to make it work. I'd be more than happy to accept a pull request though if anyone wants to take a look at it!

Credit

This plugin is based off of the template plugin here https://github.com/obsidianmd/obsidian-sample-plugin

Similar Plugins

info
• Similar plugins are suggested based on the common tags between the plugins.
Adjacency Matrix Exporter
3 years ago by danielegrazzini
Create a numerical adjacency matrix of your Vault in two ways: Absolute and Normalized
ai-writer
2 years ago by Donovan Ye
A plugin for Obsidian that uses AI to help you write better and faster.
Alt-Click to Copy
2 years ago by Veer Sheth
Barcode Generator
3 years ago by noxonad
A barcode generator for obsidian.
Blockreffer
2 years ago by tyler.earth
An Obsidian plugin to search and embed blocks with ^block-references (aka ^block-ids)
Broken Links
2 years ago by ipshing
Browser Interface
2 years ago by Jason Lieb
An obsidian plugin that pairs with a chrome extension to manage your tabs in obsidian.
BuJo Bullets
a year ago by Will Olson
Alternate checkbox types for Obsidian to support Bullet Journal bullets
Click Hint
a year ago by kbwo
Code Block
4 years ago by Patrik Lindefors
Code block from selection
5 years ago by Dmitry Savosh
Obsidian plugin. Adds code block for the selected text.
Code Files
3 years ago by Lukas Bach
Plugin for ObsidianMD to show and edit code files along other notes.
Code Language Completer
2 years ago by Stanley Wang
minimal Obisdian plugin, fine-tuned to speed up developer note-taking
Codeblock Template
3 years ago by Super10
A template plugin that allows for the reuse of content within Code Blocks!一个可以把Code Block的内容重复利用模板插件!
Copy Image
2 years ago by Felipe D.S. Lima
Easily copy image to clipboard by right clicking image.
CSS Editor
3 years ago by Zachatoo
Edit CSS snippets in Obsidian.
Dangling links
6 years ago by Graydon Hoare
obsidian plugin for displaying dangling links
Digital Garden
4 years ago by Ole Eskild Steensen
Dynamic Outline
a year ago by theopavlove
Adds a customizable GitHub-like floating table of contents to Obsidian.
Edit MDX
3 years ago by Tim Peters
Create and edit mdx files in Obsidian.md as if they were md files.
Editor Width Slider
3 years ago by @MugishoMp
With this plugin you can set the line width of the editor in obsidian.
Embed Code File
4 years ago by Abdullah Almariah
Epiphany
2 years ago by Epiphany
Epub Importer
3 years ago by aoout
Import EPUB files as Markdown.
Execute Code
4 years ago by twibiral
Obsidian Plugin to execute code in a note.
Exercises
3 years ago by AlexCCavaco
Create Interactive Exercises along side your Obsidian Notes
Feeds
3 years ago by LukeMT, pashashocky, madx
Magic feeds dataview query for obsidian
Fight Note
2 years ago by Dmitry Loac
Obsidian Plugin for shows Tekken notation into an easy-to-read form.
File Index
3 years ago by Steffo
Obsidian plugin to create a metadata file about the files present in the Vault
File indicators
3 years ago by Jakob
Add custom indicators to the file explorer.
File path to URI
5 years ago by Michal Bureš
Convert file path to uri for easier use of links to local files outside of Obsidian
File Publisher
3 years ago by Devin Sackett
Flashcard Generator
3 years ago by ChloeDia
Obsidian Plug-in to automatically create a set of questions/answers on your notes !
Focus Tracker
2 years ago by Jeet Sukumaran
Frontmatter generator
3 years ago by Hananoshika Yomaru
A plugin for Obsidian that generates frontmatter for notes
Git File Explorer
2 years ago by Mateus Molina
Handwritten Notes
3 years ago by FBarrCa
Obsidian Handwritten Notes Plugin
Header Counter
2 years ago by Nancy Lee
Homepage
5 years ago by mirnovov
An Obsidian plugin that opens a specified note, canvas, or workspace on startup, instead of the most recent one.
Image Classify Paste
3 years ago by tianfx
Improved Random Note
3 years ago by ShockThunder
Inline Code Copy
a year ago by Hongchen Lin
Kindle Highlights Importer
2 years ago by MovingMillennial
KoReader Highlight Importer
a year ago by Tahsin Kocaman
Imports highlights and metadata from KoReader into Obsidian notes
LaTeX-OCR
2 years ago by Jack Barker
Link to Verse
2 years ago by Alberto Sesiliano (aygjiay)
Marp
3 years ago by JichouP
Plugin to use Marp with Obsidian
Memos Sync
2 years ago by RyoJerryYu
Syncing Memos to Obsidian daily note. Fully compatible with official Daily Notes plugin, Calendar plugin and Periodic Notes plugin.
Metadata Hider
2 years ago by Benature
Hide metadata property if its value is empty
MLIR Syntax Highlight
3 years ago by Lewuathe
Multi State CheckBox Switcher
2 years ago by KubaMiszcz
Nifty Links
3 years ago by x-Ai
Generating elegant, Notion-styled rich link cards to enhance your note-taking experience.
No more flickering inline math
3 years ago by Ryota Ushio
No longer disturbed by flickering inline math in Obsidian.
Note Placeholder
a year ago by XZSt4nce
Replaces text of note link to placeholder in view mode.
Obsidian-compatible Watcher for ActivityWatch
3 years ago by Grimmauld
Obsidian plugin to track user activity with ActivityWatch
Page Scroll
2 years ago by triski
Obsidian Page Up|Down|Top|Bottom
PDF break page
2 years ago by CG
Plugin for obsidian that adding shortcuts to create breakpages for pdf exports.
Pia viewer
2 years ago by dldisud
Publish to Steemit
4 years ago by anpigon
Post directly to your Steemit from Obsidian.
Quiz Generator
2 years ago by Edward Cui
Generate interactive flashcards from your notes using models from OpenAI (ChatGPT), Google (Gemini), Ollama (local LLMs), and more. Or manually create your own to use with the quiz UI.
Quoth
4 years ago by Eric Rykwalder
Random Number Generator
3 years ago by iRewiewer
Gives you a random number
Rapid AI
2 years ago by Rapid AI
AI Assistant for selected text and generating content with Markdown. Shortcuts and quick action buttons provide instant AI assistance. It provides a high availability API for unlimited Chat GPT request rates, so you can ensure smooth work for any workload.
Rendered Block Link Suggestions
3 years ago by Ryota Ushio
Upgrade Obsidian's built-in link suggestions with block markdown rendering.
Replicate
a year ago by Sébastien Dubois
Integrate Replicate.com with Obsidian
RSS Copyist
2 years ago by aoout
Get the RSS articles as notes.
ruby.wasm
2 years ago by geeknees
Obsidian RubyWasm Plugin
SamePage
4 years ago by SamePage
ShaahMaat-md
a year ago by Mihail Kovachev
Share via Notepad Tab
2 years ago by Iulian Onofrei
Sheets Extended
3 years ago by NicoNekoru
Plugin that adds features to tables in obsidian including merging, vertical headers, and custom css
Shiki Highlighter
2 years ago by Moritz Jung
An Obsidian plugin that offers better code highlighting via shiki and Expressive Code.
short tab name
3 years ago by Shumpei Tanaka
a plugin of obsidian for to change showing tab name to short
Sidebar Resizer
2 years ago by Jeet Sukumaran
Simple Code Formatter
2 years ago by SY
Format current code block in obsidian.
Simple RSS
3 years ago by Monnierant
Single File Daily Notes
2 years ago by Pranav Mangal
An Obsidian plugin to create and manage daily notes in a single file
Smart Links
4 years ago by David Lynch
Smart Second Brain
2 years ago by Leo310, nicobrauchtgit
An Obsidian plugin to interact with your privacy focused AI-Assistant making your second brain even smarter!
Snippetsaurus
2 years ago by Christian Humbert
Sort Frontmatter
3 years ago by Kanzi
Sort frontmatter automatically
Stenography
5 years ago by bramses
Svelte Syntax Highlighter
2 years ago by Typhoon-Kim
This plugin adds Svelte syntax highlighting to Obsidian.
TickTick
3 years ago by Viduy Cheung
TinyPNG Image
3 years ago by ckt1031
Obsidian plugin for compressing images with TinyPNG
TODO Wrangler
3 years ago by Jeel Shah
An obsidian plugin to wrangle your Todos and put them in their place.
Update Time Updater
2 years ago by MURATAGAWA Kei
Obsidian plugin to update the 'update time' element when saving or manually.
URI Converter
a year ago by wenlzhang
An Obsidian plugin to convert Obsidian URIs to Obsidian internal links.
Vault 2 Book
3 years ago by Mitra98t
Obsidian plugin to convert vault to a complete pdf with Table Of Content
Vault Changelog
5 years ago by Badr Bouslikhin
An Obsidian plugin to maintain a changelog of recently edited notes
VSCode Editor
3 years ago by Sun Xvming
Edit Code Files like VSCode in Obsidian.