-
Notifications
You must be signed in to change notification settings - Fork 21
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
Improvements, extensions and some fixes #11
Conversation
- Expose class Renderer (opaque, for now) - Expose factory function htmlRenderer(flags), which creates and returns a standard html Renderer. - Rename toHtml and toHtmlSync to markdown(...) and markdownSync(...), because now they take a generic Renderer as argument. - Output buffer is passed in directly. - Use delete instead of free(...). - Use finally to make sure the buffers are deallocated, no matter what happens. - Some formatting.
- mkd_renderer is now wrapped - stdHtmlRenderer now has its own HtmlRenderer class - add try {} catch {} in markdown() to avoid crashes - use ObjectWrapper::Unwrap to obtain pointers - markdown() now checks that arguments have the correct types - implemented markdownSync()
First of all thank you for the thorough pull request! I've looked over most of the changes and they look great. The only small question I have is about the bumped version number (https://github.com/jmendeth/robotskirt/commit/57db8263742b92439a5aa981d46de85661ff07d7) it seems like if we want to make a major version bump we should change the version number to 1.0.0 What do you think about that? |
Yes, you're right. Ok, I'll reset it to |
If you gentlemen allow me to chime in: I think providing a compatibility The speed bump of reusing a renderer is relevant, but a point can be made for compatibility and simplicity of the API. Just my 2 cents. |
I like @edufelipe suggestion. What do you think @jmendeth ? |
Yes, that would be great! However, migrating older code to |
@jmendeth Yes, I do agree that it is very easy, but I rather have a clean API where an easy thing that needs to be done – before I accomplish what I set out to do – is automatically done for me. |
I agree with @edufelipe that a backwards compatiable API is very important. How would you both feel if I pulled in this code and make a second commit with the added code to support |
@edufelipe @benmills Ok, thanks. |
@jmendeth I always go back and forth on that. On one hand since we're not breaking the API we shouldn't do a major version bump. However we're adding quite a bit of new functionality and its pre-1.0 so I would think this seems like a good place to go 1.0. I'm leaning towards going 1.0. |
@benmills OK, you lead the way! :) |
Improvements, extensions and some fixes
@jmendeth @edufelipe I was thinking more about the API before I publish robotskirt on npm. I'm a little worried about a method named var rs = require('robotskirt');
var renderer = new rs.HtmlRenderer();
var markdownString = "# hello world";
rs.renderMarkdown(renderer, markdownString, function (html) {
//...
});
var html = rs.renderMarkdown(renderer, markdownString); |
Well, I just noticed the Sundown version of Robotskirt is very outdated! I'm working on it... |
Yes I actually took a look at upgrading and just getting robotskirt working but it was not straight forward. I think I'm going to go with the API that looks like this going forward: For raw markdown parsing use
For HTML or any other specific format we will provide a method that looks like
I'm busy this weekend but I'll try to get 1.0.0 out with your original pull request and the minor API change tagged and on npm early next week. |
Great work with Robotskirt, let's make it more complete!
And it's now even faster (it allows Renderer to be used multiple times)!
See the benchmark.
New features
Renderer
has been created which wraps amkd_renderer
.HtmlRenderer
(which inherits from the above) wraps the standard (X)HTML renderer bundled with Sundown.toHtml
andtoHtmlSync
) now require aRenderer
as first argument.Thus, they've been renamed to
markdown
andmarkdownSync
.null
).EXT_AUTOLINK
EXT_FENCED_CODE
EXT_LAX_HTML_BLOCKS
EXT_TABLES
EXT_NO_INTRA_EMPHASIS
EXT_SPACE_HEADERS
EXT_STRIKETHROUGH
Other optimizations
NODE_MODULE
macro.Buffer
instead of copying its contents.mkd_renderer
is always deleted, no matter what happens.1.0.0
.