notex.nvim/lua/notex/document.lua

29 lines
530 B
Lua
Raw Permalink Normal View History

2025-10-05 20:16:33 -04:00
-- lua/notex/document.lua
local lyaml = require("lyaml")
local M = {}
function M.parse(file_content)
local yaml_part, content_part = file_content:match("\n?^---\n(.-?)\n---\n(.*)")
if not yaml_part then
return {
type = "note",
properties = {},
content = file_content,
}
end
local properties = lyaml.load(yaml_part)
local doc_type = properties.type or "note"
properties.type = nil
return {
type = doc_type,
properties = properties,
content = content_part,
}
end
return M