"github.com/gohugoio/hugo/markup/internal/attributes"
)
-// Markdown attributes used by the Chroma hightlighter.
-var chromaHightlightProcessingAttributes = map[string]bool{
+// Markdown attributes used by the Chroma highlighter.
+var chromaHighlightProcessingAttributes = map[string]bool{
"anchorLineNos": true,
"guessSyntax": true,
"hl_Lines": true,
}
func init() {
- for k, v := range chromaHightlightProcessingAttributes {
- chromaHightlightProcessingAttributes[strings.ToLower(k)] = v
+ for k, v := range chromaHighlightProcessingAttributes {
+ chromaHighlightProcessingAttributes[strings.ToLower(k)] = v
}
}
type Highlighter interface {
Highlight(code, lang string, opts any) (string, error)
- HighlightCodeBlock(ctx hooks.CodeblockContext, opts any) (HightlightResult, error)
+ HighlightCodeBlock(ctx hooks.CodeblockContext, opts any) (HighlightResult, error)
hooks.CodeBlockRenderer
hooks.IsDefaultCodeBlockRendererProvider
}
return b.String(), nil
}
-func (h chromaHighlighter) HighlightCodeBlock(ctx hooks.CodeblockContext, opts any) (HightlightResult, error) {
+func (h chromaHighlighter) HighlightCodeBlock(ctx hooks.CodeblockContext, opts any) (HighlightResult, error) {
cfg := h.cfg
var b strings.Builder
options := ctx.Options()
if err := applyOptionsFromMap(options, &cfg); err != nil {
- return HightlightResult{}, err
+ return HighlightResult{}, err
}
// Apply these last so the user can override them.
if err := applyOptions(opts, &cfg); err != nil {
- return HightlightResult{}, err
+ return HighlightResult{}, err
}
if err := applyOptionsFromCodeBlockContext(ctx, &cfg); err != nil {
- return HightlightResult{}, err
+ return HighlightResult{}, err
}
low, high, err := highlight(&b, ctx.Inner(), ctx.Type(), attributes, cfg)
if err != nil {
- return HightlightResult{}, err
+ return HighlightResult{}, err
}
highlighted := b.String()
high = len(highlighted)
}
- return HightlightResult{
+ return HighlightResult{
highlighted: template.HTML(highlighted),
innerLow: low,
innerHigh: high,
return id
}
-// HightlightResult holds the result of an highlighting operation.
-type HightlightResult struct {
+// HighlightResult holds the result of an highlighting operation.
+type HighlightResult struct {
innerLow int
innerHigh int
highlighted template.HTML
}
// Wrapped returns the highlighted code wrapped in a <div>, <pre> and <code> tag.
-func (h HightlightResult) Wrapped() template.HTML {
+func (h HighlightResult) Wrapped() template.HTML {
return h.highlighted
}
// Inner returns the highlighted code without the wrapping <div>, <pre> and <code> tag, suitable for inline use.
-func (h HightlightResult) Inner() template.HTML {
+func (h HighlightResult) Inner() template.HTML {
return h.highlighted[h.innerLow:h.innerHigh]
}
)
// Markdown attributes used as options by the Chroma highlighter.
-var chromaHightlightProcessingAttributes = map[string]bool{
+var chromaHighlightProcessingAttributes = map[string]bool{
"anchorLineNos": true,
"guessSyntax": true,
"hl_Lines": true,
}
func init() {
- for k, v := range chromaHightlightProcessingAttributes {
- chromaHightlightProcessingAttributes[strings.ToLower(k)] = v
+ for k, v := range chromaHighlightProcessingAttributes {
+ chromaHighlightProcessingAttributes[strings.ToLower(k)] = v
}
}
panic(fmt.Sprintf("not implemented: %T", vvv))
}
- if ownerType == AttributesOwnerCodeBlockChroma && chromaHightlightProcessingAttributes[nameLower] {
+ if ownerType == AttributesOwnerCodeBlockChroma && chromaHighlightProcessingAttributes[nameLower] {
attr := Attribute{Name: string(v.Name), Value: vv}
opts = append(opts, attr)
} else {