Giter Club home page Giter Club logo

vimwiki_markdown's Introduction

vimwiki-markdown

PyPI version PyPI downloads

vimwiki markdown file to html with syntax highlighting.

Install

pip install vimwiki-markdown

Usage

Add the following to your ~/.vimrc:

let g:vimwiki_list = [{
	\ 'path': '~/vimwiki',
	\ 'template_path': '~/vimwiki/templates/',
	\ 'template_default': 'default',
	\ 'syntax': 'markdown',
	\ 'ext': '.md',
	\ 'path_html': '~/vimwiki/site_html/',
	\ 'custom_wiki2html': 'vimwiki_markdown',
	\ 'template_ext': '.tpl'}]

Markdown extensions

The following markdown extensions are activated by default:

But you can add more extensions using VIMWIKI_MARKDOWN_EXTENSIONS environment variable:

  1. Json dictionary syntax of extension with configuration {"toc": {"baselevel": 2 }, "nl2br": {}}. Note: {} configuration implies no configuration.
  2. [DEPRECATED] Json list syntax of extension. ["toc", "nl2br"].
  3. [DEPRECATED] comma separated list of extensions toc,nl2br.

Warning Deprecated formats will be remove in next major release

Syntax highlighting

Syntax highlighting is provided by Pygments, which will try to guess language by default.

You can use regular markdown indented code blocks:

	:::python
	for value range(42):
		print(value)

Or Fenced Code Blocks

```python
for value range(42):
	print(value)
```

You can also highlight line using hl_lines argument:

```python hl_lines="1 3"
for value range(42):
	print(value)
```

Pygments can generate CSS rules for you. Just run the following command from the command line:

pygmentize -S default -f html -a .codehilite > styles.css

If you would like to use a different theme, swap out default for the desired theme. For a list of themes installed on your system, run the following command:

pygmentize -L style

If you are lazy you can just use the one in this repository inside css directory which provide the monokai theme.

Environment variables

The following environment variables are available, but not mandatory:

  • VIMWIKI_TEMPLATE_PATH: path to vimwiki HTML template
  • VIMWIKI_TEMPLATE_DEFAULT: default HTML template name
  • VIMWIKI_TEMPLATE_EXT: default HTML template extension
  • VIMWIKI_ROOT_PATH: vimwiki root path

If not set vimwiki_markdown will use the default template defined in the source code.

vimwiki_markdown's People

Contributors

dependabot[bot] avatar joaoandreporto avatar levirs565 avatar wnp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vimwiki_markdown's Issues

Can't pass extension config correctly

Hi ๐Ÿ‘‹

I have following env: VIMWIKI_MARKDOWN_EXTENSIONS={"toc": {"baselevel": 2 }}

But sadly, while it applies [TOC], it does not apply baselevel setting (starts from 1).

Any pointers you could give? Thanks!

Links to directory index are not properly generated

When using links in vimwiki, one can specify links as such:

[Dir](Dir/)

Using vimwiki, one can specify that that link be interpreted as Dir/index.html or any arbitrary setting using the following:

let g:vimwiki_dir_link='index'

The current behavior makes it such that navigating to a directory via the generated HTML files does not work unless the user manually specifies [Dir](Dir/index.html) for each link.

Perhaps vimwiki_markdown should check what this variable is set to and replace links to directories such as above with Dir/index.html when appropriate?

How to use vimwiki_markdown under windows 10?

  • What I want?

Batch convert vimwiki Markdown files to HTML.

  • the output of :VimwikiShowVersion.

