markup/highlight: Add support to linkable line anchors on Chroma

Fixes #7622
This commit is contained in:
Fernando Jorge Mota
2020-09-13 06:00:16 -03:00
committed by GitHub
parent 748fd4cb0d
commit fb0f2cc718
3 changed files with 26 additions and 0 deletions

View File

@@ -50,6 +50,10 @@ type Config struct {
LineNos bool
LineNumbersInTable bool
// When set, add links to line numbers
AnchorLineNos bool
LineAnchors string
// Start the line numbers from this value (default is 1).
LineNoStart int
@@ -63,12 +67,17 @@ type Config struct {
}
func (cfg Config) ToHTMLOptions() []html.Option {
var lineAnchors string
if cfg.LineAnchors != "" {
lineAnchors = cfg.LineAnchors + "-"
}
var options = []html.Option{
html.TabWidth(cfg.TabWidth),
html.WithLineNumbers(cfg.LineNos),
html.BaseLineNumber(cfg.LineNoStart),
html.LineNumbersInTable(cfg.LineNumbersInTable),
html.WithClasses(!cfg.NoClasses),
html.LinkableLineNumbers(cfg.AnchorLineNos, lineAnchors),
}
if cfg.Hl_Lines != "" {