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

feat: add filename_small_case #344

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions doc/telekasten.txt
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,19 @@ telekasten.setup({opts})

Default: `nil`

*telekasten.settings.filename_small_case*
filename_small_case: ~
When the note title is used within the filename, i.e.
|new_note_filename| contains 'title', the tile will be
made lowercase.

e.g. if set to true, '20230103-My New Note Title.md' would instead
become '20230103-my new note title.md'

If set to `false`, no substitution will occur.

Default: `false`

*telekasten.settings.image_link_style*
image_link_style: ~
Style of links to insert when pasting an image.
Expand Down
6 changes: 6 additions & 0 deletions lua/telekasten.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ local function defaultConfig(home)
uuid_sep = "-",
-- if not nil, replaces any spaces in the title when it is used in filename generation
filename_space_subst = nil,
-- if true, make the filename lowercase
filename_small_case = false,
-- following a link to a non-existing note will create it
follow_creates_nonexisting = true,
dailies_create_nonexisting = true,
Expand Down Expand Up @@ -180,6 +182,10 @@ local function generate_note_filename(uuid, title)
title = title:gsub(" ", M.Cfg.filename_space_subst)
end

if M.cfg.filename_small_case then
title = string.lower(title)
end

local pp = Path:new(title)
local p_splits = pp:_split()
local filename = p_splits[#p_splits]
Expand Down
Loading