Custom Syntax Highlights

by Outsiders17711
5
4
3
2
1
Score: 51/100

Description

The Custom Syntax Highlights plugin enables syntax highlighting for files with non-standard extensions by mapping them to a chosen language. Users can configure extension-to-language mappings through settings, allowing files like .bib, .tex, or .py to be rendered as readable, colour-coded code blocks in reading view. The plugin ensures these files open directly in reading mode, offering a clean, formatted display ideal for reviewing source files without editing. It also includes an option to disable highlighting for certain extensions by mapping them to markdown. Markdown files themselves are excluded since they are already handled natively. The plugin draws inspiration from earlier work on custom file extensions but expands its functionality significantly.

Reviews

No reviews yet.

Stats

5
stars
1,446
downloads
0
forks
293
days
293
days
295
days
0
total PRs
0
open PRs
0
closed PRs
0
merged PRs
0
total issues
0
open issues
0
closed issues
47
commits

Latest Version

10 months ago

Changelog

Changed

  • Moved configuration-related files into config/ directory for cleaner project root.
  • Updated import paths in source code to reflect new configuration file locations.

Fixed

  • Plugin Review: Scoped plugin CSS to prevent conflicts with core Obsidian styles.
  • Plugin Review: Replaced unsafe type casts with instanceof checks for improved stability.

README file from

Github

Custom Syntax Highlights

Release License Node.js

An Obsidian plugin that displays files with custom extensions as syntax-highlighted code blocks in reading view, with configurable extension-to-language mappings.

Features

  • Custom Extension Mapping: Configure any file extension to display with specific syntax highlighting
  • Auto-Switch to Reading View: Automatically switch configured file extensions to reading view when opened
  • Flexible Language Support: Map extensions to any supported syntax highlighting language
  • Clean Display: Files are rendered as single, properly formatted code blocks

Demo

Installation

You can install the plugin directly from Obsidian's Community Plugins browser:

  1. Open Obsidian and go to Settings > Community plugins
  2. Click on Browse and search for "Custom Syntax Highlights"
  3. Click Install and then Enable the plugin

You can also install the plugin directly from its Community Plugins entry: Custom Syntax Highlights on Obsidian.

Manual Installation

  1. Download the latest release from GitHub Releases
  2. Extract main.js, manifest.json, and styles.css to your vault's .obsidian/plugins/custom-syntax-highlights/ directory
  3. Reload Obsidian and enable the plugin in Settings → Community plugins

Configuration

Extension Mappings

Configure extension-to-language mappings in Settings → Community plugins → Custom File Extensions:

  • Extension: The file extension (without the dot)
  • Language: The syntax highlighting language to use (leave empty to use the extension name)

Example Configurations

Extension Language Result
tex (empty) LaTeX files with TeX syntax highlighting
json (empty) JSON files with JSON syntax highlighting
bib ini Bibliography files with INI-style highlighting
py python Python files with Python syntax highlighting
txt md Text files with normal editing (no highlighting)

Important Notes

  • Markdown files (.md): Not supported - handled natively by Obsidian
  • Normal editing: Set language to md or markdown to disable highlighting and enable normal editing
  • Auto-switch: Toggle whether files automatically open in reading view

Usage

  1. Configure extension mappings in plugin settings
  2. Open any file with a configured extension
  3. File automatically switches to reading view with syntax highlighting

Development

Building

npm install    # install dependencies
npm run dev    # development build with watch mode
npm run build  # production build
npm run test   # update the plugin in the test vault

Release

npm run release        # automated patch release
npm run release:minor  # minor version release  
npm run release:major  # major version release

Requirements: Node.js 16+, Git repository with GitHub origin

Documentation

Inspiration

Built upon the foundation of MeepTech/obsidian-custom-file-extensions-plugin for file extension registration. This plugin now implements a complete 2-in-1 solution with both file extension registration and syntax highlighting.

License

MIT License

Similar Plugins

info
• Similar plugins are suggested based on the common tags between the plugins.
Natural Language Syntax Highlighting
3 years ago by artisticat
Highlight adjectives, nouns, adverbs, verbs, and conjunctions in Obsidian.md
Markdoc
3 years ago by Maciej Jur
Basic markdoc support for Obsidian
File Include
3 years ago by Till Hoffmann
InlineCodeHighlight
3 years ago by Dimava
MLIR Syntax Highlight
3 years ago by Lewuathe
Shiki Highlighter
2 years ago by Moritz Jung
An Obsidian plugin that offers better code highlighting via shiki and Expressive Code.
Svelte Syntax Highlighter
2 years ago by Typhoon-Kim
This plugin adds Svelte syntax highlighting to Obsidian.
Magic Move
2 years ago by imfenghuang
Animating Code Blocks in Obsidian
Vertical Timeline List
a year ago by Jalad
Utilizes task lists to create a timeline... or something like a timeline.
Ace Code Editor
a year ago by RavenHogWarts
An enhanced code editor using Ace editor
Code Blocks commands
a year ago by dragonish
Provide commands to insert code blocks with markup, and support triggering commands with backticks.
Adapt to Current View
a year ago by greetclammy
Obsidian plugin to set different accent colors for Reading view, Live Preview and Source view.
Fountain Editor
3 months ago by Chuang Caleb
Obsidian plugin for Fountain screenplay syntax formatting.
Inline TikZ
a month ago by Lachlan Harris
Render seamless Tikz, CircuiTikz & other PGFPlots LaTeX diagrams directly in your notes.
TableTune
13 days ago by niizhou
Tune your Obsidian tables: drag column/row borders to resize; sizes remembered per table; content-aware defaults; clean single-scrollbar reading view.