-
Notifications
You must be signed in to change notification settings - Fork 333
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
Make BaseNode init accessible outside the Down module #197
Make BaseNode init accessible outside the Down module #197
Conversation
…tside the framework
Codecov Report
@@ Coverage Diff @@
## master #197 +/- ##
=======================================
Coverage 32.59% 32.59%
=======================================
Files 74 74
Lines 2362 2362
=======================================
Hits 770 770
Misses 1592 1592
Continue to review full report at Codecov.
|
Hi @daikini , thanks for the pull request. Could you elaborate on what problem this change solves? |
Hi @johnxnguyen, I'm writing a new This PR fixes this issue by making the Without this PR it is not possible to build new renderers for |
@daikini That's fair; as API design goes, it's always good to be careful about opening internal APIs up for use, but at the same time we should encourage custom renderers so the community can build their own use-case-specific tooling Thanks for the extra detail 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as @johnxnguyen approves (versus an alternative approach), this seems reasonable to me
Glad to hear you’re making a custom renderer! I’m a bit hesitant to open the access of the initializer, because the node classes were never intended to be invoked outside of the framework. The reason being is because the CMarkNode is just a pointer to a C struct, and initializing a particular node class with the wrong pointer could lead to unexpected behavior. To create the correct node class from a given CMarkNode instance, there is a handy extension method on CMarkNode called You could for instance do something like: let down = Down(markdownString: “...”)
let document = try? down.toAST().wrap() as? Document
... If this approach is too inconvenient, I would suggest to create a helper method or add a renderer that returns the Document node (just like the AST renderer returns the CMarkNode), instead of opening access for every |
@johnxnguyen, didn't know about the |
This pull request adds the public designator to the BaseNode.init initializer so that it can be called outside the Down module.
Fixes #196