wiki.vim
wiki.vim copied to clipboard
How can g:wiki_export be configured to support HTML, docx, and PDF?
With the following configuration, WikiExport
can correctly output PDF files, but WikiExport test.html
is not usable because the args do not match for HTML. How can g:wiki_export be configured to support HTML, docx, and PDF?
let s:TexTemplate = s:viminit . "tools/pandoc/template.latex"
let s:pandocargs = '--pdf-engine=xelatex -V CJKmainfont="SimSun" --template="' . s:TexTemplate . '"'
let g:wiki_export = {
\ 'args' : s:pandocargs,
\ 'from_format' : 'markdown',
\ 'ext' : 'pdf',
\ 'link_ext_replace': v:false,
\ 'view' : v:false,
\ 'output': 'PandocOutput',
\}
Moreover, with the above configuration, why does the command WikiExport newname.pdf
output original-markdown-name.pdf
instead of newname.pdf
?
With the following configuration,
WikiExport
can correctly output PDF files
You mean after simply :WikiExport<cr>
?
but
WikiExport test.html
is not usable because the args do not match for HTML.
I'm sorry, but that does not currently make sense to me.
How can g:wiki_export be configured to support HTML, docx, and PDF?
I'm not sure yet. Let's find out!
In the snippet, what is s:viminit
?
Moreover, with the above configuration, why does the command
WikiExport newname.pdf
outputoriginal-markdown-name.pdf
instead ofnewname.pdf
?
My initial thought is that it is probably a bug.
With the following configuration,
WikiExport
can correctly output PDF filesYou mean after simply
:WikiExport<cr>
?
Yes. With :WikiExport<cr>
, the output file has correctly applied the definition from g:wiki_export
.
But with :WikiExport newname.pdf<cr>
, the output file still test.pdf. This means that :WikiExport newname.pdf<cr>
has the same effect as :WikiExport<cr>
.
but WikiExport test.html is not usable because the args do not match for HTML.
I'm sorry, but that does not currently make sense to me.
This is test.md, and after :WikiExport test.html<cr>
The ouput test.html applied g:wiki_export = { 'args' : s:pandocargs }
, as shown below; however, it did not apply g:wiki_export = { 'output': 'PandocOutput' }
, and the output is in the directory where the original test.md is located.
But, unlike :WikiExport newname.pdf<cr>
, :WikiExport newname.html<cr>
correctly outputs the file named newname.html
.
what is
s:viminit
?
let s:viminit = fnamemodify(resolve(expand('<sfile>:p')), ':h:h')
let s:viminit = substitute(s:viminit . '/', '\\', '/', 'g')
How can g:wiki_export be configured to support HTML, docx, and PDF?
I'm not sure yet. Let's find out!
Before using wiki.vim, I had already implemented a solution similar to WikiExport.
Detail: https://github.com/VimWei/vim-init/blob/master/autoload/Pandoc.vim
command! PandocToPDF call Pandoc#ToPdf()
command! PandocToDOCX call Pandoc#ToDocx()
command! PandocToHTML call Pandoc#ToHtml()
Upon seeing WikiExport in wiki.vim, I wanted to reproduce the above commands to freely choose the desired output file type: HTML for faster output, docx for easy sharing of files with colleagues, and PDF for convenient printing.
But don't know how. This is the background to why I raised this issue, for your reference.