Compare commits
1 commit
build/nix-
...
refactor/r
| Author | SHA1 | Date | |
|---|---|---|---|
| af8bb49122 |
4 changed files with 14 additions and 11 deletions
|
|
@ -53,19 +53,21 @@ function M.compile(bufnr, name, provider, ctx)
|
||||||
M.stop(bufnr)
|
M.stop(bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local output_file = ''
|
||||||
|
if provider.output then
|
||||||
|
output_file = eval_string(provider.output, ctx)
|
||||||
|
end
|
||||||
|
|
||||||
|
local resolved_ctx = vim.tbl_extend('force', ctx, { output = output_file })
|
||||||
|
|
||||||
local cmd = vim.list_extend({}, provider.cmd)
|
local cmd = vim.list_extend({}, provider.cmd)
|
||||||
if provider.args then
|
if provider.args then
|
||||||
vim.list_extend(cmd, eval_list(provider.args, ctx))
|
vim.list_extend(cmd, eval_list(provider.args, resolved_ctx))
|
||||||
end
|
end
|
||||||
|
|
||||||
local cwd = ctx.root
|
local cwd = ctx.root
|
||||||
if provider.cwd then
|
if provider.cwd then
|
||||||
cwd = eval_string(provider.cwd, ctx)
|
cwd = eval_string(provider.cwd, resolved_ctx)
|
||||||
end
|
|
||||||
|
|
||||||
local output_file = ''
|
|
||||||
if provider.output then
|
|
||||||
output_file = eval_string(provider.output, ctx)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if output_file ~= '' then
|
if output_file ~= '' then
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
---@field file string
|
---@field file string
|
||||||
---@field root string
|
---@field root string
|
||||||
---@field ft string
|
---@field ft string
|
||||||
|
---@field output? string
|
||||||
|
|
||||||
---@class preview.Diagnostic
|
---@class preview.Diagnostic
|
||||||
---@field lnum integer
|
---@field lnum integer
|
||||||
|
|
|
||||||
|
|
@ -138,8 +138,7 @@ M.markdown = {
|
||||||
ft = 'markdown',
|
ft = 'markdown',
|
||||||
cmd = { 'pandoc' },
|
cmd = { 'pandoc' },
|
||||||
args = function(ctx)
|
args = function(ctx)
|
||||||
local output = ctx.file:gsub('%.md$', '.html')
|
return { ctx.file, '-s', '--embed-resources', '-o', ctx.output }
|
||||||
return { ctx.file, '-s', '--embed-resources', '-o', output }
|
|
||||||
end,
|
end,
|
||||||
output = function(ctx)
|
output = function(ctx)
|
||||||
return (ctx.file:gsub('%.md$', '.html'))
|
return (ctx.file:gsub('%.md$', '.html'))
|
||||||
|
|
@ -158,7 +157,6 @@ M.github = {
|
||||||
ft = 'markdown',
|
ft = 'markdown',
|
||||||
cmd = { 'pandoc' },
|
cmd = { 'pandoc' },
|
||||||
args = function(ctx)
|
args = function(ctx)
|
||||||
local output = ctx.file:gsub('%.md$', '.html')
|
|
||||||
return {
|
return {
|
||||||
'-f',
|
'-f',
|
||||||
'gfm',
|
'gfm',
|
||||||
|
|
@ -168,7 +166,7 @@ M.github = {
|
||||||
'--css',
|
'--css',
|
||||||
'https://cdn.jsdelivr.net/gh/pixelbrackets/gfm-stylesheet@master/dist/gfm.css',
|
'https://cdn.jsdelivr.net/gh/pixelbrackets/gfm-stylesheet@master/dist/gfm.css',
|
||||||
'-o',
|
'-o',
|
||||||
output,
|
ctx.output,
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
output = function(ctx)
|
output = function(ctx)
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,7 @@ describe('presets', function()
|
||||||
file = '/tmp/document.md',
|
file = '/tmp/document.md',
|
||||||
root = '/tmp',
|
root = '/tmp',
|
||||||
ft = 'markdown',
|
ft = 'markdown',
|
||||||
|
output = '/tmp/document.html',
|
||||||
}
|
}
|
||||||
|
|
||||||
it('has ft', function()
|
it('has ft', function()
|
||||||
|
|
@ -233,6 +234,7 @@ describe('presets', function()
|
||||||
file = '/tmp/document.md',
|
file = '/tmp/document.md',
|
||||||
root = '/tmp',
|
root = '/tmp',
|
||||||
ft = 'markdown',
|
ft = 'markdown',
|
||||||
|
output = '/tmp/document.html',
|
||||||
}
|
}
|
||||||
|
|
||||||
it('has ft', function()
|
it('has ft', function()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue