diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-12-02 08:31:23 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-12-02 14:12:23 +0100 |
commit | 40a092b0687d44ecb53ef1fd53001a6299345780 (patch) | |
tree | 2a5047d0affd152da90a8e3105fa12ad470989b2 /markup/goldmark | |
parent | d534ce9424c952800dfb26c2faff2d47e9597cad (diff) |
markup: Reimplement pygmentsCodefencesGuessSyntax
Fixes #6565
Diffstat (limited to 'markup/goldmark')
-rw-r--r-- | markup/goldmark/convert.go | 1 | ||||
-rw-r--r-- | markup/goldmark/convert_test.go | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/markup/goldmark/convert.go b/markup/goldmark/convert.go index 167286831..15b0f0d77 100644 --- a/markup/goldmark/convert.go +++ b/markup/goldmark/convert.go @@ -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()..., diff --git a/markup/goldmark/convert_test.go b/markup/goldmark/convert_test.go index a23976fd6..b6816d2e5 100644 --- a/markup/goldmark/convert_test.go +++ b/markup/goldmark/convert_test.go @@ -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<") + }) } |