Comments (24)
Hey !
So I think your go.mod
file is wrong, I'm using the gopkg.in
version of Blackfriday.
It should be:
require (
github.com/Depado/bfchroma v1.1.1
gopkg.in/russross/blackfriday.v2 v2.0.0
)
Does that solve your issue ?
BTW I'm using the gopkg.in
version because of the discussion in #3
from bfchroma.
If you really want the 2.0.1 version of blackfriday, you can do this in your go.mod
:
require (
gopkg.in/russross/blackfriday.v2 v2.0.1
)
replace gopkg.in/russross/blackfriday.v2 v2.0.1 => github.com/russross/blackfriday/v2 v2.0.1
This is what I did for chromarkdown.
from bfchroma.
I will try your suggestions soon when I get back to this problem and will let you know how it goes. Thanks.
from bfchroma.
Please feel free to reopen this issue if that doesn't fix your problem !
Thanks for using my lib 😄
from bfchroma.
Hi again,
I tried a few things, for example, simply:
require github.com/Depado/bfchroma v1.1.1
This doesn't work at all. Doing go get -u
will report an error:
go: finding github.com/alecthomas/assert latest
go: finding github.com/alecthomas/colour latest
go: finding github.com/shurcooL/sanitized_anchor_name latest
go: finding golang.org/x/sys latest
go: finding github.com/alecthomas/repr latest
go: gopkg.in/russross/[email protected]: go.mod has non-....v2 module path "github.com/russross/blackfriday/v2" at revision v2.0.1
go: finding github.com/danwakefield/fnmatch latest
go get: error loading module requirements
This suggests you need to fix your dependencies versions.
I managed to get things working by following your second suggestion, more or less:
require (
github.com/Depado/bfchroma v1.1.1
gopkg.in/russross/blackfriday.v2 v2.0.1
)
replace gopkg.in/russross/blackfriday.v2 v2.0.1 => github.com/russross/blackfriday/v2 v2.0.1
After running go get -u
, this becomes:
require (
github.com/Depado/bfchroma v1.1.1
github.com/alecthomas/chroma v0.5.0 // indirect
github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/mattn/go-isatty v0.0.4 // indirect
github.com/russross/blackfriday v2.0.0+incompatible
github.com/stretchr/testify v1.2.2 // indirect
golang.org/x/sys v0.0.0-20181030150119-7e31e0c00fa0 // indirect
gopkg.in/russross/blackfriday.v2 v2.0.1
)
replace gopkg.in/russross/blackfriday.v2 v2.0.1 => github.com/russross/blackfriday/v2 v2.0.1
So, now I can proceed... thanks!
from bfchroma.
Cool !
So do you think I need to do some adjustments on my side ? Maybe the replace should be in bfchroma's go.mod ?
Thanks for the feedback anyway, I'm glad it works with the proposed fix !
from bfchroma.
The problem seems to be on the Blackfriday project.
Just create a completely new Go project with a go.mod
file (outside GOPATH) and run this:
go get -u gopkg.in/russross/blackfriday.v2
I am getting this error (which is what I was having when requiring this project):
go: gopkg.in/russross/[email protected]: go.mod has non-....v2 module path "github.com/russross/blackfriday/v2" at revision v2.0.1
go get: error loading module requirements
So I think we need to report this there (if no one has done that yet).
from bfchroma.
Oh, actually, in their README, there's this:
With package management you should import github.com/russross/blackfriday and specify that you're using version 2.0.0.
So, indeed, you should change your go.mod
file to require Blackfriday like this:
require github.com/russross/blackfriday v2.0.0+incompatible
Can you give that a go?
from bfchroma.
Sorry to spam you :)
But the latest version is specified like this instead:
require github.com/russross/blackfriday/v2 v2.0.1
Add this to go.mod
then do go get -u
so it will automagically update your deps.
from bfchroma.
I'll give that a try as soon as I can ! Thanks 👍
from bfchroma.
Well I'm still confused about all this. Does this mean I should use directly github.com/russross/blackfriday
in my source files ? In that case the lib won't be go-gettable anymore. Or it will be but only with gomodules activated. For those that didn't activate the option, it will fail.
What I can do, is keep using the gopkg.in
version, but change the go.mod
file like this:
require (
gopkg.in/russross/blackfriday.v2 v2.0.1
...
)
replace gopkg.in/russross/blackfriday.v2 v2.0.1 => github.com/russross/blackfriday/v2 v2.0.1
Think that would work ?
from bfchroma.
Yeah, I think this would work... just try it locally and see.
This whole Go modules thing seems to be a little bit messy at the moment... hopefully soon things will become clearer and these hacks won't be necessary anymore.
from bfchroma.
I had a discussion on the Gopher slack. It seems the issue is the way blackfriday is handling that. I shouldn't import the gopkg version, but rather github.com/russross/blackfriday/v2
which is the go module way of telling to use the v2. But that would lock out people that are not using go modules yet.
So for now I'll keep it that way. When go modules will be the default behavior for go dependencies I'll update the lib accordingly. But indeed, it's complicated, especially when you're depending on a lib that used gopkg.in before...
from bfchroma.
Cool, thanks for the update.
from bfchroma.
I am meeting the same issue and still cannot figure out what I need to do to use blackfriday and bfchroma together with Go modules. With the above suggestion, I get this error:
markdown/markdown.go:44:48: cannot use bfchroma.NewRenderer() (type *bfchroma.Renderer) as type "github.com/russross/blackfriday".Renderer in argument to "github.com/russross/blackfriday".WithRenderer:
*bfchroma.Renderer does not implement "github.com/russross/blackfriday".Renderer (wrong type for RenderFooter method)
have RenderFooter(io.Writer, *"gopkg.in/russross/blackfriday.v2".Node)
want RenderFooter(io.Writer, *"github.com/russross/blackfriday".Node)
from bfchroma.
Which suggestion are you talking about ?
For now the recommended way is to stick with the gopkg.in
version of blackfriday. Do you need the non-gopkg.in version for some reason ?
from bfchroma.
I tried #4 (comment)
When using gopkg.in/russross/blackfriday.v2 v2.0.1
in go.mod, I get
go: gopkg.in/russross/[email protected]: go.mod has non-....v2 module path "github.com/russross/blackfriday/v2" at revision v2.0.1
go: error loading module requirements
Could you give an example of a go.mod that is expected to work?
from bfchroma.
module github.com/Depado/testbfchroma3
require (
github.com/Depado/bfchroma v1.1.1
gopkg.in/russross/blackfriday.v2 v2.0.0
)
I'll need to see what they did in the v2.0.1
that breaks the package. Sadly I can't seem to make it work.
I'll have a closer look tomorrow and try to fix that so it works better. This will probably be a breaking change and prevent people from using the latest releases of bfchroma.
EDIT:
I just gave it another try and using the replace
statement as shown in this issue, it works:
module github.com/Depado/testbfchroma3
require (
github.com/Depado/bfchroma v1.1.1
gopkg.in/russross/blackfriday.v2 v2.0.1
)
replace gopkg.in/russross/blackfriday.v2 v2.0.1 => github.com/russross/blackfriday/v2 v2.0.1
↪ cat go.mod
module github.com/Depado/testbfchroma3
require (
github.com/Depado/bfchroma v1.1.1
gopkg.in/russross/blackfriday.v2 v2.0.1
)
replace gopkg.in/russross/blackfriday.v2 v2.0.1 => github.com/russross/blackfriday/v2 v2.0.1
↪ go get -u
go: finding github.com/alecthomas/colour latest
go: finding github.com/danwakefield/fnmatch latest
go: finding github.com/alecthomas/repr latest
go: finding github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897
go: finding github.com/stretchr/objx v0.1.0
go: finding github.com/alecthomas/kong v0.1.15
go: finding golang.org/x/sys latest
go: finding github.com/alecthomas/assert latest
go: downloading github.com/alecthomas/chroma v0.6.2
go: downloading github.com/shurcooL/sanitized_anchor_name v1.0.0
↪ go build
↪ ./testbfchroma3
<h1>Title</h1>
<pre style="color:#f8f8f2;background-color:#272822">## Subtitle
</pre>
from bfchroma.
module github.com/Depado/testbfchroma3 require ( github.com/Depado/bfchroma v1.1.1 gopkg.in/russross/blackfriday.v2 v2.0.0 )
If I do this I get
go: finding golang.org/x/net latest
go: finding golang.org/x/tools latest
go: finding gopkg.in/check.v1 latest
go: gopkg.in/russross/[email protected]: go.mod has non-....v2 module path "github.com/russross/blackfriday/v2" at revision v2.0.1
go get: error loading module requirements
module github.com/Depado/testbfchroma3 require ( github.com/Depado/bfchroma v1.1.1 gopkg.in/russross/blackfriday.v2 v2.0.1 ) replace gopkg.in/russross/blackfriday.v2 v2.0.1 => github.com/russross/blackfriday/v2 v2.0.1
If I do this, I get
go: finding golang.org/x/tools latest
go: finding golang.org/x/net latest
go: finding gopkg.in/check.v1 latest
go: downloading golang.org/x/net v0.0.0-20190110044637-be1c187aa6c6
# github.com/sourcegraph/docsite/markdown
markdown/markdown.go:44:48: cannot use bfchroma.NewRenderer() (type *bfchroma.Renderer) as type "github.com/russross/blackfriday".Renderer in argument to "github.com/russross/blackfriday".WithRenderer:
*bfchroma.Renderer does not implement "github.com/russross/blackfriday".Renderer (wrong type for RenderFooter method)
have RenderFooter(io.Writer, *"gopkg.in/russross/blackfriday.v2".Node)
want RenderFooter(io.Writer, *"github.com/russross/blackfriday".Node)
Also, my go.mod changes back to automatically include github.com/russross/blackfriday v2.0.0+incompatible
from bfchroma.
Maybe it is because I still have imports to github.com/russross/blackfriday
. How would my import
statement have to look like?
from bfchroma.
I changed my imports to
"gopkg.in/russross/blackfriday.v2"
but now I get
> go get -u
go: finding github.com/alecthomas/repr latest
go: finding golang.org/x/net latest
go: finding github.com/danwakefield/fnmatch latest
go: finding golang.org/x/sys latest
go: finding github.com/alecthomas/colour latest
go: finding gopkg.in/check.v1 latest
go: finding golang.org/x/tools latest
go: finding github.com/alecthomas/assert latest
go build gopkg.in/russross/blackfriday: no Go files in
from bfchroma.
Here are the files I'm testing with:
go.mod
module github.com/Depado/testbfchroma3
require (
github.com/Depado/bfchroma v1.1.1
gopkg.in/russross/blackfriday.v2 v2.0.1
)
replace gopkg.in/russross/blackfriday.v2 v2.0.1 => github.com/russross/blackfriday/v2 v2.0.1
main.go
package main
import (
"fmt"
"github.com/Depado/bfchroma"
"gopkg.in/russross/blackfriday.v2"
)
func main() {
md := `# Title`
html := blackfriday.Run([]byte(md), blackfriday.WithRenderer(bfchroma.NewRenderer()))
fmt.Println(string(html))
}
$ ls
go.mod main.go
$ go get -u
go: finding github.com/alecthomas/colour latest
go: finding github.com/alecthomas/assert latest
go: finding github.com/alecthomas/repr latest
go: finding golang.org/x/sys latest
go: finding github.com/danwakefield/fnmatch latest
$ go build
$ go run main.go
<h1>Title</h1>
Maybe you could also run go mod tidy
to make sure you're not importing/using the github version but the gopkg.in version of blackfriday ?
Otherwise I can't see how I can help unfortunately :(
from bfchroma.
I finally got it working with that, thanks a lot! This may be good to add to the readme or commit as an example
from bfchroma.
I'm waiting for the modules thing to stabilize and be more broadly used to completely switch.
Ideally I shouldn't use the gopkg
version at all.
from bfchroma.
Related Issues (10)
- Couple comments from Blackfriday HOT 5
- couldn't support utf-8 code. Chinese font. HOT 2
- gopkg.in -> go/dep, however vendor dir hasn't been checked in HOT 7
- Underterministic output HOT 6
- Not detecting yaml in v1.1.1? HOT 3
- error using go mod HOT 4
- required package does not exist HOT 6
- Upgrade to chroma v2 HOT 2
- Dependency Dashboard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bfchroma.