Skip to content

feat: handle boolean attributes #404

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

Merged
merged 1 commit into from
Jun 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ const exit = {
directiveContainerLabel: exitContainerLabel,
directiveContainerName: exitName,

directiveContainerAttributeInitializerMarker() {
// If an attribute name follows by `=` it should be treat as string
const attributes = this.getData('directiveAttributes')
attributes[attributes.length - 1][1] = ''
},

directiveLeaf: exitToken,
directiveLeafAttributeClassValue: exitAttributeClassValue,
directiveLeafAttributeIdValue: exitAttributeIdValue,
Expand Down Expand Up @@ -144,7 +150,9 @@ function exitAttributeValue(token: Token) {
function exitAttributeName(token: Token) {
// Attribute names in CommonMark are significantly limited, so character
// references can’t exist.
this.getData('directiveAttributes').push([this.sliceSerialize(token), ''])

// Use `true` as attrubute default value to solve issue of attributes without value (example `:block{attr1 attr2}`)
this.getData('directiveAttributes').push([this.sliceSerialize(token), true])
}

function exitAttributes() {
Expand Down