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

Update markdownfmt to use blackfriday v2 #40

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jsternberg
Copy link

Fixes #39.

There is no implementation for the interface yet and the code does not
compile.
return blackfriday.GoToNext
}

func (_ *markdownRenderer) RenderHeader(w io.Writer, ast *blackfriday.Node) {}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

golint: receiver name should not be an underscore, omit the name if it is unused

}

func (_ *markdownRenderer) RenderHeader(w io.Writer, ast *blackfriday.Node) {}
func (_ *markdownRenderer) RenderFooter(w io.Writer, ast *blackfriday.Node) {}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

golint: receiver name should not be an underscore, omit the name if it is unused

out.WriteByte('\n')
}
func (_ *markdownRenderer) TitleBlock(out *bytes.Buffer, text []byte) {
func (_ *markdownRenderer) BlockHtml(w io.Writer, text []byte) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

golint: receiver name should not be an underscore, omit the name if it is unused

out.WriteByte('\n')
}
func (_ *markdownRenderer) TitleBlock(out *bytes.Buffer, text []byte) {
func (_ *markdownRenderer) BlockHtml(w io.Writer, text []byte) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

golint: method BlockHtml should be BlockHTML

w.Write([]byte{'\n'})
}
return blackfriday.GoToNext
} else {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

golint: if block ends with a return statement, so drop this else and outdent its block

func (_ *markdownRenderer) HRule(out *bytes.Buffer) {
doubleSpace(out)
out.WriteString("---\n")
func (_ *markdownRenderer) HRule(w io.Writer) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

golint: receiver name should not be an underscore, omit the name if it is unused

}
}
func (_ *markdownRenderer) Emphasis(out *bytes.Buffer, text []byte) {
if len(text) == 0 {
func (_ *markdownRenderer) Image(w io.Writer, link []byte, title []byte, entering bool) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

golint: receiver name should not be an underscore, omit the name if it is unused

markdown/main.go Outdated
@@ -504,3 +577,45 @@ func readSource(filename string, src []byte) ([]byte, error) {
}
return ioutil.ReadFile(filename)
}

type Buffer struct {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

golint: exported type Buffer should have comment or be unexported

"io"
)

type prefixWriter struct {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused: type prefixWriter is unused (U1000)

}

// newPrefixWriter creates a new prefix writer that prefixes every line with a prefix.
func newPrefixWriter(w io.Writer, prefix []byte) io.Writer {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused: func newPrefixWriter is unused (U1000)

@jsternberg jsternberg force-pushed the blackfriday-v2 branch 2 times, most recently from e34db2a to 61ba6ee Compare February 18, 2018 03:20
This passes the original tests for markdownfmt so it should produce the
same output as the original markdownfmt.
@dmitshur
Copy link
Member

dmitshur commented Mar 2, 2018

Thank you for sending this @jsternberg. I did not forget about this, but it will likely take me a bit of time before I can get to reviewing and merging this. I hope that's okay.

A part of the complication for me is that I'll likely want to sync the upgrade to blackfriday v2 for my other package github_flavored_markdown, so they both use blackfriday v2 at the same time.

The reason for that is because I use both of them in frontend code, and having one import blackfriday v1 while the other v2 would mean my frontend code size would increase.

An alternative I will consider is to have two versions of markdownfmt, one that continues to use blackfriday v1, and another that uses blackfriday v2.

@jsternberg
Copy link
Author

👍 for anyone who needs the library form for their own code like I do, they can just use my fork.

@dmitshur dmitshur mentioned this pull request Nov 3, 2019
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

Successfully merging this pull request may close these issues.

None yet

2 participants