Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(renderer): update alecthomas/chroma to v2.3.0 #1089

Merged
merged 1 commit into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/bytesparadise/libasciidoc
go 1.17

require (
github.com/alecthomas/chroma v0.10.0
github.com/alecthomas/chroma/v2 v2.3.0
github.com/davecgh/go-spew v1.1.1
github.com/felixge/fgtrace v0.1.0
github.com/google/go-cmp v0.5.5
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
github.com/DataDog/gostackparse v0.5.0 h1:jb72P6GFHPHz2W0onsN51cS3FkaMDcjb0QzgxxA4gDk=
github.com/DataDog/gostackparse v0.5.0/go.mod h1:lTfqcJKqS9KnXQGnyQMCugq3u1FP6UZMfWR0aitKFMM=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek=
github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=
github.com/alecthomas/chroma/v2 v2.3.0 h1:83xfxrnjv8eK+Cf8qZDzNo3PPF9IbTWHs7z28GY6D0U=
github.com/alecthomas/chroma/v2 v2.3.0/go.mod h1:mZxeWZlxP2Dy+/8cBob2PYd8O2DwNAzave5AY7A2eQw=
github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE=
github.com/alecthomas/repr v0.1.0/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
Expand Down
10 changes: 5 additions & 5 deletions pkg/renderer/sgml/delimited_block_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"fmt"
"strings"

"github.com/alecthomas/chroma"
"github.com/alecthomas/chroma/formatters/html"
"github.com/alecthomas/chroma/lexers"
"github.com/alecthomas/chroma/styles"
"github.com/alecthomas/chroma/v2"
"github.com/alecthomas/chroma/v2/formatters/html"
"github.com/alecthomas/chroma/v2/lexers"
"github.com/alecthomas/chroma/v2/styles"
"github.com/bytesparadise/libasciidoc/pkg/types"
"github.com/davecgh/go-spew/spew"
"github.com/pkg/errors"
Expand Down Expand Up @@ -87,7 +87,7 @@ func (r *sgmlRenderer) renderSourceBlockElements(ctx *context, b *types.Delimite
if log.IsLevelEnabled(log.DebugLevel) {
log.Debugf("splitted lines:\n%s", spew.Sdump(lines))
}
// using github.com/alecthomas/chroma to highlight the content
// using github.com/alecthomas/v2 to highlight the content
lexer := lexers.Get(language)
if lexer == nil {
lexer = lexers.Fallback
Expand Down
58 changes: 29 additions & 29 deletions pkg/renderer/sgml/html5/delimited_block_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ printf("Hello world!\n"); // <1>
`
expected := `<div class="listingblock">
<div class="content">
<pre class="chroma highlight"><code data-lang="c"><span class="tok-line"><span class="tok-cl"><span class="tok-cp">#include</span> <span class="tok-cpf">&lt;stdio.h&gt;</span></span></span>
<pre class="chroma highlight"><code data-lang="c"><span class="tok-cp">#include</span> <span class="tok-cpf">&lt;stdio.h&gt;</span>

<span class="tok-line"><span class="tok-cl"><span class="tok-n">printf</span><span class="tok-p">(</span><span class="tok-s">&#34;Hello world!</span><span class="tok-se">\n</span><span class="tok-s">&#34;</span><span class="tok-p">);</span> <span class="tok-c1">//
</span></span></span><b class="conum">(1)</b>
<span class="tok-line"><span class="tok-cl"><span class="tok-o">&lt;</span><span class="tok-n">a</span><span class="tok-o">&gt;</span><span class="tok-n">link</span><span class="tok-o">&lt;/</span><span class="tok-n">a</span><span class="tok-o">&gt;</span></span></span></code></pre>
<span class="tok-n">printf</span><span class="tok-p">(</span><span class="tok-s">&#34;Hello world!</span><span class="tok-se">\n</span><span class="tok-s">&#34;</span><span class="tok-p">);</span> <span class="tok-c1">//
</span><b class="conum">(1)</b>
<span class="tok-o">&lt;</span><span class="tok-n">a</span><span class="tok-o">&gt;</span><span class="tok-n">link</span><span class="tok-o">&lt;/</span><span class="tok-n">a</span><span class="tok-o">&gt;</span></code></pre>
</div>
</div>
<div class="colist arabic">
Expand Down Expand Up @@ -183,11 +183,11 @@ printf("Hello world!\n"); // <1>
`
expected := `<div class="listingblock">
<div class="content">
<pre class="chroma highlight"><code data-lang="c"><span class="myprefix-line"><span class="myprefix-cl"><span class="myprefix-cp">#include</span> <span class="myprefix-cpf">&lt;stdio.h&gt;</span></span></span>
<pre class="chroma highlight"><code data-lang="c"><span class="myprefix-cp">#include</span> <span class="myprefix-cpf">&lt;stdio.h&gt;</span>

<span class="myprefix-line"><span class="myprefix-cl"><span class="myprefix-n">printf</span><span class="myprefix-p">(</span><span class="myprefix-s">&#34;Hello world!</span><span class="myprefix-se">\n</span><span class="myprefix-s">&#34;</span><span class="myprefix-p">);</span> <span class="myprefix-c1">//
</span></span></span><b class="conum">(1)</b>
<span class="myprefix-line"><span class="myprefix-cl"><span class="myprefix-o">&lt;</span><span class="myprefix-n">a</span><span class="myprefix-o">&gt;</span><span class="myprefix-n">link</span><span class="myprefix-o">&lt;/</span><span class="myprefix-n">a</span><span class="myprefix-o">&gt;</span></span></span></code></pre>
<span class="myprefix-n">printf</span><span class="myprefix-p">(</span><span class="myprefix-s">&#34;Hello world!</span><span class="myprefix-se">\n</span><span class="myprefix-s">&#34;</span><span class="myprefix-p">);</span> <span class="myprefix-c1">//
</span><b class="conum">(1)</b>
<span class="myprefix-o">&lt;</span><span class="myprefix-n">a</span><span class="myprefix-o">&gt;</span><span class="myprefix-n">link</span><span class="myprefix-o">&lt;/</span><span class="myprefix-n">a</span><span class="myprefix-o">&gt;</span></code></pre>
</div>
</div>
<div class="colist arabic">
Expand Down Expand Up @@ -215,11 +215,11 @@ printf("Hello world!\n"); // <1>
`
expected := `<div class="listingblock">
<div class="content">
<pre class="chroma highlight"><code data-lang="c"><span class="line"><span class="cl"><span class="cp">#include</span> <span class="cpf">&lt;stdio.h&gt;</span></span></span>
<pre class="chroma highlight"><code data-lang="c"><span class="cp">#include</span> <span class="cpf">&lt;stdio.h&gt;</span>

<span class="line"><span class="cl"><span class="n">printf</span><span class="p">(</span><span class="s">&#34;Hello world!</span><span class="se">\n</span><span class="s">&#34;</span><span class="p">);</span> <span class="c1">//
</span></span></span><b class="conum">(1)</b>
<span class="line"><span class="cl"><span class="o">&lt;</span><span class="n">a</span><span class="o">&gt;</span><span class="n">link</span><span class="o">&lt;/</span><span class="n">a</span><span class="o">&gt;</span></span></span></code></pre>
<span class="n">printf</span><span class="p">(</span><span class="s">&#34;Hello world!</span><span class="se">\n</span><span class="s">&#34;</span><span class="p">);</span> <span class="c1">//
</span><b class="conum">(1)</b>
<span class="o">&lt;</span><span class="n">a</span><span class="o">&gt;</span><span class="n">link</span><span class="o">&lt;/</span><span class="n">a</span><span class="o">&gt;</span></code></pre>
</div>
</div>
<div class="colist arabic">
Expand Down Expand Up @@ -374,9 +374,9 @@ type Foo struct{
----`
expected := `<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="go"><span class="tok-line"><span class="tok-cl"><span class="tok-kd">type</span> <span class="tok-nx">Foo</span> <span class="tok-kd">struct</span><span class="tok-p">{</span></span></span>
<span class="tok-line"><span class="tok-cl"> <span class="tok-nx">Field</span> <span class="tok-kt">string</span></span></span>
<span class="tok-line"><span class="tok-cl"><span class="tok-p">}</span></span></span></code></pre>
<pre class="pygments highlight"><code data-lang="go"><span class="tok-kd">type</span> <span class="tok-nx">Foo</span> <span class="tok-kd">struct</span><span class="tok-p">{</span>
<span class="tok-nx">Field</span> <span class="tok-kt">string</span>
<span class="tok-p">}</span></code></pre>
</div>
</div>
`
Expand Down Expand Up @@ -435,9 +435,9 @@ type Foo struct{
----`
expected := `<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="go"><span class="tok-line"><span class="tok-cl"><span class="tok-kd">type</span> <span class="tok-nx">Foo</span> <span class="tok-kd">struct</span><span class="tok-p">{</span></span></span>
<span class="tok-line"><span class="tok-cl"> <span class="tok-nx">Field</span> <span class="tok-kt">string</span></span></span>
<span class="tok-line"><span class="tok-cl"><span class="tok-p">}</span></span></span></code></pre>
<pre class="pygments highlight"><code data-lang="go"><span class="tok-kd">type</span> <span class="tok-nx">Foo</span> <span class="tok-kd">struct</span><span class="tok-p">{</span>
<span class="tok-nx">Field</span> <span class="tok-kt">string</span>
<span class="tok-p">}</span></code></pre>
</div>
</div>
`
Expand All @@ -457,9 +457,9 @@ type Foo struct{
----`
expected := `<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="go"><span class="tok-line"><span class="tok-ln">1</span><span class="tok-cl"><span class="tok-kd">type</span> <span class="tok-nx">Foo</span> <span class="tok-kd">struct</span><span class="tok-p">{</span></span></span>
<span class="tok-line"><span class="tok-ln">2</span><span class="tok-cl"> <span class="tok-nx">Field</span> <span class="tok-kt">string</span></span></span>
<span class="tok-line"><span class="tok-ln">3</span><span class="tok-cl"><span class="tok-p">}</span></span></span></code></pre>
<pre class="pygments highlight"><code data-lang="go"><span class="tok-kd">type</span> <span class="tok-nx">Foo</span> <span class="tok-kd">struct</span><span class="tok-p">{</span>
<span class="tok-nx">Field</span> <span class="tok-kt">string</span>
<span class="tok-p">}</span></code></pre>
</div>
</div>
` // the pygment.py sets the line number class to `tok-ln` but here we expect `tok-ln`
Expand All @@ -480,9 +480,9 @@ type Foo struct{
----`
expected := `<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="go"><span style="display:flex;"><span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1</span><span><span style="color:#069;font-weight:bold">type</span> Foo <span style="color:#069;font-weight:bold">struct</span>{</span></span>
<span style="display:flex;"><span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2</span><span> Field <span style="color:#078;font-weight:bold">string</span></span></span>
<span style="display:flex;"><span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3</span><span>}</span></span></code></pre>
<pre class="pygments highlight"><code data-lang="go"><span style="color:#069;font-weight:bold">type</span> Foo <span style="color:#069;font-weight:bold">struct</span>{
Field <span style="color:#078;font-weight:bold">string</span>
}</code></pre>
</div>
</div>
` // the pygment.py sets the line number class to `tok-ln` but here we expect `tok-ln`
Expand All @@ -501,7 +501,7 @@ const Cookie = "cookie"
----`
expected := `<div class="listingblock">
<div class="content">
<pre class="pygments highlight nowrap"><code data-lang="go"><span style="display:flex;"><span><span style="color:#069;font-weight:bold">const</span> Cookie = <span style="color:#c30">&#34;cookie&#34;</span></span></span></code></pre>
<pre class="pygments highlight nowrap"><code data-lang="go"><span style="color:#069;font-weight:bold">const</span> Cookie = <span style="color:#c30">&#34;cookie&#34;</span></code></pre>
</div>
</div>
`
Expand All @@ -519,7 +519,7 @@ const Cookie = "cookie"
----`
expected := `<div class="listingblock">
<div class="content">
<pre class="chroma highlight"><code data-lang="c"><span class="tok-line"><span class="tok-cl"><span class="tok-err">…</span></span></span></code></pre>
<pre class="chroma highlight"><code data-lang="c"><span class="tok-err">…</span></code></pre>
</div>
</div>
`
Expand All @@ -537,7 +537,7 @@ Copyright (C)
----`
expected := `<div class="listingblock">
<div class="content">
<pre class="chroma highlight"><code data-lang="c"><span class="tok-line"><span class="tok-cl"><span class="tok-n">Copyright</span> <span class="tok-p">(</span><span class="tok-n">C</span><span class="tok-p">)</span></span></span></code></pre>
<pre class="chroma highlight"><code data-lang="c"><span class="tok-n">Copyright</span> <span class="tok-p">(</span><span class="tok-n">C</span><span class="tok-p">)</span></code></pre>
</div>
</div>
`
Expand Down Expand Up @@ -576,7 +576,7 @@ Copyright (C)
"```\n"
expected := `<div class="listingblock">
<div class="content">
<pre class="chroma highlight"><code data-lang="c"><span class="tok-line"><span class="tok-cl"><span class="tok-err">…</span></span></span></code></pre>
<pre class="chroma highlight"><code data-lang="c"><span class="tok-err">…</span></code></pre>
</div>
</div>
`
Expand All @@ -594,7 +594,7 @@ Copyright (C)
"```\n"
expected := `<div class="listingblock">
<div class="content">
<pre class="chroma highlight"><code data-lang="c"><span class="tok-line"><span class="tok-cl"><span class="tok-n">Copyright</span> <span class="tok-p">(</span><span class="tok-n">C</span><span class="tok-p">)</span></span></span></code></pre>
<pre class="chroma highlight"><code data-lang="c"><span class="tok-n">Copyright</span> <span class="tok-p">(</span><span class="tok-n">C</span><span class="tok-p">)</span></code></pre>
</div>
</div>
`
Expand Down
2 changes: 1 addition & 1 deletion pkg/renderer/sgml/html5/paragraph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ int main(int argc, char **argv);
`
expected := `<div class="listingblock">
<div class="content">
<pre class="chroma highlight"><code data-lang="c"><span class="tok-line"><span class="tok-cl"><span class="tok-kt">int</span> <span class="tok-nf">main</span><span class="tok-p">(</span><span class="tok-kt">int</span> <span class="tok-n">argc</span><span class="tok-p">,</span> <span class="tok-kt">char</span> <span class="tok-o">**</span><span class="tok-n">argv</span><span class="tok-p">);</span></span></span></code></pre>
<pre class="chroma highlight"><code data-lang="c"><span class="tok-kt">int</span> <span class="tok-nf">main</span><span class="tok-p">(</span><span class="tok-kt">int</span> <span class="tok-n">argc</span><span class="tok-p">,</span> <span class="tok-kt">char</span> <span class="tok-o">**</span><span class="tok-n">argv</span><span class="tok-p">);</span></code></pre>
</div>
</div>
`
Expand Down
32 changes: 16 additions & 16 deletions pkg/renderer/sgml/xhtml5/delimited_block_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ printf("Hello world!\n"); // <1>
`
expected := `<div class="listingblock">
<div class="content">
<pre class="chroma highlight"><code data-lang="c"><span class="tok-line"><span class="tok-cl"><span class="tok-cp">#include</span> <span class="tok-cpf">&lt;stdio.h&gt;</span></span></span>
<pre class="chroma highlight"><code data-lang="c"><span class="tok-cp">#include</span> <span class="tok-cpf">&lt;stdio.h&gt;</span>

<span class="tok-line"><span class="tok-cl"><span class="tok-n">printf</span><span class="tok-p">(</span><span class="tok-s">&#34;Hello world!</span><span class="tok-se">\n</span><span class="tok-s">&#34;</span><span class="tok-p">);</span> <span class="tok-c1">//
</span></span></span><b class="conum">(1)</b>
<span class="tok-line"><span class="tok-cl"><span class="tok-o">&lt;</span><span class="tok-n">a</span><span class="tok-o">&gt;</span><span class="tok-n">link</span><span class="tok-o">&lt;/</span><span class="tok-n">a</span><span class="tok-o">&gt;</span></span></span></code></pre>
<span class="tok-n">printf</span><span class="tok-p">(</span><span class="tok-s">&#34;Hello world!</span><span class="tok-se">\n</span><span class="tok-s">&#34;</span><span class="tok-p">);</span> <span class="tok-c1">//
</span><b class="conum">(1)</b>
<span class="tok-o">&lt;</span><span class="tok-n">a</span><span class="tok-o">&gt;</span><span class="tok-n">link</span><span class="tok-o">&lt;/</span><span class="tok-n">a</span><span class="tok-o">&gt;</span></code></pre>
</div>
</div>
<div class="colist arabic">
Expand Down Expand Up @@ -253,9 +253,9 @@ type Foo struct{
----`
expected := `<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="go"><span class="tok-line"><span class="tok-cl"><span class="tok-kd">type</span> <span class="tok-nx">Foo</span> <span class="tok-kd">struct</span><span class="tok-p">{</span></span></span>
<span class="tok-line"><span class="tok-cl"> <span class="tok-nx">Field</span> <span class="tok-kt">string</span></span></span>
<span class="tok-line"><span class="tok-cl"><span class="tok-p">}</span></span></span></code></pre>
<pre class="pygments highlight"><code data-lang="go"><span class="tok-kd">type</span> <span class="tok-nx">Foo</span> <span class="tok-kd">struct</span><span class="tok-p">{</span>
<span class="tok-nx">Field</span> <span class="tok-kt">string</span>
<span class="tok-p">}</span></code></pre>
</div>
</div>
`
Expand Down Expand Up @@ -314,9 +314,9 @@ type Foo struct{
----`
expected := `<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="go"><span class="tok-line"><span class="tok-cl"><span class="tok-kd">type</span> <span class="tok-nx">Foo</span> <span class="tok-kd">struct</span><span class="tok-p">{</span></span></span>
<span class="tok-line"><span class="tok-cl"> <span class="tok-nx">Field</span> <span class="tok-kt">string</span></span></span>
<span class="tok-line"><span class="tok-cl"><span class="tok-p">}</span></span></span></code></pre>
<pre class="pygments highlight"><code data-lang="go"><span class="tok-kd">type</span> <span class="tok-nx">Foo</span> <span class="tok-kd">struct</span><span class="tok-p">{</span>
<span class="tok-nx">Field</span> <span class="tok-kt">string</span>
<span class="tok-p">}</span></code></pre>
</div>
</div>
`
Expand All @@ -336,9 +336,9 @@ type Foo struct{
----`
expected := `<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="go"><span class="tok-line"><span class="tok-ln">1</span><span class="tok-cl"><span class="tok-kd">type</span> <span class="tok-nx">Foo</span> <span class="tok-kd">struct</span><span class="tok-p">{</span></span></span>
<span class="tok-line"><span class="tok-ln">2</span><span class="tok-cl"> <span class="tok-nx">Field</span> <span class="tok-kt">string</span></span></span>
<span class="tok-line"><span class="tok-ln">3</span><span class="tok-cl"><span class="tok-p">}</span></span></span></code></pre>
<pre class="pygments highlight"><code data-lang="go"><span class="tok-kd">type</span> <span class="tok-nx">Foo</span> <span class="tok-kd">struct</span><span class="tok-p">{</span>
<span class="tok-nx">Field</span> <span class="tok-kt">string</span>
<span class="tok-p">}</span></code></pre>
</div>
</div>
` // the pygment.py sets the line number class to `tok-ln` but here we expect `tok-ln`
Expand All @@ -359,9 +359,9 @@ type Foo struct{
----`
expected := `<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="go"><span style="display:flex;"><span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1</span><span><span style="color:#069;font-weight:bold">type</span> Foo <span style="color:#069;font-weight:bold">struct</span>{</span></span>
<span style="display:flex;"><span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2</span><span> Field <span style="color:#078;font-weight:bold">string</span></span></span>
<span style="display:flex;"><span style="white-space:pre;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3</span><span>}</span></span></code></pre>
<pre class="pygments highlight"><code data-lang="go"><span style="color:#069;font-weight:bold">type</span> Foo <span style="color:#069;font-weight:bold">struct</span>{
Field <span style="color:#078;font-weight:bold">string</span>
}</code></pre>
</div>
</div>
` // the pygment.py sets the line number class to `tok-ln` but here we expect `tok-ln`
Expand Down
Loading