Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Language Matching System

Attention 💥

Support since v0.2.17.

The language detection system is used for include app to provide accurate syntax highlighting based on file paths.

Overview

The language detection system intelligently identifies programming languages from file paths using a sophisticated three-tier matching system with clear precedence rules:

PriorityMethodExampleDescription
1st (Highest)Exact filenameDockerfiledockerfilePerfect filename matches
2ndFile extensionscript.jsjavascriptExtension-based detection
3rd (Lowest)Wildcard patternDockerfile.proddockerfileFlexible pattern matching

Configuration System

Configuration Location

Language definitions are stored in src/assets/config/languages.json. Each language entry supports multiple matching strategies.

Language Definition Structure

{
  "name": "dockerfile",
  "extensions": [".dockerfile"],
  "filenames": ["Dockerfile", "dockerfile", "Containerfile", "Dockerfile.*", "dockerfile.*", "*.dockerfile"]
}
PropertyTypePurposeExample
nameStringLanguage identifier for syntax highlighting"javascript"
extensionsArrayFile extensions (with dots)[".js", ".jsx"]
filenamesArrayExact filenames and wildcard patterns["Dockerfile", "Makefile.*", "*.config.js"]

Wildcard Pattern Syntax

Supported Wildcards

WildcardRegexDescriptionExample PatternMatches
*.*Zero or more charactersDockerfile.*Dockerfile.base, Dockerfile.production
?.Exactly one charactertest?.txttest1.txt, testa.txt

Examples

🐳 Dockerfile Variants

FilenameResultReason
Dockerfiledockerfile✅ Exact match (non-wildcard entry)
Dockerfile.basedockerfile🔍 Pattern: Dockerfile.* (wildcard entry)
Dockerfile.productiondockerfile🔍 Pattern: Dockerfile.* (wildcard entry)
dockerfile.devdockerfile🔍 Pattern: dockerfile.* (wildcard entry)
web.dockerfiledockerfile🔍 Pattern: *.dockerfile (wildcard entry)
api.dockerfiledockerfile🔍 Pattern: *.dockerfile (wildcard entry)
Dockerfile.jsjavascript📁 Extension: .js (overrides pattern)

🔨 Makefile Variants

FilenameResultReason
Makefilemakefile✅ Exact match (non-wildcard entry)
Makefile.localmakefile🔍 Pattern: Makefile.* (wildcard entry)
Makefile.ammakefile✅ Exact match (non-wildcard entry)
custom.makefilemakefile📁 Extension: .makefile
build.mkmakefile📁 Extension: .mk

🐚 Shell Configuration Files

FilenameResultReason
.bashrcshell✅ Exact match (non-wildcard entry)
.zshrcshell✅ Exact match (non-wildcard entry)
custom.bashrcshell🔍 Pattern: *.bashrc (wildcard entry)
my.profileshell🔍 Pattern: *.profile (wildcard entry)
script.shshell📁 Extension: .sh

📦 Configuration Files

FilenameResultReason
package.jsonjson📁 Extension: .json
tsconfig.jsonjson📁 Extension: .json
webpack.config.jsjavascript📁 Extension: .js
.eslintrc.jsonjson📁 Extension: .json

Copyright © 2025 • Created with ❤️ by MR-Addict