Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
VimWei opened this issue Apr 29, 2024 · 4 comments
Open

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

VimWei opened this issue Apr 29, 2024 · 4 comments

Comments

@VimWei
Copy link

VimWei commented Apr 29, 2024

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
Copy link
Author

VimWei commented Apr 29, 2024

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

@lervag
Copy link
Owner

lervag commented Apr 29, 2024

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.

@VimWei
Copy link
Author

VimWei commented Apr 30, 2024

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
Copy link
Author

VimWei commented Apr 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants