Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Make it easier to extend ToHtmlSerializer #26

pillingworthz opened this Issue · 2 comments

2 participants


Similar to #21 - toHtmlSerialzer is difficult to subclass and tweak behaviour.

I would like to modify the link URLs before they are written (in my case I want to resolve relative image URLs)

I can do this by overriding toHtmlSerializer but I have to override all of the link methods, some are complicated and I end up having to repeat the base class code (public void visit(final RefLinkNode node) in particular).

Maybe some of the code in this class could be broken down with more overridable template method hooks so subclasses can change the functionality more easily?

public void visit(ExpLinkNode node) {
    if (node.getImage()) {
        printer.print("<img src=\"").printEncoded(modifyUrl(node.getUrl()), this).print("\"  alt=\"").startEncoding(this);

String modifyUrl(String url) {
    // override to modify the url
    return url;

Also some variables like printer as private which make overriding and tweaking the behaviour difficult.


Yes, good point!
Will take care of this with the next release...
Thanks for taking the time to report this!


Excellent - will look forward to it.

@sirthias sirthias closed this in 869b108
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.