summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin.chausse@goto.com>2025-04-01 11:29:52 -0400
committerBenjamin Chausse <benjamin.chausse@goto.com>2025-04-01 11:29:52 -0400
commiteed913409a070100d6a5d6792d81464c66dd0f6d (patch)
tree4862cf223e1ece9199ebe84baa522d7ee29c9702
Batman
-rw-r--r--lua/rafta.lua39
1 files changed, 39 insertions, 0 deletions
diff --git a/lua/rafta.lua b/lua/rafta.lua
new file mode 100644
index 0000000..b3483a4
--- /dev/null
+++ b/lua/rafta.lua
@@ -0,0 +1,39 @@
+local M = {}
+
+M.setup = function()
+ -- nothing
+end
+
+---@class rafta.Slides
+---@fields slides string[]: The slides of the file
+
+--- Takes some lines and parses them
+---@param lines string[]: The lines in the buffer
+---@return rafta.Slides
+local parse_slides = function(lines)
+ local current_slide = {}
+ local sep = "^#"
+
+ local slides = { slides = {} }
+ for _, line in ipairs(lines) do
+ print(line, "find:", line:find(sep), "|")
+ if line:find(sep) then
+ if #current_slide > 0 then
+ table.insert(slides.slides, current_slide)
+ end
+ current_slide = {}
+ end
+ table.insert(current_slide, line)
+ end
+ table.insert(slides.slides, current_slide)
+ return slides
+end
+
+vim.print(parse_slides({
+ "# Hello",
+ "this is something else",
+ "# World",
+ "this is another thing",
+}))
+
+return M