mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-27 06:00:25 +03:00
markup/highlight: Add hl_inline option
If set to true, the highlighted code will not be wrapped in any div. Closes #9442
This commit is contained in:
parent
c97fed08f9
commit
a360cab75a
4 changed files with 72 additions and 2 deletions
|
@ -75,11 +75,24 @@ func (h chromaHighlighter) Highlight(code, lang string, opts interface{}) (strin
|
|||
}
|
||||
var b strings.Builder
|
||||
|
||||
if _, _, err := highlight(&b, code, lang, nil, cfg); err != nil {
|
||||
low, high, err := highlight(&b, code, lang, nil, cfg)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return b.String(), nil
|
||||
if !cfg.Hl_inline {
|
||||
return b.String(), nil
|
||||
}
|
||||
|
||||
hr := HightlightResult{
|
||||
highlighted: template.HTML(b.String()),
|
||||
innerLow: low,
|
||||
innerHigh: high,
|
||||
}
|
||||
|
||||
return string(hr.Inner()), nil
|
||||
|
||||
}
|
||||
|
||||
func (h chromaHighlighter) HighlightCodeBlock(ctx hooks.CodeblockContext, opts interface{}) (HightlightResult, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue