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

Add support for rendering XML from cmark-gfm #144

Merged
merged 3 commits into from
Aug 30, 2021

Conversation

digitalmoksha
Copy link
Contributor

@digitalmoksha digitalmoksha commented Aug 26, 2021

cmark-gfm supports rending to the XML format and exports the correct functions. So I've added support to the Node class so you can now do doc.to_xml.

Also added support for a new command line option, —to=FORMAT (which mirrors the option in cmark-gfm) that allows you to specify the output format. Since to_plaintext and to_commonmark were already supported internally, possible output formats is html, xml, plaintext, and CommonMark. For example commonmarker --to=xml

Currently man and latex are not supported output formats.

`cmark-gfm` supports rending to the XML format and exports the
correct functions.  Added support to the `Node` class so you can
now do `doc.to_xml`.

Also added support for a new command line option, `—to=FORMAT`
that allows you to specify `html` or `xml` as the output format
Command line arguments `--to=commonmark` and
`--to=plaintext` are now supported
@digitalmoksha
Copy link
Contributor Author

@gjtorikian I think this is ready for your consideration if you have time.

The reason I added this is that we would like to be able to output as XML, particularly since that's currently the only format that supports inline source mapping.

Copy link
Collaborator

@kivikakk kivikakk left a comment

Choose a reason for hiding this comment

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

I've given this a once-over and it looks fine to me 👍 I am very tired, though, so will wait for Garen to give the final OK.

@gjtorikian
Copy link
Owner

I think this looks great. Thank you for your contribution.

I tend to lean extra hard on the side of caution/paranoia when working with FFI. Could you add a few more "malicious" test cases, such as:

  • Calling with a format that doesn't exist (e.g. make_bin('strong.md', '--to=foofoo')
  • Calling --to=html with and without --renderer
  • Calling --to=xml on a text with double quotes in it (")

Those are a few I can think of off the top of my head. Obviously it looks like the code would be able to handle such situations but better safe than sorry! At least the first one, in any event, should be test.

The README should also be updated, probably a quick blurb under the OPTIONS header to let people know.

and add additional specs.
@digitalmoksha
Copy link
Contributor Author

Thanks @gjtorikian and @kivikakk for taking a look!

I've added some additional specs, and made unrecognized formats abort like the other options.

I also took a stab at updating the README.

@gjtorikian
Copy link
Owner

Nice nice nice. Thank you!

@gjtorikian gjtorikian merged commit 608e42c into gjtorikian:main Aug 30, 2021
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