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

Create custom normalizer? #1

Closed
icco opened this issue Feb 14, 2021 · 3 comments
Closed

Create custom normalizer? #1

icco opened this issue Feb 14, 2021 · 3 comments

Comments

@icco
Copy link

icco commented Feb 14, 2021

Hi! This is great. I'm wondering how I pass in a custom normalizer though.

@13rac1
Copy link
Owner

13rac1 commented Feb 16, 2021

Thanks!

use WithNormalizer()

// WithNormalizer is the fluent interface for replacing the default normalizer plugin.
func (p *Parser) WithNormalizer(fn FilenameNormalizer) *Parser {
p.normalizer = fn
return p
}

@13rac1 13rac1 closed this as completed Feb 16, 2021
@icco
Copy link
Author

icco commented Feb 17, 2021 via email

@13rac1
Copy link
Owner

13rac1 commented Feb 20, 2021

Create a struct implementing the FilenameNormalizer interface and pass it to WithNormalizer()

// FilenameNormalizer is a plugin which takes link text and converts the text given to
// a filename which can be linked to in the final format of your file.
type FilenameNormalizer interface {
Normalize(linkText string) string
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants