Package: panvimwiki
description: Filter and convert Vimwiki notes using pandoc.
project: panvimwiki
toc: true
vimversion: Vim v9.0Filter and convert Vimwiki notes using pandocIntroductionPanvimwiki provides tools for conversion to Microsoft Word docx or other
output formats supported byPandocPanvimwiki provides command line
tools as well as Vim commands to concatenate and convert Diary Notes or
convert any Vimwiki note.InstallationPanvimwiki requiresPandocInstallation withcondais recommended
because the system version, e.g., with Ubuntu, may be too old. Or
download from the website.Pypandocsupports binary installation of
pandoc usingpip.Using the Vim 8 native packages, panvimwiki should install inpack/*/opt/panvimwikibecause it depends on:python3and requires
installation of the python package panvimwiki.From a bash shell, enter the following:# Adjust dest to suit, e.g., $HOME/vimfiles/pack/vimwiki/opt/panvimwikidest="$HOME/.vim/pack/vimwiki/opt/panvimwiki"gitclonehttps://github.com/jfishe/panvimwiki.git"$dest"# Activate the python environment used by Vim.# Then install panvimwiki in that python environment.python-mpipinstall"$dest"# Or to install from pypi:python-mpipinstallpanvimwikiPanvimwiki requires Vim compiled with Python 3, so add the following tovimrcprior to:filetype-plugin-on. See:packaddfor an
explanation. Otherwise, install panvimwiki inpack/*/start/panvimwiki.ifhas('python3')packadd!panvimwikiendifUsageCommand Line ShellPanvimwiki provides plain text pre-filters and pandoc filters for use
from the command line.For example from a bash prompt:cat$HOME/vimwiki/diary/*|delete_bullet_star|delete_task_pending|pandoc--from=vimwiki--to=markdown\--filter=delete_tag_lines\--filter=delete_taskwiki_heading\--filter=delete_empty_headingFrom python:frompathlibimportPathfrompanvimwiki.convertimportconvertPREFILTER=("delete_bullet_star","delete_task_pending",)FILTER=("delete_tag_lines","delete_empty_heading","delete_taskwiki_heading",)EXTRA_ARGS=("--shift-heading-level-by","1","--data-dir",str(Path.home()/"vimwiki_html/templates"),)convert(inputfile=str(Path.home()/"vimwiki/index.wiki"),outputfile=str(Path.home()/"vimwiki_html/markdown/index.md"),to="markdown",prefilters=PREFILTER,filters=FILTER,extra_args=EXTRA_ARGS,)Pre-Filtersdelete_bullet_starRemove unordered lists which use the star (asterisk) bullet marker.The pre-filter does not remove task list items (seedelete_task_pending). The pre-filter does not handle wrapped
bullets--i.e., it will delete the bulleted-line and leave the wrapped
lines. I haven't figured out a good regex for wrapped lines.echo'- Bulleted list item 1 should appear'\'* Bulleted list item 6 should NOT appear'|delete_bullet_star- Bulleted list item 1 should appeardelete_task_pendingDelete pending tasks.echo'- [ ] Bulleted list done0 item 0 should NOT appear'\'- [.] Bulleted list done1 item 1 should appear'|delete_task_pending- [.] Bulleted list done1 item 1 should appearPandoc FiltersPanvimwiki provides plain text pre-filters, pandoc filters and
post-filters for use from the command line.delete_tag_linesDelete lines which only contain Vimwiki tags, e.g., ':tag1:tag2:'delete_empty_headingRemove headings that do not have any children or paragraphs. Remove tag
lines first,delete_tag_linesor the heading is not considered empty.delete_taskwiki_headingPost-Filtersreference_citationConvert citations to a reference list.Example.md:::: {#refs .references .csl-bib-body .hanging-indent}
::: {#ref-bloggs-jones .csl-entry}
Bloggs, A. J., and X. Y. Jones. 1959. "Title Title Title Title Title Title
Title Title Title Title."_Journal Journal Journal_.
:::

::: {#ref-chomsky-73 .csl-entry}
Chomsky, N. 1973. "Conditions on Transformations." In _A Festschrift for Morris
Halle_, edited by S. R. Anderson and P. Kiparsky. New York: Holt, Rinehart &
Winston.
:::
:::reference_citation < Example.mdproduces:[#ref-bloggs-jones]:Bloggs, A. J., and X. Y. Jones. 1959. "Title Title Title TitleTitle Title Title Title Title Title."_Journal Journal Journal_.

[#ref-chomsky-73]:Chomsky, N. 1973. "Conditions on Transformations." In _AFestschrift for Morris Halle_, edited by S. R. Anderson and P. Kiparsky.
New York: Holt, Rinehart & Winston.wikilink_markdownConvertPandocmarkdown tasks and wikilinks to:h vimwiki-todo-listsand markdown links compatible with:h vimwiki-syntax-links.CommandsLocal CommandsThese commands are only available (and meaningful) when you are
currently in a Vimwiki file.VimwikiConvert[!]Convert the current Vimwiki buffer. With !, open with default viewer.Convert the current Vimwiki:bufferto the selected output format (default:
docx) specified ing:panvimwiki_settings.Copy the path to the Word file to the clipboard register "+quoteplus.
On Windows Subsystem for Linux (WSL), convert the path from POSIX to
Windows before copying to clipboard.Remove extraneous info:Vimwiki tag lines, e.g., :tag1:tag2:Not started tasks, e.g., - [ ] Task1Non-task bullet lines, e.g.,* [[URI|Description]]or* TextRemove empty parent/child headings.VimwikiConvertWeek[!]Concatenate DiaryNotes for Monday through current buffer and convert.
With !, open in default viewer.After concatenating DiaryNotes for the week, behave asVimwikiConvert.VimwikiReferenceIf in markdown format, expandPandoc Citationsin the current file and
append to the end of the file. The Yaml metadata shouldspecify the
bibliographic dataand theCitation Style Language (CSL).Add the following to.markdownlint.ymlto suppressMD033:# MD033/no-inline-html : Inline HTML :# https://github.com/DavidAnson/markdownlint/blob/main/doc/md033.mdMD033:# MD033/no-inline-html Inline HTML [Element: div]# Allowed elementsallowed_elements:-'div'VimwikiReferenceoverwrites the file, so Vim may prompt to reload the
buffer (cf. Warning:h W12). If you choose not to reload the buffer,:h :DiffOrigfacilitate review of the changes.VimwikiMarkdownFormatIf in markdown format, convert:h vimwiki-syntax-linkswikilinks_title_after_pipetoInline links, without the
"wikilink" title that pandoc adds by default. Preserve:h vimwiki-todo-lists,
usingtask_lists.VimwikiMarkdownFormatoverwrites the file, so Vim may prompt to reload the
buffer (cf. Warning:h W12). If you choose not to reload the buffer,:h :DiffOrigfacilitate review of the changes.SettingsGlobal Settingsg:panvimwiki_settingsOptionally add the following to or, preferably,
'~/.vim/plugin/vimwiki.vim'. Panvimwiki defaults to docx format,
without extra_args.letg:panvimwiki_settings={
      \'extra_args': ['--shift-heading-level-by','1',\'--data-dir','~/vimwiki_html/templates/'\ ],\'format':'docx'\ }Development and TestingBecause pandoc is required, a conda environment calledpanvimwikiis
created. The default name may be overridden with the--name <environment name>parameter.gitclonehttps://github.com/jfishe/panvimwiki.gitcdpanvimwiki
condaenvcreate--fileenvironment.yml
condaactivatepanvimwikitox-av# List tox commands and descriptions.tox--recreate# Build the package and run tests with python and Vader.tox-evim# Run Vader tests and generate coverage report.# Run Vader tests and view results with Vim.vim-Nutests/vim/vimrc-c'Vader tests/vim/*.vader'NoteThis project has been set up using PyScaffold 4.5. For details and usage
information on PyScaffold seehttps://pyscaffold.org/.