From 08f733310ccfaa77b86b6460fe7605fc04d4d627 Mon Sep 17 00:00:00 2001 From: Florian Benedetti Date: Wed, 31 Jul 2019 11:56:30 +0200 Subject: [PATCH 1/2] Fix specific highlighting. --- modules/highlight/highlight.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/highlight/highlight.go b/modules/highlight/highlight.go index cb52f6ac2ea9e..dbcd4848f7f05 100644 --- a/modules/highlight/highlight.go +++ b/modules/highlight/highlight.go @@ -24,6 +24,11 @@ var ( "makefile": true, } + // File names and extensions that are not same as highlight classes and may be case sensitive. + highlightSpecificNames = map[string]string{ + "CMakeLists.txt": "cmake", + } + // Extensions that are same as highlight classes. highlightExts = map[string]struct{}{ ".arm": {}, @@ -82,6 +87,11 @@ func NewContext() { // FileNameToHighlightClass returns the best match for highlight class name // based on the rule of highlight.js. func FileNameToHighlightClass(fname string) string { + + if name, ok := highlightSpecificNames[fname]; ok { + return name + } + fname = strings.ToLower(fname) if ignoreFileNames[fname] { return "nohighlight" From 291bbea1aa1a3f99d857c12b5e2fd86867f14ece Mon Sep 17 00:00:00 2001 From: Florian Benedetti Date: Fri, 2 Aug 2019 13:30:20 +0200 Subject: [PATCH 2/2] Highlighting CMakeLists.txt: remove case sensitive checks. use lowercase checks instead. --- modules/highlight/highlight.go | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/modules/highlight/highlight.go b/modules/highlight/highlight.go index dbcd4848f7f05..4334480566f7c 100644 --- a/modules/highlight/highlight.go +++ b/modules/highlight/highlight.go @@ -19,14 +19,11 @@ var ( } // File names that are representing highlight classes. - highlightFileNames = map[string]bool{ - "dockerfile": true, - "makefile": true, - } - - // File names and extensions that are not same as highlight classes and may be case sensitive. - highlightSpecificNames = map[string]string{ - "CMakeLists.txt": "cmake", + highlightFileNames = map[string]string{ + "dockerfile": "dockerfile", + "makefile": "makefile", + "gnumakefile": "makefile", + "cmakelists.txt": "cmake", } // Extensions that are same as highlight classes. @@ -87,18 +84,13 @@ func NewContext() { // FileNameToHighlightClass returns the best match for highlight class name // based on the rule of highlight.js. func FileNameToHighlightClass(fname string) string { - - if name, ok := highlightSpecificNames[fname]; ok { - return name - } - fname = strings.ToLower(fname) if ignoreFileNames[fname] { return "nohighlight" } - if highlightFileNames[fname] { - return fname + if name, ok := highlightFileNames[fname]; ok { + return name } ext := path.Ext(fname)