This commit is contained in:
yuin 2019-11-11 03:59:36 +09:00
parent 16b69522a4
commit ea8789f650
2 changed files with 6 additions and 5 deletions

View file

@ -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>
@ -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>
//= = = = = = = = = = = = = = = = = = = = = = = =//

View file

@ -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)
}