diff --git a/luax.lua b/luax.lua index 919d4a9..98954d9 100644 --- a/luax.lua +++ b/luax.lua @@ -52,9 +52,11 @@ function State:toggle(key, bool) end local function kebabToCamel(str) - return str:gsub("%-(%w)", function(c) + local tag = str:gsub("%-(%w)", function(c) return c:upper() end) + local _, count = str:gsub("-", "-") + return tag, count end local function formatDocTypeParams(input) @@ -112,8 +114,9 @@ local function decentParserAST(input) end if tagName then if tagName:match("(%-+)") then - tagName = kebabToCamel(tagName) - s:inc() + local tag, count = kebabToCamel(tagName) + tagName = tag + s:inc(count) end s:incDeepNode() end @@ -140,8 +143,9 @@ local function decentParserAST(input) s:inc(#tagName) elseif tagNameEnd then if tagNameEnd:match("(%-+)") then - tagNameEnd = kebabToCamel(tagNameEnd) - s:inc() + local tag, count = kebabToCamel(tagNameEnd) + tagNameEnd = tag + s:inc(count) end s:decDeepNode() if s.isTag and not s.textNode then diff --git a/test/21_web_component.luax b/test/21_web_component.luax index a2fe1a7..8ba9926 100644 --- a/test/21_web_component.luax +++ b/test/21_web_component.luax @@ -1 +1 @@ -return Example \ No newline at end of file +return Example \ No newline at end of file diff --git a/test/test_spec.lua b/test/test_spec.lua index 0b79668..63eb99f 100644 --- a/test/test_spec.lua +++ b/test/test_spec.lua @@ -151,7 +151,7 @@ describe("LuaX", function() it("should return a HTML string when given XML like syntax with kebab-case tag", function() local fui = require("test.21_web_component") - assert.is.equal([[Example]], h(fui)) + assert.is.equal([[Example]], h(fui)) end) end)