Skip to content

Commit

Permalink
feat: add filename_small_case
Browse files Browse the repository at this point in the history
Add an option to cast the new filename to lowercase. Closes #311.
  • Loading branch information
erooke committed Oct 11, 2024
1 parent ae6473d commit 9610fcd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
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

0 comments on commit 9610fcd

Please sign in to comment.