diff options
Diffstat (limited to 'markup/highlight')
-rw-r--r-- | markup/highlight/highlight.go | 2 | ||||
-rw-r--r-- | markup/highlight/highlight_test.go | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/markup/highlight/highlight.go b/markup/highlight/highlight.go index 4727843cc..772244a91 100644 --- a/markup/highlight/highlight.go +++ b/markup/highlight/highlight.go @@ -123,7 +123,7 @@ type preWrapper struct { func (p preWrapper) Start(code bool, styleAttr string) string { w := &strings.Builder{} - fmt.Fprintf(w, "<pre%s>", styleAttr) + fmt.Fprintf(w, `<pre tabindex="0"%s>`, styleAttr) var language string if code { language = p.language diff --git a/markup/highlight/highlight_test.go b/markup/highlight/highlight_test.go index eb8ba3e96..f68df629a 100644 --- a/markup/highlight/highlight_test.go +++ b/markup/highlight/highlight_test.go @@ -43,9 +43,9 @@ User-Agent: foo h := New(cfg) result, _ := h.Highlight(`echo "Hugo Rocks!"`, "bash", "") - c.Assert(result, qt.Equals, `<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash"><span class="nb">echo</span> <span class="s2">"Hugo Rocks!"</span></code></pre></div>`) + c.Assert(result, qt.Equals, `<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="nb">echo</span> <span class="s2">"Hugo Rocks!"</span></code></pre></div>`) result, _ = h.Highlight(`echo "Hugo Rocks!"`, "unknown", "") - c.Assert(result, qt.Equals, `<pre><code class="language-unknown" data-lang="unknown">echo "Hugo Rocks!"</code></pre>`) + c.Assert(result, qt.Equals, `<pre tabindex="0"><code class="language-unknown" data-lang="unknown">echo "Hugo Rocks!"</code></pre>`) }) c.Run("Highlight lines, default config", func(c *qt.C) { @@ -54,7 +54,7 @@ User-Agent: foo h := New(cfg) result, _ := h.Highlight(lines, "bash", "linenos=table,hl_lines=2 4-5,linenostart=3") - c.Assert(result, qt.Contains, "<div class=\"highlight\"><div class=\"chroma\">\n<table class=\"lntable\"><tr><td class=\"lntd\">\n<pre class=\"chroma\"><code><span class") + c.Assert(result, qt.Contains, "<div class=\"highlight\"><div class=\"chroma\">\n<table class=\"lntable\"><tr><td class=\"lntd\">\n<pre tabindex=\"0\" class=\"chroma\"><code><span class") c.Assert(result, qt.Contains, "<span class=\"hl\"><span class=\"lnt\">4") result, _ = h.Highlight(lines, "bash", "linenos=inline,hl_lines=2") @@ -113,7 +113,7 @@ User-Agent: foo h := New(cfg) result, _ := h.Highlight(lines, "", "") - c.Assert(result, qt.Equals, "<pre><code>LINE1\nLINE2\nLINE3\nLINE4\nLINE5\n</code></pre>") + c.Assert(result, qt.Equals, "<pre tabindex=\"0\"><code>LINE1\nLINE2\nLINE3\nLINE4\nLINE5\n</code></pre>") }) c.Run("No language, guess syntax", func(c *qt.C) { |