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

Feature/create d2 diagrams extension #589

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Anakin100100
Copy link

Work in progress

@Anakin100100
Copy link
Author

Anakin100100 commented Aug 27, 2023

@vsch I'm working on adding the support for d2 diagrams and am able to parse the ast correctly (D2Node should be 0 to 23, I'm going to fix it later)

Document[0, 23]
  D2Block[0, 23]
    D2Node[20, 23]

and this should render
<p>rendering d2 node</p> but the render method of the D2NodeRenderer is not called even though the D2Node rendering is associated with the render method of the renderer.

public class D2NodeRenderer implements NodeRenderer {
    public D2NodeRenderer(DataHolder options) {

    }

    @Override
    public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {
        HashSet<NodeRenderingHandler<?>> set = new HashSet<>();
        set.add(new NodeRenderingHandler<>(D2Node.class, this::render));
        return set;
    }

    private void render(D2Node node, NodeRendererContext context, HtmlWriter html) {
        html.tag("p");
        html.text("rendering d2 node");
        html.tag("/p");
    }

    public static class Factory implements NodeRendererFactory {
        @NotNull
        @Override
        public NodeRenderer apply(@NotNull DataHolder options) {
            return new D2NodeRenderer(options);
        }
    }
}

I'm a bit at a loss here because the method is not called and I don't see any relevant differences between the examples and other extensions and this one. Do you see what could be a cause of this issue?

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

1 participant