Skip to content

Commit e948347

Browse files
committed
feat(babel): add directory creation support with :mkdirp header argument
When tangling code blocks to files, automatically create parent directories when the :mkdirp header argument is set to 'yes'.
1 parent bcb8bc4 commit e948347

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lua/orgmode/babel/tangle.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ function Tangle:tangle()
7575
filemode = tangle_mode:gsub('[\'"]', '')
7676
end
7777

78+
if info.header_args[':mkdirp'] == 'yes' then
79+
local path = vim.fn.fnamemodify(info.filename, ':h')
80+
vim.fn.mkdir(path, "p")
81+
end
82+
7883
if info.name then
7984
block_content_by_name[info.name] = parsed_content
8085
end

0 commit comments

Comments
 (0)