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

@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.

end
-- add white spaces between title and slide number
local white_space_fill = string.rep(" ", width - title_len - #footer_nrs)
local footer_text = presentation_title .. white_space_fill .. footer_nrs
Copy link
Owner

Choose a reason for hiding this comment

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

I always wanted to have this, but I was too lazy. Nice!

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
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! 🙏

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