Os: Windows
Vim: 802
Branch: HEAD
Revision: c9e6afe
Date: 2020-05-26 23:09:58 +0200

  • Post the syntax you are using (default/mediawiki/markdown) and your vimwiki settings from your .vimrc

    Plug 'vimwiki/vimwiki', { 'commit': 'c9e6afe' }

    " def wiki dict for normal
    let wiki = {}
    let wiki.name = 'ChenWei VimwikiMd'
    let wiki.path = 'd:/WeirdData/VimwikiMd/'
    let wiki.ext = '.md'
    let wiki.syntax = 'markdown'
    let wiki.nested_syntaxes = {'python': 'python'}
    let wiki.links_space_char = '_'
    let wiki.list_margin = 0
    let wiki.auto_toc = 1
    let wiki.auto_tags = 1
    let wiki.auto_generate_tags = 1

    " dev wiki dict for convert markdown to html
    let wiki.template_path = 'd:/WeirdData/VimwikiMd/templates/'
    let wiki.template_default = 'default'
    let wiki.path_html = 'd:/WeirdData/VimwikiMd/site_html/'
    let wiki.custom_wiki2html = 'vimwiki_markdown'
    let wiki.template_ext = '.tpl'

    " def vimwiki_list and so on.
    let g:vimwiki_list = [wiki]
    let g:vimwiki_ext2syntax = {'.md': 'markdown'}
    let g:vimwiki_global_ext = 1
    let g:vimwiki_autowriteall = 1
    let g:vimwiki_auto_chdir = 1
    let g:vimwiki_folding = 'expr'

  • Provide a detailed description of the problem including steps to reproduce the issue.

  1. Install vimwiki_markdown pip install vimwiki-markdown
  2. Config vimrc.
  3. Open my vimwiki index file <leader>ww
  4. Run Convert command <leader>wh
  5. The output files in folder d:\WeirdData\VimwikiMD\site_html\ are only style.css but no any HTML files.
    and there are some messages:
Traceback (most recent call last):^@  File "c:\users\chenwei\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main^@    "__main__", mod_spec)^@  File "c:\users\chenwei\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code^@    exec(code, run_globals)^@  File "C:\Users\chenwei\AppData\Local\Programs\Python\Python37\Scripts\vimwiki_markdown.exe\__main__.py", line 7, in <module>^@  File "c:\users\chenwei\appdata\local\programs\python\python37\lib\site-packages\vimwiki_markdown.py", line 69, in main^@    TEMPLATE_EXT = sys.argv[9]^@IndexError: list index out of range^@
Vimwiki: HTML conversion is done, output: d:\WeirdData\VimwikiMd\site_html\

What should I do ?

pip install vimwiki-markdown failed

I try to run on AIX -> pip install vimwiki-markdown
but this failed

