Skip to content

Commit 040b478

Browse files
committed
Fixes #223
1 parent 38f7fc9 commit 040b478

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

_test/options.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,11 @@
6868
//- - - - - - - - -//
6969
<h1 id="test--class0">Test ## {class=0#.}</h1>
7070
//= = = = = = = = = = = = = = = = = = = = = = = =//
71+
72+
73+
7: short handed ids can contain hyphens ("-"), underscores ("_"), colons (":"), and periods (".")
74+
//- - - - - - - - -//
75+
# Test ## {#id-foo_bar:baz.qux .foobar}
76+
//- - - - - - - - -//
77+
<h1 id="id-foo_bar:baz.qux" class="foobar">Test</h1>
78+
//= = = = = = = = = = = = = = = = = = = = = = = =//

parser/attribute.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ func parseAttribute(reader text.Reader) (Attribute, bool) {
8989
reader.Advance(1)
9090
line, _ := reader.PeekLine()
9191
i := 0
92-
for ; i < len(line) && !util.IsSpace(line[i]) && (!util.IsPunct(line[i]) || line[i] == '_' || line[i] == '-'); i++ {
92+
// HTML5 allows any kind of characters as id, but XHTML restricts characters for id.
93+
// CommonMark is basically defined for XHTML(even though it is legacy).
94+
// So we restrict id characters.
95+
for ; i < len(line) && !util.IsSpace(line[i]) &&
96+
(!util.IsPunct(line[i]) || line[i] == '_' || line[i] == '-' || line[i] == ':' || line[i] == '.'); i++ {
9397
}
9498
name := attrNameClass
9599
if c == '#' {

0 commit comments

Comments
 (0)