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

allow extensions to use ! and ^ as special characters #30

Merged
merged 3 commits into from
Mar 16, 2022

Conversation

QuietMisdreavus
Copy link

While implementing updates for #28, and while verifying changes for #29, i noticed that some special characters weren't being handled properly, and couldn't be used by extensions. This updates the parse_inline function to allow ^ and ! to be used as special characters by extensions. This also allows footnotes to work with our implementation of inline attributes, allowing the full test suite to pass.

@QuietMisdreavus
Copy link
Author

I split off a change from #28 into this branch so that make test could pass with the swift-cmark-gfm changes.

@QuietMisdreavus
Copy link
Author

I've rebased this PR atop the new updates in #29.

}
break;
default:

Choose a reason for hiding this comment

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

What happenned to the default case? Did you just push it outside the switch?

Copy link
Author

Choose a reason for hiding this comment

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

Yes. I had to move the try_extensions call outside of this switch, so that it could be tried with characters that are part of the built-in grammar (specifically ^ and [). That's also why i modified the ! and ^ branches to peek for their syntax instead of eagerly advancing the pointer.

@QuietMisdreavus QuietMisdreavus force-pushed the QuietMisdreavus/extended-ext branch from 46bda92 to 05a5f22 Compare March 11, 2022 16:47
@@ -1563,43 +1564,49 @@ static int parse_inline(cmark_parser *parser, subject *subj, cmark_node *parent,
new_inl = handle_close_bracket(parser, subj);
break;
case '!':
advance(subj);
if (peek_char(subj) == '[' && peek_char_n(subj, 1) != '^') {
if (peek_char_n(subj, 1) == '[' && peek_char_n(subj, 2) != '^') {

Choose a reason for hiding this comment

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

Maybe add a comment saying that this case is not effectively "![(!^)"

Copy link

@daniel-grumberg daniel-grumberg left a comment

Choose a reason for hiding this comment

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

LGTM after offline discussion

Base automatically changed from QuietMisdreavus/sync-upstream to gfm March 16, 2022 18:50
QuietMisdreavus and others added 3 commits March 16, 2022 12:57
- generalize the special-character-inline-creating section
- add comments about looking for images and attributes specificall
@QuietMisdreavus QuietMisdreavus force-pushed the QuietMisdreavus/extended-ext branch from d9b0520 to 76ae837 Compare March 16, 2022 18:58
@QuietMisdreavus QuietMisdreavus merged commit c816eae into gfm Mar 16, 2022
@QuietMisdreavus QuietMisdreavus deleted the QuietMisdreavus/extended-ext branch March 16, 2022 18:59
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