pip install vimwiki-markdown
Traceback (most recent call last):
File "/opt/freeware/bin/pip", line 6, in
from pip._internal.cli.main import main
File "/opt/freeware/lib/python3.7/site-packages/pip/_internal/init.py", line 40, in
from pip._internal.cli.autocompletion import autocomplete
File "/opt/freeware/lib/python3.7/site-packages/pip/_internal/cli/autocompletion.py", line 8, in
from pip._internal.cli.main_parser import create_main_parser
File "/opt/freeware/lib/python3.7/site-packages/pip/_internal/cli/main_parser.py", line 11, in
from pip._internal.commands import (
File "/opt/freeware/lib/python3.7/site-packages/pip/_internal/commands/init.py", line 6, in
from pip._internal.commands.completion import CompletionCommand
File "/opt/freeware/lib/python3.7/site-packages/pip/_internal/commands/completion.py", line 6, in
from pip._internal.cli.base_command import Command
File "/opt/freeware/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 26, in
from pip._internal.index import PackageFinder
ImportError: cannot import name 'PackageFinder' from 'pip._internal.index' (/opt/freeware/lib/python3.7/site-packages/pip/_internal/index/init.py)
`

Any suggestion?

Exporting HTML does not provide pygmentize.css

Hi there,

First of all, thanks for this plugin. I owe you my wiki ๐Ÿ™‚

One small issue I've realized: After exporting to HTML, the pygmentize.css file in the target folder is missing. Exact issue I'm getting on nginx logs:

*6382 open() "/shared/vhosts/gurkan.in/public/wiki/pygmentize.css" failed (2: No such file or directory), client: 50.100.227.44, server: gurkan.in, request: "GET /wiki/pygmentize.css HTTP/2.0", host: "gurkan.in", referrer: "https://gurkan.in/wiki/nix.html"

So I've manually generated the file like you told on README. I'm not sure if this is expected or not? Can I somehow add an extra parameter to make HTML generation also run the pygments command to generate the required css?

Thanks!

No such file or directory 'vim' error

My init.vim:

          let g:vimwiki_list = [{
	\ 'path': '/media/vimwiki',
	\ 'template_path': '/media/vimwiki/templates/',
	\ 'template_default': 'default',
	\ 'syntax': 'markdown',
	\ 'ext': '.md',
	\ 'path_html': '~/vimwiki/site_html/',
	\ 'custom_wiki2html': 'vimwiki_markdown',
	\ 'template_ext': '.tpl'}]

Here's the error:

Vimwiki: Saving Vimwiki files ...
Vimwiki: Deleting non-wiki html files ...
Vimwiki: Converting wiki to html files ...
Vimwiki: Processing /media/vimwiki/Markdowncheatsheet.md
Traceback (most recent call last):^@  File "/usr/bin/vimwiki_markdown", line 5, in <module>^@    from vimwiki_markdo
wn import main^@  File "/usr/lib/python3.8/site-packages/vimwiki_markdown.py", line 32, in <module>^@    with subpro
cess.Popen(^@  File "/usr/lib/python3.8/subprocess.py", line 854, in __init__^@    self._execute_child(args, executa
ble, preexec_fn, close_fds,^@  File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child^@    raise chil
d_exception_type(errno_num, err_msg, err_filename)^@FileNotFoundError: [Errno 2] No such file or directory: 'vim'^@
Vimwiki: Processing /media/vimwiki/Vim.md
Traceback (most recent call last):^@  File "/usr/bin/vimwiki_markdown", line 5, in <module>^@    from vimwiki_markdo
wn import main^@  File "/usr/lib/python3.8/site-packages/vimwiki_markdown.py", line 32, in <module>^@    with subpro
cess.Popen(^@  File "/usr/lib/python3.8/subprocess.py", line 854, in __init__^@    self._execute_child(args, executa
ble, preexec_fn, close_fds,^@  File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child^@    raise chil
d_exception_type(errno_num, err_msg, err_filename)^@FileNotFoundError: [Errno 2] No such file or directory: 'vim'^@
Vimwiki: Processing /media/vimwiki/index.md
Traceback (most recent call last):^@  File "/usr/bin/vimwiki_markdown", line 5, in <module>^@    from vimwiki_markdo
wn import main^@  File "/usr/lib/python3.8/site-packages/vimwiki_markdown.py", line 32, in <module>^@    with subpro
cess.Popen(^@  File "/usr/lib/python3.8/subprocess.py", line 854, in __init__^@    self._execute_child(args, executa
ble, preexec_fn, close_fds,^@  File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child^@    raise chil
d_exception_type(errno_num, err_msg, err_filename)^@FileNotFoundError: [Errno 2] No such file or directory: 'vim'^@
Vimwiki: HTML exported to /media/vimwiki/site_html/
Vimwiki: Done!

I use neovim - maybe that's the problem?

Turn off "pygment"?

The pygment integration does not play well with my js for generating line numbers in code, among other things.

If I remove the %pygments% tag from the template it seems to have problems. Is there a way to turn this feature off?

image links?

Hello, i am trying to convert my markdown vim wiki with this script, but it does not support image links?

i tried syntax
Inline link: >

  [Looks like this](URL)

Image link: >

![Looks like this](URL)

for jpg files
first made links to image.jpg.html

second skipped link at all.

can you help me in some way?

thx

Convert vimwiki automatic links to Markdown syntax

If I use :VimwikiGenerateLinks, it creates a bunch of links like this:

- [[foo]]
- [[bar]]

As far as I can see, there's not a way to get vimwiki to generate markdown-formatted links. Is that something that this script could handle gracefully?

VimWiki link not supported in HTML conversion

I'm not sure if this is a bug or just a non-supported feature.

I am organizing my VimWiki using built-in VimWiki links using double brackets (i.e. [[index.md]]). However, it doesn't seem to work.

For example, I have the following:
image
which converts to the following:
image

Not sure if this is intended, but it would be nice if the conversion handled this and automatically links to the target file/webpage. This would allow creating the main HTML page that can be navigated to other subpages - much like how a website is actually stuctured.

A workaround that I found is replacing the wiki link with the absolute path of the target file using the markdown link syntax, such as [swift](~/vimwiki/swift/index.md). This will create a hyperlink in the HTML file and allow navigation between files in your system.

Not sure if this is a necessary feature, but just thought it might be interesting to be able to link to other HTML files in your system. :)

Can't get latex formula to display on html file

I'm able to get latex formula using the vimwiki syntax, but when I use vimwiki_markdown and markdown syntax the equations don not show up. Is it possible to get them using this converter?

Conversion to HTML is not supported for markdown

Hi, I'm started using vimwiki recently
I have an issue with with converting markdown code to HTML using :Vimwiki2HTML

  • I had install vimwiki_markdown library with pip using

    python3 -m pip install vimwiki-markdown
    
  • checked :checkhealth provider.python gives

    Python 3 provider (optional) ~
    - Using: g:python3_host_prog = "/usr/bin/python3"
    - Executable: /usr/bin/python3
    - Python version: 3.10.12
    - pynvim version: 0.5.0
    - OK Latest pynvim is installed.
    
    Python virtualenv ~
    - OK no $VIRTUAL_ENV
    
  • and my vimwiki config:

    return {
        'vimwiki/vimwiki',
        dependencies ={
            'mattn/calendar-vim'
        },
        init = function()
            vim.g.vimwiki_list = {
                {
                    path = '~/vimwiki',
                    template_path = '~/vimwiki/templates/',
                    template_default = 'default',
                    syntax = 'markdown',
                    ext = '.md',
                    path_html = '~/vimwiki/site_html/',
                    custom_wiki2html = 'vimwiki_markdown',
                    template_ext = '.tpl'
                }
            }
        end
    }

And still I'm getting a conversion to HTML is not supported error
guide me in solving this issue

'\' before special characters in math mode go missing

Somehow the conversion misses backslashes \ that are in front of other special characters, like e.g. \ or { when in math mode. This means that things
like new lines \\ or \left\{ don't work in math mode.

Expected behaviour

A lot of text

$$
\begin{aligned}
H &= A \\
   &= \left\{B \right\}
\end{aligned}
$$

more text

gets converted to

<p>A lot of text </p>
<p>$$
\begin{aligned}
H &= A \\
   &= \left\{B \right\}
\end{aligned}
$$</p>
<p>more text </p>

Actual behaviour

It gets converted to

<p>A lot of text </p>
<p>$$
\begin{aligned}
H &= A \
   &= \left{B \right}
\end{aligned}
$$</p>

<p>more text </p>

"Conversion to HTML is not supported" when setting new paths

I have no problem to run Vimwiki2HTML with vimiwiki_markdown with this configuration:

set nocompatible
filetype plugin on
let g:vimwiki_list = [{
                        \ 'path':'~/git/wiki',
                        \ 'path_html':'~/git/wiki/html/', 
                        \ 'syntax': 'markdown', 
                        \ 'ext': '.md', 
                        \ 'custom_wiki2html': 'vimwiki_markdown', 
                        \ 'template_ext': '.tpl'}]

I've figured out this could be a faster way to write simple entries for a blog, so I'm trying to setup a command to change the default paths temporarily using this:

let blogmode = [{
                        \ 'path':'~/git/blog/md/',
                        \ 'path_html':'~/git/blog/html/',
                        \ 'syntax': 'markdown',
                        \ 'ext': '.md',
                        \ 'custom_wiki2html': 'vimwiki_markdown',
                        \ 'template_ext': '.tpl'}]
autocmd FileType markdown map <leader>bm :w<CR>:let g:vimwiki_list = blogmode<CR>:echo "Blog mode"<CR>

But unfortunately, I keep receiving the message "Vimwiki Error: Conversion to HTML is not supported for this syntax".
Am I doing something wrong?

Support For linenums for CodeHilite

line number can be enabled by passing linenums to codehilite

Codehilite(linenums=True)

If i want to raise PR which approach is advised.

  1. create VIMWIKIMARKDOWN_LINENUMS for passing this arguement
  2. parse VIMWIKIMARKDOWN_EXTENSION using ast.literal_eval and then add default plugins if they are not available

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.