fix(11.1-07): check go fences, README src= and shell fences from the AST
- goLang follows the highlighter's chroma lookup, so golang and main.go need src= - a src= fence in a module README is refused and never captioned - shell fences inside callouts and lists are command-checked - a fence with four or more leading spaces is an indented code block
This commit is contained in:
@@ -84,6 +84,15 @@ func highlight(lang, code string) string {
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// goLang reports whether lang is the Go lexer the highlighter uses.
|
||||
// chroma's registry resolves names, aliases, case and file names, so
|
||||
// go, Go, GO, golang, Golang and main.go are Go. go-html-template,
|
||||
// go-text-template, text and an empty language are not.
|
||||
func goLang(lang string) bool {
|
||||
lexer := lexerFor(lang)
|
||||
return lexer != nil && lexer.Config().Name == "Go"
|
||||
}
|
||||
|
||||
// lexerFor returns the chroma lexer for a fence language, or nil for
|
||||
// plain text and unknown languages.
|
||||
func lexerFor(lang string) chroma.Lexer {
|
||||
|
||||
Reference in New Issue
Block a user