comparison runtime/compiler/pandoc.vim @ 34807:7f709fa537df v9.1.0276

patch 9.1.0276: No pandoc syntax support Commit: https://github.com/vim/vim/commit/7005b7ee7f282b24378c2a844366cb8616cad5d7 Author: Wu, Zhenyu <wuzhenyu@ustc.edu> Date: Mon Apr 8 20:53:19 2024 +0200 patch 9.1.0276: No pandoc syntax support Problem: No pandoc syntax support Solution: Add pandoc syntax and compiler plugins (Wu, Zhenyu, Konfekt) closes: #14389 Co-authored-by: Konfekt <Konfekt@users.noreply.github.com> Signed-off-by: Wu, Zhenyu <wuzhenyu@ustc.edu> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Mon, 08 Apr 2024 22:00:03 +0200
parents
children ca0bfdb5d652
comparison
equal deleted inserted replaced
34806:33cac3f2dec5 34807:7f709fa537df
1 " Vim compiler file
2 " Compiler: Pandoc
3 " Maintainer: Konfekt
4 "
5 " Expects output file extension, say `:make html` or `:make pdf`.
6 " Passes additional arguments to pandoc, say `:make html --self-contained`.
7
8 if exists("current_compiler")
9 finish
10 endif
11
12 if exists(":CompilerSet") != 2 " older Vim always used :setlocal
13 command -nargs=* CompilerSet setlocal <args>
14 endif
15
16 let s:keepcpo = &cpo
17 set cpo&vim
18
19 let current_compiler = 'pandoc'
20
21 " As of 2024-04-08 pandoc supports the following text input formats with
22 " an ftplugin on Github:
23 let s:supported_filetypes =
24 \ [ 'bibtex', 'markdown', 'creole', 'json', 'csv', 'tsv', 'docbook',
25 \ 'xml', 'fb2', 'html', 'jira', 'tex', 'mediawiki', 'nroff', 'org',
26 \ 'rtf', 'rst', 't2t', 'textile', 'twiki', 'typst', 'vimwiki' ]
27 " .. and out of those the following are included in Vim's runtime:
28 " 'xml', 'tex', 'html', 'rst', 'json', 'nroff', 'markdown'
29
30 silent! function s:PandocFiletype(filetype) abort
31 let ft = a:filetype
32 if ft ==# 'pandoc'
33 return 'markdown'
34 elseif ft ==# 'tex'
35 return 'latex'
36 elseif ft ==# 'xml'
37 " Pandoc does not support XML as a generic input format, but it does support
38 " EndNote XML and Jats XML out of which the latter seems more universal.
39 return 'jats'
40 elseif ft ==# 'text' || empty(ft)
41 return 'markdown'
42 elseif index(s:supported_filetypes, &ft) >= 0
43 return ft
44 else
45 echomsg 'Unsupported filetype: ' . a:filetype ', falling back to Markdown as input format!'
46 return 'markdown'
47 endif
48 endfunction
49 execute 'CompilerSet makeprg=pandoc\ --standalone' .
50 \ '\ --metadata\ title=%:t:r:S' .
51 \ '\ --metadata\ lang=' . matchstr(&spelllang, '^\a\a') .
52 \ '\ --from=' . s:PandocFiletype(&filetype) .
53 \ '\ --output\ %:r:S.$*\ %:S'
54
55 CompilerSet errorformat="%f",\ line\ %l:\ %m
56
57 let &cpo = s:keepcpo
58 unlet s:keepcpo