Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add title to footer #11

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

gerazov
Copy link
Contributor

@gerazov gerazov commented Oct 22, 2024

A bit hacky but extracts the title from the first line of the first slide.

It also left aligns the title and right aligns the slide nr.

@gerazov gerazov requested a review from sotte as a code owner October 22, 2024 00:21
Copy link
Owner

@sotte sotte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

There is one issue with extracting the title for adoc files. Otherwise this is good.

lua/presenting/init.lua Show resolved Hide resolved
Comment on lines +387 to +403
H.extract_title = function(slide)
local title = ""
for _, line in pairs(vim.split(slide, "\n")) do
-- if line is nonempty set it as title
if line:match("%S") then
title = line
break
end
end
-- strip any trailing whitespace
title = title:gsub("%s+$", "")
-- strip any starting * or # for org and md
title = title:gsub("^%*+%s*", "")
title = title:gsub("^#+%s*", "")
return title
end

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic here is not quite apt to the task.

I opened the adoc file and got this title in the footer:
image
It works for md and org files. Let's make it work for adoc files as well.

Also I wonder if we can reuse the separator definitions from the config instead of having two very similar definitions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sure go right ahead! I'm not really using adoc.

Ultimately we should add a proper frontmatter parser like in lookatme - #12

btw I held 6 classes last week with this and it was awesome - thanks! 🙏

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad to hear that presenting.nvim works for you ❤️

Having a frontmatter parer would be nice, but I want to keep presenting.nvim as simple as possible and don't want any external deps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do it in plain Lua, e.g. if the first line in the first slide starts with title: then we parse the title etc. This is just to populate the footer of course.

@sotte sotte mentioned this pull request Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants