Skip to content

Make HTML rendering for nodes extensible (#35)#49

Merged
robinst merged 3 commits into
masterfrom
issue-35-extensible-node-rendering
Apr 13, 2016
Merged

Make HTML rendering for nodes extensible (#35)#49
robinst merged 3 commits into
masterfrom
issue-35-extensible-node-rendering

Conversation

@robinst

@robinst robinst commented Apr 8, 2016

Copy link
Copy Markdown
Collaborator

We had CustomHtmlRenderer for custom nodes before. That was ok for
that, but didn't allow clients to override rendering for core nodes.

This introduces a new concept NodeRenderer (including factories, who
doesn't like those?) that is also used for the core nodes. That allows
overriding the rendering and allows to define the rendering for custom
nodes at the same time.

NodeRenderers have access to rendering configuration and functionality,
such as extending attributes. That fixes the problem that the renderer
for table nodes wasn't extensible via AttributeProvider (#31).

robinst added 3 commits April 8, 2016 15:42
We had `CustomHtmlRenderer` for custom nodes before. That was ok for
that, but didn't allow clients to override rendering for core nodes.

This introduces a new concept `NodeRenderer` (including factories, who
doesn't like those?) that is also used for the core nodes. That allows
overriding the rendering and allows to define the rendering for custom
nodes at the same time.

NodeRenderers have access to rendering configuration and functionality,
such as extending attributes. That fixes the problem that the renderer
for table nodes wasn't extensible via `AttributeProvider` (#31).
Now that there's an extra level of indirection, the stack requirements
are higher. The test was failing on Java 7 but not on 8 because its
default stack size is smaller.
* @param nodeRendererFactory the factory for creating a node renderer
* @return {@code this}
*/
public Builder nodeRendererFactory(NodeRendererFactory nodeRendererFactory) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is the new extension point. See also NodeRenderer and associated interfaces.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks great! Overriding is simple and intuitive.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Cool, thanks for reviewing!

@koesie10

Copy link
Copy Markdown

Could a new version be released with this change included?

@robinst robinst deleted the issue-35-extensible-node-rendering branch April 22, 2016 13:53
@robinst

robinst commented Apr 22, 2016

Copy link
Copy Markdown
Collaborator Author

@koesie10 I released 0.5.0 today with these and other changes included, see release notes: https://github.com/atlassian/commonmark-java/releases/tag/commonmark-parent-0.5.0

@koesie10

Copy link
Copy Markdown

Great, thanks!

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.

3 participants