Commit e510d1e 1 parent aa61312 commit e510d1e Copy full SHA for e510d1e
File tree 1 file changed +25
-1
lines changed
lua/neorg/modules/core/norg/journal
1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,26 @@ require("neorg.modules.base")
25
25
local module = neorg .modules .create (" core.norg.journal" )
26
26
local log = require (" neorg.external.log" )
27
27
28
+
29
+ --- Preform substitutions for a template file.
30
+ --- Right now this just supports {DATE} and {FULLDATE}
31
+ --- @param filename string #The filename to the template file that will have substitutions
32
+ local function sub_file (filename )
33
+ local lines = {}
34
+ for line in io.lines (filename ) do
35
+ lines [# lines + 1 ] = (line :gsub (" %S+" , function (word )
36
+ if word :match (" {DATE}" ) then
37
+ return os.date (" %Y-%m-%d" )
38
+ elseif word :match (" {FULLDATE}" ) then
39
+ return os.date (" %A, %B %d, %Y" )
40
+ else
41
+ return word
42
+ end
43
+ end ))
44
+ end
45
+ return lines
46
+ end
47
+
28
48
module .examples = {
29
49
[" Changing TOC format to divide year in quarters" ] = function ()
30
50
-- In your ["core.norg.journal"] options, change toc_format to a function like this:
@@ -147,7 +167,11 @@ module.private = {
147
167
workspace_path .. " /" .. folder_name .. " /" .. template_name
148
168
)
149
169
then
150
- vim .cmd (" 0read " .. workspace_path .. " /" .. folder_name .. " /" .. template_name .. " | w" )
170
+ -- vim.cmd("0read " .. workspace_path .. "/" .. folder_name .. "/" .. template_name .. "| w")
171
+ vim .api .nvim_put (sub_file (workspace_path .. " /" .. folder_name .. " /" .. template_name ),
172
+ " c" ,
173
+ false ,
174
+ true )
151
175
end
152
176
end ,
153
177
You can’t perform that action at this time.
0 commit comments