Skip to content

Fix specific highlighting (CMakeLists.txt ...) #7686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 4, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Highlighting CMakeLists.txt:
remove case sensitive checks.
use lowercase checks instead.
  • Loading branch information
FlorianBen committed Aug 2, 2019
commit 291bbea1aa1a3f99d857c12b5e2fd86867f14ece
22 changes: 7 additions & 15 deletions modules/highlight/highlight.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down