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

format.register({
	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 breakdown: frontier requires the previous character to be '>'; [^<]+ consumes text through the next '<'
		{ pattern = "%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 = "",
	},
})
