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 exposing list markers *, -, +, or numeric to AST and API. #226

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nathanaschbacher
Copy link

Prior to this commit the node struct for a list contained a member to
store whatever char was parsed from the markdown, but this value
wasn't exposed through the API, nor was it made available in the
output of the AST in any format.

Following this commit a cmark_marker_type struct has been added to
capture various forms of list markers: CMARK_NUMERIC_MARKER (for
ordered lists) and CMARK_ASTERISK_MARKER, CMARK_HYPHEN_MARKER, &
CMARK_PLUS_MARKER (for unordered lists). The value of which is
stored in the marker member of the cmark_list node struct.

This enables two primary features:

  1. The bullet marker types are now preserved when converting from
    markdown to markdown.
  2. The XML representation of the AST now has a marker="hyphen" (as
    well as numeric, asterisk, and plus) as an attribute on the list
    nodes. This is similar to the delim="period" attribute available on
    ordered list nodes.

Tests have been added and are passing. The original test suite still
passes as well. This commit also updates the racket-lang wrapper to
support these new features as well as fixes a minor bug for a missing
no_delim symbol because NO_DELIM wasn't defined in cmark.h

If you'd like to see examples of the different results of running this through the updated cmark executable, then take a look at this Gist: https://gist.github.com/nathanaschbacher/93f45e938aef671a07e8c9f8850115cf

Finally, this should close issue #225 that I opened earlier today.

Cheers!

Prior to this commit the node struct for a list contained a member to
store whatever char was parsed from the markdown, but this value
wasn't exposed through the API, nor was it made available in the
output of the AST in any format.

Following this commit a `cmark_marker_type` struct has been added to
capture various forms of list markers: `CMARK_NUMERIC_MARKER` (for
ordered lists) and `CMARK_ASTERISK_MARKER`, `CMARK_HYPHEN_MARKER`, &
`CMARK_PLUS_MARKER` (for unordered lists). The value of which is
stored in the `marker` member of the `cmark_list` node struct.

This enables two primary features:

1. The bullet marker types are now preserved when converting from
markdown to markdown.
2. The XML representation of the AST now has a `marker="hyphen"` (as
well as numeric, asterisk, and plus) as an attribute on the list
nodes. This is similar to the `delim="period"` attribute available on
ordered list nodes.

Tests have been added and are passing. The original test suite still
passes as well. This commit also updates the racket-lang wrapper to
support these new features as well as fixes a minor bug for a missing
`no_delim` symbol because `NO_DELIM` wasn't defined in cmark.h
@nathanaschbacher
Copy link
Author

nathanaschbacher commented Aug 9, 2017

I also have a similar branch that doesn't create the concept of a "marker" and instead just overloads the "deliminator" concept to include asterisk, hyphen, and plus if that's preferable.

Likewise for a version that doesn't bother to convert to a term and just keeps the syntax, like marker="*" instead of marker="asterisk", or marker="2" instead of marker="numeric", but that seemed to break with the convention used by cmark already.

@gjtorikian
Copy link

Could there be a review/consideration for this?

QuietMisdreavus pushed a commit to swiftlang/swift-cmark that referenced this pull request Dec 29, 2021
Move CI build over to Actions, per `@jgm`'s upstream work.
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.

2 participants