Skip to content

generic Renderer for render targets richer than String #364

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.commonmark.node.Node;

public interface Renderer {
public interface Renderer<T> {

/**
* Render the tree of nodes to output.
Expand All @@ -16,7 +16,7 @@ public interface Renderer {
* Render the tree of nodes to string.
*
* @param node the root node
* @return the rendered string
* @return the rendered result
*/
String render(Node node);
T render(Node node);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* renderer.render(node);
* </code></pre>
*/
public class HtmlRenderer implements Renderer {
public class HtmlRenderer implements Renderer<String> {

private final String softbreak;
private final boolean escapeHtml;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* However, it should produce Markdown that is semantically equivalent to the input, i.e. if the Markdown was parsed
* again and compared against the original AST, it should be the same (minus bugs).
*/
public class MarkdownRenderer implements Renderer {
public class MarkdownRenderer implements Renderer<String> {

private final List<MarkdownNodeRendererFactory> nodeRendererFactories;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* Renders nodes to plain text content with minimal markup-like additions.
*/
public class TextContentRenderer implements Renderer {
public class TextContentRenderer implements Renderer<String> {

private final LineBreakRendering lineBreakRendering;

Expand Down