markup: Reimplement pygmentsCodefencesGuessSyntax

Fixes #6565
This commit is contained in:
Bjørn Erik Pedersen
2019-12-02 08:31:23 +01:00
parent d534ce9424
commit 40a092b068
10 changed files with 74 additions and 9 deletions

View File

@@ -198,6 +198,7 @@ func newHighlighting(cfg highlight.Config) goldmark.Extender {
e := hl.NewHighlighting(
hl.WithStyle(cfg.Style),
hl.WithGuessLanguage(cfg.GuessSyntax),
hl.WithCodeBlockOptions(highlight.GetCodeBlockOptions()),
hl.WithFormatOptions(
cfg.ToHTMLOptions()...,

View File

@@ -224,4 +224,25 @@ LINE5
result = convertForConfig(c, cfg, lines, "bash {linenos=table}")
c.Assert(result, qt.Contains, "<span class=\"lnt\">1\n</span>")
})
c.Run("No language", func(c *qt.C) {
cfg := highlight.DefaultConfig
cfg.NoClasses = false
cfg.LineNos = true
cfg.LineNumbersInTable = false
result := convertForConfig(c, cfg, lines, "")
c.Assert(result, qt.Contains, "<pre><code>LINE1\n")
})
c.Run("No language, guess syntax", func(c *qt.C) {
cfg := highlight.DefaultConfig
cfg.NoClasses = false
cfg.GuessSyntax = true
cfg.LineNos = true
cfg.LineNumbersInTable = false
result := convertForConfig(c, cfg, lines, "")
c.Assert(result, qt.Contains, "<span class=\"ln\">2</span>LINE2\n<")
})
}