on master help sign in
#13, permit . in attribute names
fcf5588Neil Mitchell
CHANGES.txt+1
@@ -1,5 +1,6 @@
1Changelog for Hexml
1Changelog for Hexml
2
2
3+ #13, allow the . character in tags and attributes
30.3.2
40.3.2
4 #10, mark the small fast FFI calls as "unsafe" (up to 10x faster)
5 #10, mark the small fast FFI calls as "unsafe" (up to 10x faster)
50.3.1
60.3.1
cbits/hexml.c+1−1
@@ -233,7 +233,7 @@ static void init_parse_table()
233 for (int i = 0; i < 256; i++)
233 for (int i = 0; i < 256; i++)
234 {
234 {
235 bool name1 = i == ':' || i == '_' || (i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z');
235 bool name1 = i == ':' || i == '_' || (i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z');
236− bool name = name1 || i == '-' || (i >= '0' && i <= '9');
236+ bool name = name1 || i == '-' || i == '.' || (i >= '0' && i <= '9');
237 bool space = i == ' ' || i == '\t' || i == '\r' || i == '\n';
237 bool space = i == ' ' || i == '\t' || i == '\r' || i == '\n';
238 parse_table[i] = (name1 ? tag_name1 : 0) | (name ? tag_name : 0) | (space ? tag_space : 0);
238 parse_table[i] = (name1 ? tag_name1 : 0) | (name ? tag_name : 0) | (space ? tag_space : 0);
239 }
239 }
src/Main.hs+1−1
@@ -74,7 +74,7 @@ rerender = inside
74 "</" <> name x <> ">"
74 "</" <> name x <> ">"
75 attr (Attribute a b) = validName a <> "=\"" <> validAttr b <> "\""
75 attr (Attribute a b) = validName a <> "=\"" <> validAttr b <> "\""
76
76
77− validName x | BS.all (\x -> isAlphaNum x || x `elem` ("-:_" :: String)) x = x
77+ validName x | BS.all (\x -> isAlphaNum x || x `elem` ("-.:_" :: String)) x = x
78 | otherwise = error "Invalid name"
78 | otherwise = error "Invalid name"
79 validAttr x | BS.notElem '\"' x = x
79 validAttr x | BS.notElem '\"' x = x
80 | otherwise = error "Invalid attribute"
80 | otherwise = error "Invalid attribute"