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

refactor(parser): simplified grammar rules for attributes #804

Merged

Conversation

xcoulon
Copy link
Member

@xcoulon xcoulon commented Dec 12, 2020

Process the attributes in a more generic way: positional values
are retained until the block is initialized, in which case they
are process accordingly, by mapping the position to an expected
attribute name.

Overall, the grammar for block and inline attributes is much simpler,
which means that adding support for new elements will require
less effort.

Also:

  • no need to the AdmonitionKind and BlockKind types, whose
    constant values are all string now and stored in the style key.
  • for inline attributes, spaces after the opening square bracket ([)
    are not tolerated (this was already the case for block attributes). This
    allows for a better consistency and simpler grammar rules.

BREAKING CHANGE: for images and links, positional attributes are delimited
with commas, so if a link text should contain such a comma, it is necessary
that the text be wrapped in single or double quotes. This makes the syntax
(and thus, the parsing) consistent between block attributes and inline
attributes.
Eg: link:http://example.com["a description, with comma"]

BREAKING CHANGE: inline attributes content must not start with spaces, as
it is the case with block attributes.
Eg: image::cookie.png[ cookie ] is not valid.

Fixes #750

Signed-off-by: Xavier Coulon [email protected]

Process the attributes in a more generic way: positional values
are retained until the block is initialized, in which case they
are process accordingly, by mapping the position to an expected
attribute name.

Overall, the grammar for block and inline attributes is much simpler,
which means that adding support for new elements will require
less effort.

Also:
- no need to the `AdmonitionKind` and `BlockKind` types, whose
constant values are all `string` now and stored in the `style` key.
- for inline attributes, spaces after the opening square bracket (`[`)
are not tolerated (this was already the case for block attributes). This
allows for a better consistency and simpler grammar rules.

BREAKING CHANGE: for images and links, positional attributes are delimited
with commas, so if a link text should contain such a comma, it is necessary
that the text be wrapped in single or double quotes. This makes the syntax
(and thus, the parsing) consistent between block attributes and inline
attributes.
Eg: `link:http://example.com["a description, with comma"]`

BREAKING CHANGE: inline attributes content must not start with spaces, as
it is the case with block attributes.
Eg: `image::cookie.png[ cookie ]` is not valid.

Fixes bytesparadise#750

Signed-off-by: Xavier Coulon <[email protected]>
@xcoulon xcoulon force-pushed the Issue750_refactor_attribute_grammar_rules branch from babd9c2 to 817bdf3 Compare December 12, 2020 16:47
@codecov
Copy link

codecov bot commented Dec 12, 2020

Codecov Report

Merging #804 (5b6019f) into master (af509d0) will decrease coverage by 2.48%.
The diff coverage is 75.36%.

@@            Coverage Diff             @@
##           master     #804      +/-   ##
==========================================
- Coverage   81.92%   79.43%   -2.49%     
==========================================
  Files          86       87       +1     
  Lines        5144     5275     +131     
==========================================
- Hits         4214     4190      -24     
- Misses        581      750     +169     
+ Partials      349      335      -14     

Signed-off-by: Xavier Coulon <[email protected]>
@xcoulon xcoulon merged commit 1a08657 into bytesparadise:master Dec 16, 2020
@xcoulon xcoulon deleted the Issue750_refactor_attribute_grammar_rules branch December 16, 2020 20:56
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.

Refactor ElementRole type
1 participant