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

cmark extensions #28

Merged
merged 22 commits into from
Sep 18, 2016
Merged

cmark extensions #28

merged 22 commits into from
Sep 18, 2016

Conversation

kivikakk
Copy link
Collaborator

@kivikakk kivikakk commented Sep 13, 2016

This is not yet ready for merge, but I figure opening a PR is an okay idea at this stage.

In short:

Fixes #22.

@gjtorikian
Copy link
Owner

Not sure if you're aware but it's totally fine for the Windows build to fail: #22

I should get on that....one day. 😞

Other than that, this is looking great. The two things that stand out are:

  • obviously, all the XXX should raise comments
  • I prefer to use symbols for immutable strings, so if extensions could be an array of symbols, instead, that'd be great.

I'm not nervous about switching the submodule to your fork. I am nervous about the core CMark stuff getting improvements, that might not trickle down to your fork. For example, I routinely run update_submodule on a new CMark release and just bump the gem: #21

Could/Would you be willing to also incorporate those upstream C changes into your fork, so that I can continue to release new gems with those updates? If not, I'm totally open to any other suggestions or improvements on the workflow here. For example, could any of the C extension code be written directly to this repo, rather than maintained in a separate submodule?

@kivikakk
Copy link
Collaborator Author

Haha, whoops! If I ever get a Windows dev environment going I might look into it.

I could've sworn I had a good reason to use symbols instead of strings — maybe it was because one of the extension names had a hyphen in it. At any rate, I'll change it to use symbols there; will look much better!

I'm super happy to track the upstream cmark and integrate — hopefully it'll only be a matter of time before this code does get merged upstream, so it'll be helpful for me to do this anyway, to make sure it always stays merge-ready. :)

Unfortunately the nature of the changes (adapting cmark to be extensible) means we can't easily separate it yet. I'm hoping the core changes will land, and then we'll be able to keep the extensions proper in this repo if we wanted/needed.

@kivikakk
Copy link
Collaborator Author

Symbols are in, XXX are out, upstream is merged. :)

@kivikakk kivikakk changed the title [WIP] cmark extensions cmark extensions Sep 14, 2016
@kivikakk
Copy link
Collaborator Author

@kivikakk
Copy link
Collaborator Author

Windows is all fixed. Let me know if there's anything else you'd like addressed!

@gjtorikian
Copy link
Owner

😹

- bundle -v

test_script:
- bundle exec rake
Copy link
Owner

Choose a reason for hiding this comment

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

OCD ALERT: can this end in a newline please? 🙏

@@ -15,26 +15,28 @@ module CommonMarker
#
# text - A {String} of text
# option - Either a {Symbol} or {Array of Symbol}s indicating the render options
# extensions - An {Array of String}s indicating the extensions to use
Copy link
Owner

Choose a reason for hiding this comment

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

Should be {Array of Symbol}s.

html.force_encoding('UTF-8')
end

# Public: Parses a Markdown string into a `document` node.
#
# string - {String} to be parsed
# option - A {Symbol} or {Array of Symbol}s indicating the parse options
# extensions - An {Array of String}s indicating the extensions to use
Copy link
Owner

Choose a reason for hiding this comment

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

Should be {Array of Symbol}s.

@@ -17,11 +17,22 @@ def walk(&block)
# Public: Convert the node to an HTML string.
#
# options - A {Symbol} or {Array of Symbol}s indicating the render options
# extensions - An {Array of String}s indicating the extensions to use
Copy link
Owner

Choose a reason for hiding this comment

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

Should be {Array of Symbol}s.

assert_raises(TypeError) { CommonMarker.render_html(@markdown, :default, "nope") }
assert_raises(TypeError) { CommonMarker.render_html(@markdown, :default, ["table"]) }
assert_raises(ArgumentError) { CommonMarker.render_html(@markdown, :default, %i[table bad]) }
end
Copy link
Owner

Choose a reason for hiding this comment

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

Love the error cases--thank you!


none_in_use = CommonMarker.render_html(@markdown, :default, %i[table strikethrough])
refute none_in_use.include?("| a")
refute none_in_use.include?("~~hi~~")
Copy link
Owner

Choose a reason for hiding this comment

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

Could we get some assertions on the expected HTML, for example, <strike>hi</strike> or <td>a</td>? (For these, and the tests above.)

Also, could you demonstrate what happens with something like, asterisks in a table cell? github-markdown does support this at the moment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can do! I had left these out as cmark itself tests the cases, but I think it makes sense to assert they're working properly here too.

@gjtorikian
Copy link
Owner

This is looking goooood! I left a few more comments. Thanks for your patience.

@kivikakk
Copy link
Collaborator Author

Fixed up. And not at all, thanks for your attention! :)

@gjtorikian gjtorikian merged commit 15ba18b into gjtorikian:master Sep 18, 2016
@gjtorikian
Copy link
Owner

Shipping as 0.11.0!

@kivikakk kivikakk deleted the kivikakk/extensions branch September 19, 2016 02:47
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