From 10c65de6b22211743056de1bf5066eaae249deb5 Mon Sep 17 00:00:00 2001 From: Xavier Coulon Date: Wed, 28 Sep 2022 19:30:42 +0200 Subject: [PATCH] chore(renderer): update alecthomas/chroma to v2.3.0 include changes in expected rendering Fixes #1058 Signed-off-by: Xavier Coulon --- go.mod | 2 +- go.sum | 6 +- pkg/renderer/sgml/delimited_block_source.go | 10 ++-- .../sgml/html5/delimited_block_source_test.go | 58 +++++++++---------- pkg/renderer/sgml/html5/paragraph_test.go | 2 +- .../xhtml5/delimited_block_source_test.go | 32 +++++----- pkg/renderer/sgml/xhtml5/paragraph_test.go | 2 +- 7 files changed, 57 insertions(+), 55 deletions(-) diff --git a/go.mod b/go.mod index cf8a0655..747174b7 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 2a0a14d1..17af4dbe 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/pkg/renderer/sgml/delimited_block_source.go b/pkg/renderer/sgml/delimited_block_source.go index d622cc88..75150fad 100644 --- a/pkg/renderer/sgml/delimited_block_source.go +++ b/pkg/renderer/sgml/delimited_block_source.go @@ -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" @@ -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 diff --git a/pkg/renderer/sgml/html5/delimited_block_source_test.go b/pkg/renderer/sgml/html5/delimited_block_source_test.go index 0ee85d0e..a624455e 100644 --- a/pkg/renderer/sgml/html5/delimited_block_source_test.go +++ b/pkg/renderer/sgml/html5/delimited_block_source_test.go @@ -151,11 +151,11 @@ printf("Hello world!\n"); // <1> ` expected := `
-
#include <stdio.h>
+
#include <stdio.h>
 
-printf("Hello world!\n"); // 
-(1)
-<a>link</a>
+printf("Hello world!\n"); // +(1) +<a>link</a>
@@ -183,11 +183,11 @@ printf("Hello world!\n"); // <1> ` expected := `
-
#include <stdio.h>
+
#include <stdio.h>
 
-printf("Hello world!\n"); // 
-(1)
-<a>link</a>
+printf("Hello world!\n"); // +(1) +<a>link</a>
@@ -215,11 +215,11 @@ printf("Hello world!\n"); // <1> ` expected := `
-
#include <stdio.h>
+
#include <stdio.h>
 
-printf("Hello world!\n"); // 
-(1)
-<a>link</a>
+printf("Hello world!\n"); // +(1) +<a>link</a>
@@ -374,9 +374,9 @@ type Foo struct{ ----` expected := `
-
type Foo struct{
-    Field string
-}
+
type Foo struct{
+    Field string
+}
` @@ -435,9 +435,9 @@ type Foo struct{ ----` expected := `
-
type Foo struct{
-    Field string
-}
+
type Foo struct{
+    Field string
+}
` @@ -457,9 +457,9 @@ type Foo struct{ ----` expected := `
-
1type Foo struct{
-2    Field string
-3}
+
type Foo struct{
+    Field string
+}
` // the pygment.py sets the line number class to `tok-ln` but here we expect `tok-ln` @@ -480,9 +480,9 @@ type Foo struct{ ----` expected := `
-
1type Foo struct{
-2    Field string
-3}
+
type Foo struct{
+    Field string
+}
` // the pygment.py sets the line number class to `tok-ln` but here we expect `tok-ln` @@ -501,7 +501,7 @@ const Cookie = "cookie" ----` expected := `
-
const Cookie = "cookie"
+
const Cookie = "cookie"
` @@ -519,7 +519,7 @@ const Cookie = "cookie" ----` expected := `
-
+
` @@ -537,7 +537,7 @@ Copyright (C) ----` expected := `
-
Copyright (C)
+
Copyright (C)
` @@ -576,7 +576,7 @@ Copyright (C) "```\n" expected := `
-
+
` @@ -594,7 +594,7 @@ Copyright (C) "```\n" expected := `
-
Copyright (C)
+
Copyright (C)
` diff --git a/pkg/renderer/sgml/html5/paragraph_test.go b/pkg/renderer/sgml/html5/paragraph_test.go index 36a588e5..ac02cf5c 100644 --- a/pkg/renderer/sgml/html5/paragraph_test.go +++ b/pkg/renderer/sgml/html5/paragraph_test.go @@ -699,7 +699,7 @@ int main(int argc, char **argv); ` expected := `
-
int main(int argc, char **argv);
+
int main(int argc, char **argv);
` diff --git a/pkg/renderer/sgml/xhtml5/delimited_block_source_test.go b/pkg/renderer/sgml/xhtml5/delimited_block_source_test.go index ff35c320..962b171d 100644 --- a/pkg/renderer/sgml/xhtml5/delimited_block_source_test.go +++ b/pkg/renderer/sgml/xhtml5/delimited_block_source_test.go @@ -151,11 +151,11 @@ printf("Hello world!\n"); // <1> ` expected := `
-
#include <stdio.h>
+
#include <stdio.h>
 
-printf("Hello world!\n"); // 
-(1)
-<a>link</a>
+printf("Hello world!\n"); // +(1) +<a>link</a>
@@ -253,9 +253,9 @@ type Foo struct{ ----` expected := `
-
type Foo struct{
-    Field string
-}
+
type Foo struct{
+    Field string
+}
` @@ -314,9 +314,9 @@ type Foo struct{ ----` expected := `
-
type Foo struct{
-    Field string
-}
+
type Foo struct{
+    Field string
+}
` @@ -336,9 +336,9 @@ type Foo struct{ ----` expected := `
-
1type Foo struct{
-2    Field string
-3}
+
type Foo struct{
+    Field string
+}
` // the pygment.py sets the line number class to `tok-ln` but here we expect `tok-ln` @@ -359,9 +359,9 @@ type Foo struct{ ----` expected := `
-
1type Foo struct{
-2    Field string
-3}
+
type Foo struct{
+    Field string
+}
` // the pygment.py sets the line number class to `tok-ln` but here we expect `tok-ln` diff --git a/pkg/renderer/sgml/xhtml5/paragraph_test.go b/pkg/renderer/sgml/xhtml5/paragraph_test.go index a49b6676..092d059b 100644 --- a/pkg/renderer/sgml/xhtml5/paragraph_test.go +++ b/pkg/renderer/sgml/xhtml5/paragraph_test.go @@ -521,7 +521,7 @@ int main(int argc, char **argv); ` expected := `
-
int main(int argc, char **argv);
+
int main(int argc, char **argv);
`