module Hansa::Modeline

Overview

Content-based modeline detection, ported from go-enry v2's GetLanguagesByModeline strategy. Emacs modelines are checked first, then Vim ones, over the first and last 5 lines.

Defined in:

modeline.cr

Constant Summary

EMACS_LANG = /(?i:mode)\s*:\s*([^\s;]+)/
EMACS_MODELINE = /-\*-\s*(.+?)\s*-\*-/
SEARCH_SCOPE = 5
VIM_LANG = /(?i:filetype|ft|syntax)\s*=(\w+)(?:\s|:|$)/
VIM_MODELINE = /(?:(?:\s|^)vi(?:m[<=>]?\d+|m)?|[\t ]*ex)\s*:\s*(.*)$/

Class Method Summary

Class Method Detail

def self.languages(content : String) : Array(String) #

[View source]