patrickdavey / vimwiki_markdown Goto Github PK
View Code? Open in Web Editor NEWA gem to use for converting vimwiki markdown files to html.
License: MIT License
A gem to use for converting vimwiki markdown files to html.
License: MIT License
Directory links are not processed accurately.
For example,
[anchor-text](directory/)
creates a link to directory.html
instead of a link to one of the following:
directory/
directory/index.html
.I think the second form is better since some browsers show a directory listing when pointed to a local directory root.
Thanks for this, it makes Vimwiki irresistible.
So I think I put everything all together:
init.vim
let g:vimwiki_list = [{
\ 'path': '$HOME/Documents/PersonalWiki',
\ 'syntax': 'markdown', 'ext': '.md',
\ 'custom_wiki2html': 'vimwiki_markdown',
\ 'template_path': '$HOME/Documents/PersonalWiki/templates',
\ 'template_default': 'default',
\ 'template_ext': '.tpl'}]
default.tpl
<!DOCTYPE html>
<html>
<head>
<link rel="Stylesheet" type="text/css" href="%root_path%%css%">
<title>%title%</title>
<meta http-equiv="Content-Type" content="text/html; charset=%encoding%">
%pygments%
</head>
<body>
<script type="text/javascript" src="../PersonalWiki/templates/MathJax-2.7.0/MathJax.js?config=TeX
AMS-MML_HTMLorMML"></script>
%content%
</body>
</html>
The gem is installed without problems but yet I have an error which says that a conversion from markdown to HTML is not supported.
I'm on High Sierra 10.13.2
Ruby:
$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]
Gem:
$ gem -v
2.5.2
When I do gem install vimwiki_markdown
I get errors with the following output. Any ideas?
$ sudo gem install vimwiki_markdown
Password:
Fetching: concurrent-ruby-1.0.5.gem (100%)
Successfully installed concurrent-ruby-1.0.5
Fetching: i18n-0.9.1.gem (100%)
Successfully installed i18n-0.9.1
Fetching: thread_safe-0.3.6.gem (100%)
Successfully installed thread_safe-0.3.6
Fetching: tzinfo-1.2.4.gem (100%)
Successfully installed tzinfo-1.2.4
Fetching: activesupport-4.1.16.gem (100%)
Successfully installed activesupport-4.1.16
Fetching: github-markup-1.3.3.gem (100%)
Successfully installed github-markup-1.3.3
Fetching: github-markdown-0.6.9.gem (100%)
Building native extensions. This could take a while...
Successfully installed github-markdown-0.6.9
Fetching: charlock_holmes-0.7.5.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing vimwiki_markdown:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.3.0/gems/charlock_holmes-0.7.5/ext/charlock_holmes
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20180120-17096-1v236w1.rb extconf.rb
checking for main() in -licui18n... no
checking for main() in -licui18n... yes
checking for unicode/ucnv.h... yes
checking for main() in -lz... yes
checking for main() in -licuuc... yes
checking for main() in -licudata... yes
creating Makefile
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/charlock_holmes-0.7.5/mkmf.log
current directory: /Library/Ruby/Gems/2.3.0/gems/charlock_holmes-0.7.5/ext/charlock_holmes
make "DESTDIR=" clean
current directory: /Library/Ruby/Gems/2.3.0/gems/charlock_holmes-0.7.5/ext/charlock_holmes
make "DESTDIR="
compiling ext.c
compiling encoding_detector.c
compiling converter.c
compiling transliterator.cpp
In file included from transliterator.cpp:1:
In file included from ./common.h:9:
In file included from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby.h:33:
In file included from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/ruby.h:24:
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin17/ruby/config.h:368:31: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]
#define RUBY_ARCH "universal-"RUBY_PLATFORM_OS
^
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin17/ruby/config.h:369:35: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]
#define RUBY_PLATFORM "universal."RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS
^
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin17/ruby/config.h:369:55: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]
#define RUBY_PLATFORM "universal."RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS
^
3 errors generated.
make: *** [transliterator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/charlock_holmes-0.7.5 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/charlock_holmes-0.7.5/gem_make.out
adding the line
%template index
to one of my files does not cause the template index.tpl to be used when generating the HTML for that page. Am I doing something wrong, or is this feature not implemented yet?
When I run
sudo gem install vimwiki_markdown
this is the following error that I get:
Building native extensions. This could take a while...
ERROR: Error installing vimwiki_markdown:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.7.0/gems/commonmarker-0.22.0/ext/commonmarker
/usr/bin/ruby2.7 -I /usr/lib/ruby/2.7.0 -r ./siteconf20210818-14573-1dygqb5.rb extconf.rb
creating Makefile
current directory: /var/lib/gems/2.7.0/gems/commonmarker-0.22.0/ext/commonmarker
make "DESTDIR=" clean
current directory: /var/lib/gems/2.7.0/gems/commonmarker-0.22.0/ext/commonmarker
make "DESTDIR="
compiling arena.c
arena.c:1:10: fatal error: stdlib.h: No such file or directory
1 | #include <stdlib.h>
| ^~~~~~~~~~
compilation terminated.
make: *** [Makefile:245: arena.o] Error 1
make failed, exit code 2
Gem files will remain installed in /var/lib/gems/2.7.0/gems/commonmarker-0.22.0 for inspection.
Results logged to /var/lib/gems/2.7.0/extensions/x86_64-linux/2.7.0/commonmarker-0.22.0/gem_make.out
What's going on? I have latest ruby
and vimwiki
installed. I am using vim-nox
.
When file contains danish letters æøå the conversion won't happen.
To reproduce:
1. ø
Vimwiki: '/home/chris/.local/share/gem/ruby/3.1.0/gems/vimwiki_markdown-0.8.2/lib/vimwiki_markdown/wiki_body.rb:52:in `gsub!'': invalid byte sequence in US-ASC
II (ArgumentError)
from /home/chris/.local/share/gem/ruby/3.1.0/gems/vimwiki_markdown-0.8.2/lib/vimwiki_markdown/wiki_body.rb:52:in `convert_wiki_style_links_with_title_b
ar!''
from /home/chris/.local/share/gem/ruby/3.1.0/gems/vimwiki_markdown-0.8.2/lib/vimwiki_markdown/wiki_body.rb:45:in `fixlinks''
from /home/chris/.local/share/gem/ruby/3.1.0/gems/vimwiki_markdown-0.8.2/lib/vimwiki_markdown/wiki_body.rb:18:in `to_s''
from /home/chris/.local/share/gem/ruby/3.1.0/gems/vimwiki_markdown-0.8.2/lib/vimwiki_markdown.rb:16:in `convert_wikimarkdown_to_html''
from /home/chris/.local/share/gem/ruby/3.1.0/gems/vimwiki_markdown-0.8.2/bin/vimwiki_markdown:4:in `<top (required)>''
from /home/chris/.local/share/gem/ruby/3.1.0/bin/vimwiki_markdown:25:in `load''
from /home/chris/.local/share/gem/ruby/3.1.0/bin/vimwiki_markdown:25:in `<main>''
'
Vimwiki: HTML conversion is done, output: /home/chris/life/site_html/
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',
\ 'html_filename_parameterization': 1,
\ 'template_ext': '.tpl'}]
and
gem install vimwiki_markdown
running on lunarvim (layer on top of neovim 0.5).
VimwikiDiaryGenerateLinks
creates links in the diary index as [SomeDiaryEntry][SomeDiaryDate.md]
. When I subsequently run Vimwiki2HTML
on diary.md
, the link in diary.html
points to SomeDiaryDate.md.html
instead of SomeDiaryDate.html
as expected. This results in a broken link since only SomeDiaryDate.html
exists.
If I manually remove the .md
from the link in the diary index markdown file (i.e. [SomeDiaryDate.md]
becomes [SomeDiaryDate]
, then everything works as expected. But I don't believe vimwiki is in error here by including the .md
extension at the end of the generated link.
I've been adding css to my default.tpl template to render the html pages in a darker scheme that's easier on the eyes. Unfortunately I have not been able to figure out how to make the pygments code dark.
Would it be possible to use different styles for the pygments?
Thanks
Hey! First of all, thanks for your hard work on this plugin, I'm a novice user of vimwiki and allowing people to use markdown is pretty cool.
However I'm running into an issue. In my vimrc
I'm importing your fork of the plugin like this:
Plug 'patrickdavey/vimwiki-1', { 'branch': 'dev' }
Then, I set up my wiki with the following parameters:
" vimwiki
let g:vimwiki_conceallevel = 0
let g:vimwiki_folding='expr' "this allows the folding to work for markdown
let g:vimwiki_list = [{
\ 'nested_syntaxes': {
\ 'javascript': 'javascript',
\ 'bash': 'sh',
\ 'vim': 'vim',
\ },
\ 'template_default': 'default',
\ 'syntax': 'markdown',
\ 'ext': '.md',
\ 'path': '~/vimwiki/',
\ 'template_path': '~/vimwiki/templates/',
\ 'path_html': '~/vimwiki/site_html/',
\ 'custom_wiki2html': 'vimwiki_markdown',
\ 'template_ext': '.tpl',
\ }]
In my markdown files, I'm setting up links such as these:
# (Neo)vim
Snippets, tips and tricks gathered here and there.
- [Pretty print JSON](Pretty print JSON)
- [Why is pasting long strings slow?](Why is pasting long strings slow?)
When I call :VimwikiAll2HTML
, it generates all the HTML correctly. It renames the links as expected (e.g. pretty-print-json.html
and why-is-pasting-long-strings-slow.html
.
However, it doesn't appear to be renaming the HTML files themselves. I end up with Pretty print JSON.html
and Why is pasting long strings slow?.html
and, therefore, broken links in the index page.
Am I missing something in the configuration? I installed the gem without issues and the extension seems to be working fine otherwise. Apologies if I'm missing something completely obvious. Let me know if you need anything else to help uncover the culprit.
The tags functionality has been removed in 6852e83 originally implemented in #11
There was an issue I couldn't quickly work around when upgrading to the latest github/markup gem. Also, it didn't play nicely with custom extensions (now implemented) nor with [[wiki links with multiple words in them]]. I've now added covering specs for some of that, and, I think perhaps the functionality can be reimplemented without requiring actually needing to change the links themselves. That is, we can still leave those paramaterized (so they're valid markdown links), but, still put in a custom title.
Well, maybe anyway ;)
If anyone wants to take a shot, esp @KTSCode go for it, otherwise I'll try to get to it sometime.
Even when using rvm, I was unable to install the gem due to an issue installing rugged. It seems that this is an upstream issue -- I found another project that has the same problem (sonic-pi-net/sonic-pi#1908).
To get around this, I used rvm to install Ruby 2.3.3, and everything seems to work. For anyone like me who is unfamiliar with Ruby, I used
rvm install 2.3.3
rvm ruby-2.3.3 do gem install vimwiki_markdown
You probably also need to make 2.3.3 your default. I just removed all other versions of Ruby instead.
Scenario: Links are placed beside each other
When inks are placed beside each other... the last link (done.md) gets converted to a file with .html extension (done.html) while all other files 1backlog.md, 2todo.md, 3doing.md gets converted to html files but their URLS don't
Markdown:
[1backlog](1backlog) [2todo](2todo) [3doing](3doing) [4done](4done)
HTML Result:
<p><a href="1backlog">1backlog</a> <a href="2todo">2todo</a> <a href="3doing">3doing</a> <a href="4done.html">4done</a> </p>
However...
Scenario: Links are listed with one link per line, the conversion works.
Markdown:
- [1backlog](1backlog)
- [2todo](2todo)
- [3doing](3doing)
- [4done](4done)
HTML Result:
<ul>
<li> <a href="1backlog.html">1backlog</a> </li>
<li> <a href="2todo.html">2todo</a><br> </li>
<li> <a href="3doing.html">3doing</a> </li>
<li> <a href="4done.html">4done</a> </li>
</ul>
https://github.blog/2022-02-14-include-diagrams-markdown-files-mermaid/
Not sure what's involved here. If anyone wants to take a look - great ;)
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
I'm totally newbie to vimwiki, probably I did something wrong :-(
I run Vim 8.2 and vimwiki on Windows 10,
I have a few *md file in my first vimwiki:
c:\Users\RO\vimwiki>ls -l
-rw-rw-r-- 1 RO RO 12 Nov 06 20:57 Tasks.md
-rw-rw-r-- 1 RO RO 1716 Nov 09 20:31 VimWiki.md
-rw-rw-r-- 1 RO RO 306 Nov 08 17:17 Zkratky.md
-rw-rw-r-- 1 RO RO 2084 Nov 09 20:52 index.md
drwxrwxr-x 2 RO RO 0 Nov 09 20:20 site_html
drwxrwxr-x 2 RO RO 0 Nov 09 20:14 templates
c:\Users\RO\vimwiki>ls -l templates
-rw-rw-r-- 1 RO RO 4001 Nov 09 20:14 default.tpl
====================
from my .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',
\ 'html_filename_parameterization': 1,
\ 'template_ext': '.tpl'}]
====================
When I run Vimwiki2HTML for currently open wiki file I get this
Any suggestion?
I routinely use HTML in my wikis (to embed YouTube videos, canvases, etc.).
Unfortunately it gets replaced by the string <!-- raw HTML omitted -->
.
As far as I can tell this can be adjusted by passing the UNSAFE
option to commonmarker (but I'm not sure how to accomplish that).
Would it be possible to allow html tags by default or add an option for that?
Detail please see libgit2/libgit2#4336 and it's already fixed at last year libgit2/libgit2/pull/4339.
The dependency need to update or using another way to install vimiwki_markdown.
I am getting this error when I run sudo gem install vimwiki_markdown
. I don't understand any of this error message. Help would be appreciated.
Building native extensions. This could take a while...
ERROR: Error installing vimwiki_markdown:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.7.0/gems/commonmarker-0.21.2/ext/commonmarker
/usr/bin/ruby2.7 -I /usr/lib/ruby/2.7.0 -r ./siteconf20210416-43753-110lyl4.rb extconf.rb
creating Makefile
current directory: /var/lib/gems/2.7.0/gems/commonmarker-0.21.2/ext/commonmarker
make "DESTDIR=" clean
current directory: /var/lib/gems/2.7.0/gems/commonmarker-0.21.2/ext/commonmarker
make "DESTDIR="
compiling arena.c
arena.c:1:10: fatal error: stdlib.h: No such file or directory
1 | #include <stdlib.h>
| ^~~~~~~~~~
compilation terminated.
make: *** [Makefile:245: arena.o] Error 1
make failed, exit code 2
Gem files will remain installed in /var/lib/gems/2.7.0/gems/commonmarker-0.21.2 for inspection.
Results logged to /var/lib/gems/2.7.0/extensions/x86_64-linux/2.7.0/commonmarker-0.21.2/gem_make.out
This is the message I get when search for vimwiki_markdown
in my computer: searching for vimwiki_markdown.
I just tumbled across your project and really like it to quickly render markdown files of the vimwiki format to html.
For some reason any relative path to a file will be relative within the html_path
instead of pointing to the vimwiki path
where the actual image is.
Example:
I want to embed foo.gif
which is in the same folder as bar.wiki
.
With vimwiki's syntax I'd do
{{foo.gif}}
which results in
<img src="../../foo.gif" alt="foo_alt_text">
for html_path/bar.html
when converting to html. Perfect.
With markdown's syntax
![foo_alt_text][foo.gif]
![foo_alt_text2][file:foo.gif]
![foo_alt_text3][file:/abs/path/to/foo.gif]
the relative path's are not adjusted, as the result in html_path/bar.html
will simply be
<img src="foo.gif" alt="foo_alt_text">
Am I missing a point, or are relative paths not supported. Is it something from the side of Vimwiki? Besides, I have a workaround to use symbolic links to a dedicated images folder which works, but the behavior was not as expected.
It will not works when the filename of the Markdown file being converted is in Chinese, I spent some time digging into the source code, and found the parameterize
function which is called in output_fullpath
returns empty string when the object string is in Chinese. I am not familiar with Ruby, so my dirty solution is removing the parameterize
function call, but I don't think it is a perfect solution.
Hi,
This might be more a request for clarification, as it might as well be that I'm just using this gem wrong:
I just stumbled upon this after tweaking with vimwiki for a couple of weeks. I was using Gollum until now with fairly good results, but there's no support for table of contents there, which is a bummer.
I'm uncertain if there's such support here, but I do see in the changelog that there has been work done in that direction. However, with a vanilla configuration just as the one stated in the README.md I see my markdown links for the TOC as plain text. Is this expected?
Also, as the syntax used for the markdown is the GitHub enriched, I was also expecting the checkboxes to be rendered, but that is not the case. Is it also expected or am I missing a configuration step?
Thanks!
Hello, and sorry for the pesky question, but I noticed the title, %title%
in the template, is generated from the url. Any way to change this? Maybe by passing different arguments to the script?
a) Say I have two markdown files, first.md
, second.md
, and first.md
refers to the other inside it. Now I run :Vimwiki2HTML
on the first one to create first.html
neither does it automatically create second.html
nor it shows any prompt to convert the second one simultaneously.
b) Now if I convert both of them using :Vimwiki2HTML
, and open first.html
and click on the link of the second file, it shows file doesn't exist
. Cause inside first.html
second file is linked as path_html/second
not as path_html/second.html
Shouldn't first.html
, second.html
be linked together? How to make the work?
Say I have a markdown file like the following:
---
title: NewFile
created: 18/09/2020 15:13:58 IST
theme: Copenhagen
---
# Header
Some text
.
.
.
_End of file_
After convertion, resulting file looks like the following:
Some text
.
.
.
End of file
How do I get the file to look like this:
Some text
.
.
.
End of file
This is how pandoc
converts it. I couldn't get it done even after fiddling with default.tpl
long enough. I don't know much html. Any help will be appreciated.
If I comment a line in markdown like this:
%% a comment
after conversion it is displayed in html like %% a comment
. Comments in markdown should remain comments in html. How to get that? Am I doing anything wrong?
Thanks for this module.
Once the ruby script does its thing, I'd like to process the text some more. For example, I wish to convert hyperlinks to a youtube video to youtube's embed code. Is there some kind of hook or other method for doing this kind of thing?
Does this work with formulas?
Thinking about it, making either a separate binary, or at least an option to allow users to simply say "generate the static site for me" would be a better way to go. It could optionally plug into vimwikiAllToHTML
but that would require a code change on vimwiki's side.
Just need to pass a config of the template, site_dir, and then assume ? that any markdown files which are in the wiki directory should be turned into html files.
Really is the cleanest way of doing things I think.
I'm going to use js for syntax highlighting. There's no easy way to disable pygments?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.