renderer: add support for extending node renderers #16
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
golibs/goldmark-markdown!16
Loading…
Reference in a new issue
No description provided.
Delete branch "f-extend-node-renderers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi, I added support for extending node renderer similar to goldmark's HTML renderer.
An example usage:
Pull Request Test Coverage Report for Build 7825492430
💛 - Coveralls
@ -126,10 +146,10 @@ func (r *Renderer) renderBlockSeparator(node ast.Node, entering bool) ast.WalkStfunc (r *Renderer) renderAutoLink(node ast.Node, entering bool) ast.WalkStatus {I was starting to worry about the performance of setting up all these renderer function chains. Nice change!
Other than my one requested change this looks good!
@ -128,3 +148,2 @@if entering {r.rc.writer.Write([]byte("<"))r.rc.writer.Write(n.URL(r.rc.source))r.rc.writer.WriteBytes([]byte("<"))The only thing I suggest changing is to add a length check here. Since you're keeping
maxKindup to date in theRegistermethod, I don't think an index out of range issue is likely to come up in practice. If it does happen, it'll result in a panic.The existing version of the code would turn this into a no-op by calling the function returned by
chainRenderers(...)with an empty slice. We can maintain that behavior here by returningast.WalkContinue.