-- lx syntax
local syntax = require("core.syntax")

syntax.add({
	name = "Extensible Markup (XML)",
	shortname = "XML",
	author = "liqube",
	extensions = "xml",
	headers = "<%?xml",

	patterns = {
		{ pattern = "<%?xml%s?[^\n>]*>", type = "meta", caseless = true },
		{ pattern = "<%/xml>", type = "meta", caseless = true },

		{ pattern = { "<!%-%-", "%-%->" }, type = "comment" },
		{ pattern = { "%f[^>][^<]", "%f[<]" }, type = "normal" },
		{ pattern = { '"', '"', "\\" }, type = "string" },
		{ pattern = { "'", "'", "\\" }, type = "string" },

		{ pattern = "0x[%da-fA-F]+", type = "hex" },
		{ pattern = "-?%d+[%d%.]*f?", type = "number" },
		{ pattern = "-?%.?%d+f?", type = "number" },

		{ pattern = "%f[^<]![%a_][%w_]*", type = "keyword2" },
		{ pattern = "%f[^<][%a_][%w_]*", type = "function" },
		{ pattern = "%f[^<]/[%a_][%w_]*", type = "function" },
		{ pattern = "[%a_][%w_]*", type = "keyword" },
		{ pattern = "[/<>=]", type = "operator" },
	},

	block_comment = {
		block_open = "<!--",
		block_close = "-->",
		block_line_prefix = "",
		close_line_prefix = "",
		open_on_own_line = false,
		close_on_own_line = false,
		strip_line_prefix = "",
	},
})
