Skip to content
Open
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ let g:mkdp_page_title = '「${name}」'
" use a custom location for images
let g:mkdp_images_path = /home/user/.markdown_images

" resolve absolute image paths against the custom location for images,
" instead of the root of the system (default to 0)
let g:mkdp_images_path_as_root = 1

" recognized filetypes
" these filetypes will have MarkdownPreview... commands
let g:mkdp_filetypes = ['markdown']
Expand Down
2 changes: 1 addition & 1 deletion app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ use(async (req, res, next) => {

let imgPath = decodeURIComponent(decodeURIComponent(req.asPath.replace(reg, '')))
imgPath = imgPath.replace(/\\ /g, ' ')
if (imgPath[0] !== '/' && imgPath[0] !== '\\') {
if (req.custImgPathAsRoot || imgPath[0] !== '/' && imgPath[0] !== '\\') {
imgPath = path.join(fileDir, imgPath)
} else if (!fs.existsSync(imgPath)) {
let tmpDirPath = fileDir
Expand Down
1 change: 1 addition & 0 deletions app/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ exports.run = function () {
req.mkcss = await plugin.nvim.getVar('mkdp_markdown_css')
req.hicss = await plugin.nvim.getVar('mkdp_highlight_css')
req.custImgPath = await plugin.nvim.getVar('mkdp_images_path')
req.custImgPathAsRoot = await plugin.nvim.getVar('mkdp_images_path_as_root')
// routes
routes(req, res)
})
Expand Down
6 changes: 6 additions & 0 deletions plugin/mkdp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ if !exists('g:mkdp_images_path')
let g:mkdp_images_path = ''
endif

" if 1, absolute image paths are resolved against the images custom
" path instead of the system root
if !exists('g:mkdp_images_path_as_root')
let g:mkdp_images_path_as_root = 0
endif

" combine preview window
if !exists('g:mkdp_combine_preview')
let g:mkdp_combine_preview = 0
Expand Down