Skip to content

Commit

Permalink
Fixed #27
Browse files Browse the repository at this point in the history
  • Loading branch information
yuin committed Nov 10, 2019
1 parent 16b6952 commit ea8789f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 3 additions & 0 deletions _test/options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
## Title6 ## {#id_6 .class6 attr6=value6}

## Title7 ## {#id_7 attr7="value \"7"}

## Title8 {#id .className attrName=attrValue class="class1 class2"}
//- - - - - - - - -//
<h2 id="title-0">Title 0</h2>
<h2 id="id_1" class="class-1">Title1</h2>
Expand All @@ -24,4 +26,5 @@
<h2 id="id_5" attr5="value5">Title5</h2>
<h2 id="id_6" class="class6" attr6="value6">Title6</h2>
<h2 id="id_7" attr7="value &quot;7">Title7</h2>
<h2 id="id" class="className class1 class2" attrName="attrValue">Title8</h2>
//= = = = = = = = = = = = = = = = = = = = = = = =//
8 changes: 3 additions & 5 deletions parser/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ func ParseAttributes(reader text.Reader) (Attributes, bool) {
}
if bytes.Equal(attr.Name, attrNameClass) {
if !attrs.findUpdate(attrNameClass, func(v interface{}) interface{} {
var ret interface{}
if ret, ok = v.([][]byte); !ok {
ret = [][]byte{v.([]byte)}
}
return append(ret.([][]byte), attr.Value.([]byte))
ret := make([]byte, 0, len(v.([]byte))+1+len(attr.Value.([]byte)))
ret = append(ret, v.([]byte)...)
return append(append(ret, ' '), attr.Value.([]byte)...)
}) {
attrs = append(attrs, attr)
}
Expand Down

0 comments on commit ea8789f

Please sign in to comment.