diff --git a/markup/highlight/config.go b/markup/highlight/config.go index 62db6b237ee..338ea77e502 100644 --- a/markup/highlight/config.go +++ b/markup/highlight/config.go @@ -45,13 +45,18 @@ var DefaultConfig = Config{ 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 diff --git a/markup/highlight/highlight.go b/markup/highlight/highlight.go index a284b59813c..30f225c0b2f 100644 --- a/markup/highlight/highlight.go +++ b/markup/highlight/highlight.go @@ -202,7 +202,7 @@ func highlight(fw hugio.FlexiWriter, code, lang string, attributes []attributes. } if !cfg.Hl_inline { - writeDivStart(w, attributes) + writeDivStart(w, attributes, cfg.WrapperClass) } options := cfg.toHTMLOptions() @@ -303,8 +303,9 @@ func (s startEnd) End(code bool) string { return s.end(code) } -func writeDivStart(w hugio.FlexiWriter, attrs []attributes.Attribute) { - w.WriteString(`