NoClasses: true,
LineNumbersInTable: true,
TabWidth: 4,
+ WrapperClass: "highlight",
}
type Config struct {
Style string
+ // Enable syntax highlighting of fenced code blocks.
CodeFences bool
+ // The class or classes to use for the outermost element of the highlighted code.
+ WrapperClass string
+
// Use inline CSS styles.
NoClasses bool
}
if !cfg.Hl_inline {
- writeDivStart(w, attributes)
+ writeDivStart(w, attributes, cfg.WrapperClass)
}
options := cfg.toHTMLOptions()
return s.end(code)
}
-func writeDivStart(w hugio.FlexiWriter, attrs []attributes.Attribute) {
- w.WriteString(`<div class="highlight`)
+func writeDivStart(w hugio.FlexiWriter, attrs []attributes.Attribute, wrapperClass string) {
+ w.WriteString(`<div class="`)
+ w.WriteString(wrapperClass)
if attrs != nil {
for _, attr := range attrs {
if attr.Name == "class" {
<span class="nx">xəx</span>
`)
}
+
+func TestHighlightClass(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- config.toml --
+[markup.highlight]
+noClasses = false
+wrapperClass = "highlight no-prose"
+-- content/_index.md --
+---
+title: home
+---
+§§§go
+xəx := 0
+§§§
+-- layouts/index.html --
+{{ .Content }}
+`
+
+ b := hugolib.Test(t, files)
+
+ b.AssertFileContent("public/index.html", `
+ <div class="highlight no-prose"><pre
+ `)
+}