Skip to content

Commit

Permalink
fix: handle boolean attributes (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz authored Jun 10, 2021
1 parent 13bf9fa commit e778d86
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit e778d86

Please sign in to comment.