charmbracelet/glamour

Go Modules URI incorrectly parsed as mailto link

picatz opened this issue · 1 comments

picatz commented

Similar to #82, Go modules are incorrectly rendered as mailto links.

Given a module like golang.org/x/net@v0.0.0-20210326060303-6b1517762897, it is rendered as:

golang.org/x/net@v0.0.0-20210326060303-6b1517762897 mailto:golang.org/x/net@v0.0.0-20210326060303-6b1517762897 

It'd be nice if there was an option to disable mailto links for a given regular expression, or all together.

picatz commented

Looking into what it would take to implement this, it looks like mailto: is added here:

glamour/ansi/elements.go

Lines 229 to 231 in ea72398

if n.AutoLinkType == ast.AutoLinkEmail && !strings.HasPrefix(strings.ToLower(u), "mailto:") {
u = "mailto:" + u
}

We can add additional options for the ANSI renderer's context here:

glamour/ansi/renderer.go

Lines 17 to 23 in ea72398

type Options struct {
BaseURL string
WordWrap int
PreserveNewLines bool
ColorProfile termenv.Profile
Styles StyleConfig
}