Add files via upload
Kevgeon - Brandon [07-10-17 - 00:33]
diff --git a/autotag.lua b/autotag.lua
new file mode 100644
index 0000000..119d4f4
--- /dev/null
+++ b/autotag.lua
@@ -0,0 +1,27 @@
+return {
+ name = "Autotag for xml",
+ description = "Auto-enters closing tags for xml",
+ author = "Brandon Wall @Solvaring",
+ version = 0.1,
+ onEditorCharAdded = function(self, editor, event)
+ local tag = editor:GetCurLine()
+ if tag:find('%b<>') then
+ local position = editor:GetCurrentPos()
+ if tag:find('/>') then
+ goto breakout
+ end
+ if tag:find('</') then
+ goto breakout
+ end
+ tag = tag:match('<([%w]+)[%s]*')
+ if string.find(editor:GetCurLine(), '%b<><') then
+ editor:AddText("/"..tag..">")
+ editor:GotoPos(position-1)
+ goto breakout
+ end
+ editor:AddText("</"..tag..">")
+ editor:GotoPos(position)
+ ::breakout::
+ end
+ end
+}
\ No newline at end of file