From 6f517951ab4ff97c536f0330e03e54475bdfdd5a Mon Sep 17 00:00:00 2001 From: Patrick Smith Date: Mon, 5 Feb 2018 15:03:18 +1100 Subject: [PATCH 1/2] Fix SVG viewBox attribute issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SVG’S ‘viewBox’ attribute was being converted to the lowercase ‘viewbox’, which browsers don’t like --- src/HtmlParser.elm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/HtmlParser.elm b/src/HtmlParser.elm index a61b128..788971f 100644 --- a/src/HtmlParser.elm +++ b/src/HtmlParser.elm @@ -86,9 +86,26 @@ tagName = map String.toLower (regex "[a-zA-Z][a-zA-Z0-9\\-]*") +specialCaseAttributes : Dict String String +specialCaseAttributes = + Dict.fromList + [ ("viewbox", "viewBox") + ] + + +normalizeAttribute : String -> String +normalizeAttribute input = + let + lower = + String.toLower input + in + Dict.get lower specialCaseAttributes + |> Maybe.withDefault lower + + attributeName : Parser s String attributeName = - map String.toLower (regex "[a-zA-Z][a-zA-Z0-9:\\-]*") + map normalizeAttribute (regex "[a-zA-Z][a-zA-Z0-9:\\-]*") attributeQuotedValue : Parser s String From 082a13d6df36f7c9c29515c1bba77c3ff3ad0db4 Mon Sep 17 00:00:00 2001 From: Patrick Smith Date: Mon, 5 Feb 2018 15:05:49 +1100 Subject: [PATCH 2/2] Fix Dict -> Dict.Dict --- src/HtmlParser.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HtmlParser.elm b/src/HtmlParser.elm index 788971f..6fd4406 100644 --- a/src/HtmlParser.elm +++ b/src/HtmlParser.elm @@ -86,7 +86,7 @@ tagName = map String.toLower (regex "[a-zA-Z][a-zA-Z0-9\\-]*") -specialCaseAttributes : Dict String String +specialCaseAttributes : Dict.Dict String String specialCaseAttributes = Dict.fromList [ ("viewbox", "viewBox")