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,000
downloads
1
forks
1,554
days
1,563
days
1,563
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.
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.
Natural Language Dates
6 years ago by Argentina Ortega Sainz
Work with dates in natural language in Obsidian
Execute Code
4 years ago by twibiral
Obsidian Plugin to execute code in a note.
Digital Garden
4 years ago by Ole Eskild Steensen
Editor Width Slider
3 years ago by @MugishoMp
With this plugin you can set the line width of the editor in obsidian.
CSS Editor
3 years ago by Zachatoo
Edit CSS snippets in Obsidian.
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!
VSCode Editor
3 years ago by Sun Xvming
Edit Code Files like VSCode in Obsidian.
Sheets Extended
3 years ago by NicoNekoru
Plugin that adds features to tables in obsidian including merging, vertical headers, and custom css
Handwritten Notes
3 years ago by FBarrCa
Obsidian Handwritten Notes Plugin
Epub Importer
2 years ago by aoout
Import EPUB files as Markdown.
SystemSculpt AI
2 years ago by SystemSculpt.com
Enhance your Obsidian App experience with AI-powered tools for note-taking, task management, and much, MUCH more.
Dynamic Outline
a year ago by theopavlove
Adds a customizable GitHub-like floating table of contents to Obsidian.
Simple RSS
3 years ago by Monnierant
Shiki Highlighter
2 years ago by Moritz Jung
An Obsidian plugin that offers better code highlighting via shiki and Expressive Code.
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
Vault Changelog
5 years ago by Badr Bouslikhin
An Obsidian plugin to maintain a changelog of recently edited notes
Code Files
3 years ago by Lukas Bach
Plugin for ObsidianMD to show and edit code files along other notes.
Dangling links
5 years ago by Graydon Hoare
obsidian plugin for displaying dangling links
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.
Marp
3 years ago by JichouP
Plugin to use Marp with Obsidian
PDF break page
2 years ago by CG
Plugin for obsidian that adding shortcuts to create breakpages for pdf exports.
Code Block
4 years ago by Patrik Lindefors
Copy Image
2 years ago by Felipe D.S. Lima
Easily copy image to clipboard by right clicking image.
Code block from selection
5 years ago by Dmitry Savosh
Obsidian plugin. Adds code block for the selected text.
Improved Random Note
3 years ago by ShockThunder
Better Math in Callouts & Blockquotes
2 years ago by Ryota Ushio
An Obsidian plugin to add better Live Preview support for math rendering inside callouts & blockquotes.
Metadata Hider
2 years ago by Benature
Hide metadata property if its value is empty
MLIR Syntax Highlight
3 years ago by Lewuathe
Nifty Links
3 years ago by x-Ai
Generating elegant, Notion-styled rich link cards to enhance your note-taking experience.
TickTick
3 years ago by Viduy Cheung
Obsidian-compatible Watcher for ActivityWatch
3 years ago by Grimmauld
Obsidian plugin to track user activity with ActivityWatch
Embed Code File
4 years ago by Abdullah Almariah
No more flickering inline math
3 years ago by Ryota Ushio
No longer disturbed by flickering inline math in Obsidian.
Rendered Block Link Suggestions
2 years ago by Ryota Ushio
Upgrade Obsidian's built-in link suggestions with block markdown rendering.
Quoth
4 years ago by Eric Rykwalder
Single File Daily Notes
2 years ago by Pranav Mangal
An Obsidian plugin to create and manage daily notes in a single file
Orgmode (CM6)
2 years ago by Benoit Bazard
Orgmode plugin for Obsidian
Smart Links
3 years ago by David Lynch
Multi State CheckBox Switcher
2 years ago by KubaMiszcz
Kindle Highlights Importer
2 years ago by MovingMillennial
Flashcard Generator
3 years ago by ChloeDia
Obsidian Plug-in to automatically create a set of questions/answers on your notes !
Broken Links
2 years ago by ipshing
Vault 2 Book
3 years ago by Mitra98t
Obsidian plugin to convert vault to a complete pdf with Table Of Content
SamePage
3 years ago by SamePage
Stenography
5 years ago by bramses
TinyPNG Image
3 years ago by ckt1031
Obsidian plugin for compressing images with TinyPNG
Exercises
3 years ago by AlexCCavaco
Create Interactive Exercises along side your Obsidian Notes
Frontmatter generator
3 years ago by Hananoshika Yomaru
A plugin for Obsidian that generates frontmatter for notes
Code::Stats
3 years ago by MiskaMyasa
The Code::Stats plugin allows you to track your coding progress and earn XP for writing markdown in the Obsidian editor.
File indicators
2 years ago by Jakob
Add custom indicators to the file explorer.
Publish to Steemit
4 years ago by anpigon
Post directly to your Steemit from Obsidian.
BuJo Bullets
a year ago by Will Olson
Alternate checkbox types for Obsidian to support Bullet Journal bullets
Image Classify Paste
2 years ago by tianfx
TODO Wrangler
3 years ago by Jeel Shah
An obsidian plugin to wrangle your Todos and put them in their place.
File Publisher
3 years ago by Devin Sackett
Edit MDX
2 years ago by Tim Peters
Create and edit mdx files in Obsidian.md as if they were md files.
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.
Simple Code Formatter
2 years ago by SY
Format current code block in obsidian.
Codeblock Template
3 years ago by Super10
A template plugin that allows for the reuse of content within Code Blocks!一个可以把Code Block的内容重复利用模板插件!
Feeds
2 years ago by LukeMT, pashashocky, madx
Magic feeds dataview query for obsidian
File Index
2 years ago by Steffo
Obsidian plugin to create a metadata file about the files present in the Vault
Random Number Generator
2 years ago by iRewiewer
Gives you a random number
Barcode Generator
2 years ago by noxonad
A barcode generator for obsidian.
Git File Explorer
2 years ago by Mateus Molina
RSS Copyist
2 years ago by aoout
Get the RSS articles as notes.
Sort Frontmatter
2 years ago by Kanzi
Sort frontmatter automatically
LaTeX-OCR
2 years ago by Jack Barker
Alt-Click to Copy
2 years ago by Veer Sheth
KoReader Highlight Importer
a year ago by Tahsin Kocaman
Imports highlights and metadata from KoReader into Obsidian notes
Adjacency Matrix Exporter
2 years ago by danielegrazzini
Create a numerical adjacency matrix of your Vault in two ways: Absolute and Normalized
short tab name
2 years ago by Shumpei Tanaka
a plugin of obsidian for to change showing tab name to short
Page Scroll
2 years ago by triski
Obsidian Page Up|Down|Top|Bottom
Blockreffer
2 years ago by tyler.earth
An Obsidian plugin to search and embed blocks with ^block-references (aka ^block-ids)
Code Language Completer
2 years ago by Stanley Wang
minimal Obisdian plugin, fine-tuned to speed up developer note-taking
Sidebar Resizer
2 years ago by Jeet Sukumaran
ai-writer
2 years ago by Donovan Ye
A plugin for Obsidian that uses AI to help you write better and faster.
Fight Note
2 years ago by Dmitry Loac
Obsidian Plugin for shows Tekken notation into an easy-to-read form.
Focus Tracker
2 years ago by Jeet Sukumaran
Svelte Syntax Highlighter
2 years ago by Typhoon-Kim
This plugin adds Svelte syntax highlighting to Obsidian.
Link to Verse
2 years ago by Alberto Sesiliano (aygjiay)
Update Time Updater
2 years ago by MURATAGAWA Kei
Obsidian plugin to update the 'update time' element when saving or manually.
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.
Snippetsaurus
a year ago by Christian Humbert
Truth Table+
2 years ago by Maximilian Schulten
This is the repository of an Obsidian.md plugin that allows users to create truth tables via the command palette.
Browser Interface
2 years ago by Jason Lieb
An obsidian plugin that pairs with a chrome extension to manage your tabs in obsidian.
Pia viewer
2 years ago by dldisud
Inline Code Copy
a year ago by Hongchen Lin
Epiphany
2 years ago by Epiphany
URI Converter
a year ago by wenlzhang
An Obsidian plugin to convert Obsidian URIs to Obsidian internal links.
Header Counter
2 years ago by Nancy Lee
Click Hint
a year ago by kbwo
ruby.wasm
2 years ago by geeknees
Obsidian RubyWasm Plugin
ShaahMaat-md
a year ago by Mihail Kovachev
Share via Notepad Tab
2 years ago by Iulian Onofrei
Replicate
a year ago by Sébastien Dubois
Integrate Replicate.com with Obsidian
Note Placeholder
a year ago by XZSt4nce
Replaces text of note link to placeholder in view mode.