wiki.vim icon indicating copy to clipboard operation
wiki.vim copied to clipboard

How can g:wiki_export be configured to support HTML, docx, and PDF?

Open VimWei opened this issue 9 months ago • 4 comments

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',
          \}

VimWei avatar Apr 29 '24 14:04 VimWei

Moreover, with the above configuration, why does the command WikiExport newname.pdf output original-markdown-name.pdf instead of newname.pdf?

VimWei avatar Apr 29 '24 14:04 VimWei

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 output original-markdown-name.pdf instead of newname.pdf?

My initial thought is that it is probably a bug.

lervag avatar Apr 29 '24 20:04 lervag

With the following configuration, WikiExport can correctly output PDF files

You 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>.

image

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>

test.md after WikiExport test.html

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.

image

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')

VimWei avatar Apr 30 '24 00:04 VimWei

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.

VimWei avatar Apr 30 '24 00:04 VimWei