Code Block

by Patrik Lindefors
5
4
3
2
1
Score: 68/100

Description

Category: Coding & Technical Tools

The Code Block plugin is a simple yet powerful tool for converting selected text or pasted content into a code block with automatic programming language detection. This feature-rich plugin uses highlight.js to detect the language of the code, making it easy to format and display your code snippets in a clear and readable manner. With this plugin, you can select the languages you want to detect from a list of options, ensuring that your code is accurately identified and displayed with the correct syntax highlighting. Whether you're writing documentation, creating tutorials, or simply sharing code examples, this plugin makes it easy to add professional-looking code blocks to your content.

Reviews

No reviews yet.

Stats

39
stars
15,028
downloads
2
forks
1,550
days
4
days
4
days
0
total PRs
0
open PRs
0
closed PRs
0
merged PRs
0
total issues
0
open issues
0
closed issues
18
commits

README file from

Github

Code Block Plugin

This plugin converts selected text or pasted text into a code block with automatic programming language detection. Select the languages to consider in the plugin settings.

Detection runs locally using highlight.js (all languages it ships with) plus the third-party Cypher grammar. Distinctive syntax such as shebangs, JSON objects and arrays, graph patterns, and certain language declarations takes priority over automatic scoring. C is recognized from common C headers when no C++ markers are present; fragments valid in both languages cannot always be distinguished. HTML uses the xml language, and TOML shares the ini grammar.

Empty input, likely plain prose, low-scoring results, and unresolved ties produce an unlabelled code block. Disabled languages are never selected, including by the syntax rules. If a snippet still gets the wrong language, edit the language after the opening code fence or narrow the enabled languages in settings. Detection is heuristic: a short fragment may be valid in several languages.

Development

npm install
npm run dev    # watch build
npm run build  # typecheck + production build
npm run lint
npm test

The detection tests include a representative snippet for every supported language, with both the full language selection and that language alone, plus short snippets, prose, shebangs, aliases, and disabled-language cases. These are regression examples, not an accuracy benchmark for arbitrary code.

data.json is Obsidian's local settings file for the plugin and is git-ignored. It appears in the project root after you enable the plugin in a vault for the first time.

Similar Plugins

info
• Similar plugins are suggested based on the common tags between the plugins.
Code Block Labels
5 years ago by Sean Bowers
Provides labels for codeblocks in Obsidian
Execute Code
4 years ago by twibiral
Obsidian Plugin to execute code in a note.
Embed Code File
4 years ago by Abdullah Almariah
Code Files
3 years ago by Lukas Bach
Plugin for ObsidianMD to show and edit code files along other notes.
Any Block
3 years ago by LincZero
You can flexibility to create a 'Block' by many means. It also provides many useful features, like `list to table`. (obsidian/markdown-it/vuepress plugin/app)
VSCode Editor
3 years ago by Sun Xvming
Edit Code Files like VSCode in Obsidian.
Are.na unofficial
3 years ago by 0xroko
Unofficial Are.na plugin for Obsidian
Alt-Click to Copy
3 years ago by Veer Sheth
Shiki Highlighter
2 years ago by Moritz Jung
An Obsidian plugin that offers better code highlighting via shiki and Expressive Code.
Bitcoin Block Stamp
2 years ago by sefiro
Stamp your Obsidian notes with the current Bitcoin block.
ruby.wasm
2 years ago by geeknees
Obsidian RubyWasm Plugin
Svelte Syntax Highlighter
2 years ago by Typhoon-Kim
This plugin adds Svelte syntax highlighting to Obsidian.
Code block from selection
6 years ago by Dmitry Savosh
Obsidian plugin. Adds code block for the selected text.
Stenography
5 years ago by bramses
Code Language Completer
2 years ago by Stanley Wang
minimal Obisdian plugin, fine-tuned to speed up developer note-taking
Remove Unused Block IDs
2 years ago by Daniel Geneta
A simple plugin that removes unused block IDs for Obsidian.md
Simple Code Formatter
2 years ago by SY
Format current code block in obsidian.
Snippetsaurus
2 years ago by Christian Humbert
Inline Code Copy
2 years ago by Hongchen Lin
Dragger
3 months ago by ariestar
An Obsidian plugin for dragging and rearranging any block.