├── .github
└── workflows
│ └── ci.yml
├── .gitignore
├── .hound.yml
├── .rspec
├── .rubocop.yml
├── A.png
├── B.png
├── Gemfile
├── Guardfile
├── LICENSE.txt
├── README.md
├── Rakefile
├── bin
└── vimwiki_markdown
├── changelog.md
├── example_files
└── default.tpl
├── lib
├── vimwiki_markdown.rb
└── vimwiki_markdown
│ ├── exceptions.rb
│ ├── options.rb
│ ├── template.rb
│ ├── version.rb
│ ├── vimwiki_link.rb
│ ├── vimwiki_toc_filter.rb
│ └── wiki_body.rb
├── spec
├── lib
│ └── vimwiki_markdown
│ │ ├── options_spec.rb
│ │ ├── template_spec.rb
│ │ ├── vimwiki_link_spec.rb
│ │ └── wiki_body_spec.rb
└── spec_helper.rb
└── vimwiki_markdown.gemspec
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: CI
3 |
4 | on:
5 | pull_request:
6 | branches:
7 | - '*'
8 | push:
9 | branches:
10 | - master
11 | jobs:
12 | # SQLITE
13 | testrunner:
14 | runs-on: ubuntu-latest
15 | strategy:
16 | matrix:
17 | ruby: ['2.7', '3.0', '3.1']
18 |
19 | steps:
20 | - uses: actions/checkout@v2
21 | - name: Set up Ruby ${{ matrix.ruby }}
22 | uses: ruby/setup-ruby@v1
23 | with:
24 | ruby-version: ${{ matrix.ruby }}
25 | bundler-cache: true
26 |
27 | - name: Run tests
28 | run: |
29 | bundle exec rspec spec
30 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | .bundle
4 | .config
5 | .yardoc
6 | Gemfile.lock
7 | InstalledFiles
8 | _yardoc
9 | coverage
10 | doc/
11 | lib/bundler/man
12 | pkg
13 | rdoc
14 | spec/reports
15 | test/tmp
16 | test/version_tmp
17 | tmp
18 | *.bundle
19 | *.so
20 | *.o
21 | *.a
22 | mkmf.log
23 |
--------------------------------------------------------------------------------
/.hound.yml:
--------------------------------------------------------------------------------
1 | ruby:
2 | config_file: .rubocop.yml
3 |
--------------------------------------------------------------------------------
/.rspec:
--------------------------------------------------------------------------------
1 | --color
2 | --require spec_helper
3 |
--------------------------------------------------------------------------------
/.rubocop.yml:
--------------------------------------------------------------------------------
1 | AllCops:
2 | TargetRubyVersion: 2.3
3 |
4 | Style/StringLiterals:
5 | EnforcedStyle: double_quotes
6 |
7 | Style/DoubleNegation:
8 | Enabled: false
9 |
10 | Style/AndOr:
11 | EnforcedStyle: conditionals
12 |
13 | Style/SymbolArray:
14 | Enabled: false
15 |
16 | Style/SafeNavigation:
17 | Enabled: false
18 |
19 | Layout/HeredocIndentation:
20 | Enabled: false
21 |
22 | Layout/FirstParameterIndentation:
23 | EnforcedStyle: consistent
24 |
25 | Layout/EmptyLines:
26 | Enabled: false
27 |
28 | Style/NumericLiterals:
29 | Enabled: false
30 |
31 | Style/FrozenStringLiteralComment:
32 | Enabled: false
33 |
34 | Style/RaiseArgs:
35 | EnforcedStyle: compact
36 |
37 | Documentation:
38 | Enabled: false
39 |
40 | Metrics/LineLength:
41 | Exclude:
42 | - spec/**/*
43 | Max: 120
44 |
45 | Metrics/BlockLength:
46 | Exclude:
47 | - 'Rakefile'
48 | - 'spec/**/*.rb'
49 |
50 | Lint/AmbiguousBlockAssociation:
51 | Exclude:
52 | - "spec/**/*"
53 |
54 | Layout/MultilineMethodCallIndentation:
55 | Enabled: true
56 | EnforcedStyle: indented
57 | SupportedStyles:
58 | - aligned
59 | - indented
60 |
61 | Metrics/AbcSize:
62 | Enabled: true
63 | Max: 20
64 |
65 | Metrics/MethodLength:
66 | Enabled: true
67 | CountComments: false
68 | Max: 20
69 | Exclude:
70 | - "spec/**/*"
71 |
72 |
--------------------------------------------------------------------------------
/A.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickdavey/vimwiki_markdown/cd15e729489cc20cb1344c51a3a6e050b6a238c4/A.png
--------------------------------------------------------------------------------
/B.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/patrickdavey/vimwiki_markdown/cd15e729489cc20cb1344c51a3a6e050b6a238c4/B.png
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | # Specify your gem's dependencies in vimwiki_markdown.gemspec
4 | gemspec
5 |
--------------------------------------------------------------------------------
/Guardfile:
--------------------------------------------------------------------------------
1 | guard :rspec, cmd: 'bundle exec rspec' do
2 | watch(%r{^spec/.+_spec\.rb$})
3 | watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4 | watch('spec/spec_helper.rb') { "spec" }
5 | end
6 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014 Patrick Davey
2 |
3 | MIT License
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining
6 | a copy of this software and associated documentation files (the
7 | "Software"), to deal in the Software without restriction, including
8 | without limitation the rights to use, copy, modify, merge, publish,
9 | distribute, sublicense, and/or sell copies of the Software, and to
10 | permit persons to whom the Software is furnished to do so, subject to
11 | the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # VimwikiMarkdown
2 | [](https://codeclimate.com/github/patrickdavey/vimwiki_markdown) [](https://github.com/patrickdavey/vimwiki_markdown/actions/workflows/ci.yml)
3 |
4 | This gem allows vimwiki pages written in (github enhanced) markdown
5 | to be converted to HTML.
6 |
7 | It is currently a work in progress (but working for me ;)
8 |
9 | ## Example
10 | It turns this:
11 |
12 | 
13 |
14 | into
15 |
16 | 
17 |
18 | ## Requirements
19 |
20 | Ruby installed on your computer & up to date version of vimwiki
21 |
22 | https://www.ruby-lang.org/en/installation/
23 |
24 | Install the vimwiki_markdown gem
25 |
26 | $ gem install vimwiki_markdown
27 |
28 | ## Setup
29 |
30 | vimwiki_markdown works best with a recent version of [vimwiki](https://github.com/vimwiki/vimwiki). Use the `dev` branch for best results.
31 |
32 | Ensure that your vimiwiki directive in your .vimrc is setup for markdown. For
33 | this we use the custom_wiki2html parameter. My .vimrc looks like this:
34 |
35 | let g:vimwiki_list = [{'path': '~/vimwiki', 'template_path': '~/vimwiki/templates/',
36 | \ 'template_default': 'default', 'syntax': 'markdown', 'ext': '.md',
37 | \ 'path_html': '~/vimwiki/site_html/', 'custom_wiki2html': 'vimwiki_markdown',
38 | \ 'html_filename_parameterization': 1,
39 | \ 'template_ext': '.tpl'}]
40 |
41 | The most important parts are the *'custom_wiki2html': 'vimwiki_markdown'* and the *'html_filename_parameterization': 1*. The custom_wiki2html tells vimwiki to use this gem for creating html, the html_filename_parameterization tells vimwiki to match the filenames that vimwiki_markdown produces.
42 |
43 | ### Install issues.
44 | There have been some issues with getting dependencies installed. Before opening an issue, please check if you can use [rvm](http://rvm.io/) to install the gem, as RVM is magic and makes everything work ;)
45 |
46 | ### VimWiki Template
47 |
48 | It is a requirement that your template file contain a placeholder
49 | for the syntax highlighting code to be placed. In order to do this,
50 | open up your default.tpl (or whatever your template file is called)
51 | and ensure that before the closing tag you put
52 | `%pygments%`. You also have the option to put `%dark_pygments%` if you want to have "dark mode" syntax highlighting.
53 |
54 | A sample tpl file is available here https://raw.githubusercontent.com/patrickdavey/vimwiki_markdown/master/example_files/default.tpl
55 |
56 | #### Optional %root_html% marker.
57 |
58 | You can also have a `%root_html%` marker in your template file, thanks
59 | to [this commit](https://github.com/patrickdavey/vimwiki_markdown/commit/8645883b96df9962aba616d0d12961285cd3f4d7).
60 | It will get rewritten with the relative path to the root
61 | of the site (e.g. `./` or `../../` etc)
62 |
63 | #### Optional %date% marker.
64 |
65 | You can also have a `%date%` marker in your template file
66 | It will get rewritten with todays date in the format 29 March 2019
67 |
68 | #### Support for tasklists
69 | Vimwiki has support for complex todo lists which you can [read about in their help.txt](https://github.com/vimwiki/vimwiki/blob/619f04f89861c58e5a6415a4f83847752928252d/doc/vimwiki.txt#L1768). We do support turning them into HTML. This is _slightly different_ from the way that GitHub checklists are rendered, but, the syntax is a subset of GitHub lists so it should be fine. You can read about it in the [issue](https://github.com/patrickdavey/vimwiki_markdown/issues/27), but basically it should work fine. You will want to add `styles` in for the various states that the todo lists can be in. The easiest way is to simply add the `styles` into your template. You can see the styles [in the sample template here](https://github.com/patrickdavey/vimwiki_markdown/blob/293f99e656819b9c5ecc0c831698ce58904eb774/example_files/default.tpl#L7-L45)
70 |
71 | #### Support for :local and :file links
72 |
73 | We have partial support for the `:local` and `:file` link types for vimwiki.
74 | If you are editing `foo.md` (in the root dir of your wiki) and you are linking to `bar.txt` stored in the same directory as `foo.md` you can do:
75 |
76 | * `[link text](local:bar.txt)` when output to HTML becomes `link text`
77 | * `[link text](file:bar.txt)` when output to HTML becomes `link text`
78 |
79 | #### Optional %nohtml
80 |
81 | If you place the text %nohtml anywhere in a wiki page, it will not be processed into html
82 |
83 | ## Contributing
84 |
85 | Pull requests are very welcome
86 |
87 | 1. Fork it ( https://github.com/patrickdavey/vimwiki_markdown/fork )
88 | 2. Create your feature branch (`git checkout -b my-new-feature`)
89 | 3. Commit your changes (`git commit -am 'Add some feature'`)
90 | 4. Push to the branch (`git push origin my-new-feature`)
91 | 5. Create a new Pull Request
92 |
93 | ## License
94 |
95 | [MIT License](http://opensource.org/licenses/mit-license.php)
96 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | require 'rspec/core/rake_task'
2 | require 'bundler/gem_tasks'
3 |
4 | # Default directory to look in is `/specs`
5 | # Run with `rake spec`
6 | RSpec::Core::RakeTask.new(:spec) do |task|
7 | task.rspec_opts = ['--color', '--format', 'documentation']
8 | end
9 |
10 | task :default => :spec
11 |
12 |
--------------------------------------------------------------------------------
/bin/vimwiki_markdown:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'vimwiki_markdown'
3 |
4 | if ARGV.include?("--version") || ARGV.include?("-v")
5 | puts "vimwiki_markdown #{VimwikiMarkdown::VERSION}"
6 | exit 0
7 | else
8 | VimwikiMarkdown.convert_wikimarkdown_to_html
9 | end
10 |
11 |
--------------------------------------------------------------------------------
/changelog.md:
--------------------------------------------------------------------------------
1 | ## 0.9.3 [08 Feb 2025]
2 | Add a --version flag to the command line tool
3 |
4 | ## 0.9.2 [02 April 2023]
5 | Just bump activesupport version for security advisories
6 |
7 | ## 0.9.1 [02 April 2023]
8 | Bugfix that both pygments and dark_pygments placeholers were required.
9 |
10 | ## 0.9.0 [02 April 2023]
11 | Add support for dark mode. Drop support for ruby < 2.7
12 |
13 | ## 0.8.2 [22 June 2022]
14 | Remove deprecation warning for EscapeUtils.escape_html
15 | see https://github.com/patrickdavey/vimwiki_markdown/pull/43
16 |
17 | ## 0.8.1 [March 7 2022]
18 | Update commonmarker version, fixes security issue!
19 |
20 | ## 0.8.0 [March 7 2022]
21 | Fixes an issue where VimwikiTOC generated table of contents where there are duplicate heading names did not match the output HTML from the Github pipeline.
22 |
23 | This means any generated (dupliate) bookmarks are going to be broken though, so, this is backwardly incompatible
24 |
25 | see https://github.com/patrickdavey/vimwiki_markdown/pull/39
26 |
27 | ## 0.7.0 [July 8 2021]
28 | Fixes an issue whereby non english filenames were being replaced with empty strings
29 | see https://github.com/patrickdavey/vimwiki_markdown/pull/35
30 |
31 | ## 0.6.0 [April 26 2020]
32 | Support for todo lists with enhanced state options. Thanks to @primercuervo
33 |
34 | ## 0.5.0 [April 26 2020]
35 | Partial support for `local` and `file` links in urls. Thanks to @tfachmann for the PR
36 |
37 | ## 0.4.4 [June 16 2019]
38 | Allow fragments if they are for local vimwiki links only
39 |
40 | ## 0.4.3 [June 16 2019]
41 | temporarily revoke fragments until we're not altering old links
42 |
43 | ## 0.4.2 [June 16 2019]
44 | Allow "fragments" in markdown style links such as those generated by :VimwikiTOC or or when using a diary_caption_level.
45 | Thanks to @djeremiah - see https://github.com/patrickdavey/vimwiki_markdown/pull/23
46 |
47 | ## 0.4.1 [June 16 2019]
48 | Allow "unsafe" HTML tags in markdown content (iframe etc.)
49 |
50 | ## 0.4.0 [June 16 2019]
51 | Support HTML tags in markdown content again.
52 |
53 | ## 0.3.3 [March 29 2019]
54 | Support for %date% and %nohtml tags
55 | Add information about html_filename_parameterization.
56 |
57 | ## 0.3.2 [March 28 2019]
58 |
59 | Bugfix
60 |
61 | Files were changed to be written out using their actual filename, rather than the
62 | parameterized version, this is fixed now.
63 |
64 | ## 0.3.1 [March 10 2019]
65 | Adds the ability to strip the extension correctly from vimwiki files.
66 | For example, the file index.wiki was converted to index.wiki.html.
67 |
68 | Thanks to @bowmanat for the PR.
69 |
70 | This may also very likely break existing links, so, watch out there ;)
71 |
72 | ## 0.3.0 [March 10 2019]
73 | Rebuilds vimwiki_markdown against the latest versions of Github/Markup etc.
74 |
75 | The tools are somewhat different and so it's quite possible there will be breaking changes here, especially if
76 | you have embedded HTML tags inside your markdown files. With a later version of https://github.com/github/markup
77 | we should be able to pass options to commonmark and give ourselves more options.
78 |
79 | This also uses rouge for syntax highlighting (fenced code blocks). Finding the documentation for that was fun ;)
80 |
81 | ### Breaking changes with 0.3
82 | * This removes the title tag functionality which was introduced in 0.2.6 Unfortunately, having spaces in links meant that the new markdown parsing did not see the link as being valid (at least for [foo bar](foo bar) links). This may be reintroduced later.
83 | * Requires ruby >= 2.3.8
84 |
85 |
86 | ## 0.2.6 [Jan 18 2018]
87 | Add %template and %title options
88 |
89 | ## 0.2.4 [Jan 01 2017]
90 | Make directory links work correctly. If you now link to
91 | a directory [somedir](somedir/) then that link will be preserved
92 | correctly.
93 |
94 | ## 0.2.3 [December 15th 2016]
95 | Bugfix - multiple links on the same line were not processed correctly.
96 |
97 | ## 0.2.1 [December 15th 2016]
98 | Allow %root_path% substitution in template file.
99 |
100 | ## 0.2.0 [March 6th 2016]
101 | * Adds the ability for `[[source|title]]` style links to be parsed correctly
102 | * Allows links with subdirectories `[[path/in/a/subdir/file]]` links to work
103 | * Also allows vimwiki links formatted with markdown syntax to work, this
104 | feature is currently implemented on the dev branch. This means you can
105 | link to [my markdownfile](blah.md) and it'll be parsed correctly
106 |
107 | ## 0.1.3 [August 11th 2015]
108 | * Adding the TableOfContents filter so that bookmarks are created.
109 |
110 | ## 0.1.1 [April 22nd 2015]
111 | * Aaaaannnnd reverting that change. While it totally works, it probably
112 | is overkill to have Druby running. The major issue is that vimwiki
113 | deletes the old files as the filenames do not match. Have added a
114 | note in the README to tell people how to make it faster.
115 |
116 | ## 0.1.0 [April 18th 2015]
117 | * Quite a major change, we now spin up a Druby server in the background
118 | and then send the files across the wire to it. This is somewhat
119 | invasive, but, on the plus side, takes the compilation time from
120 | several minutes down to seconds as we're not having to start
121 | up and require a whole bunch of files all the time.
122 |
123 | ## 0.0.4 [Dec 9th 2014]
124 | * Use Github::Markup to prerender the markdown
125 |
126 | ## 0.0.3 [Oct 30th 2014]
127 |
128 | * Raise warning if pygments placeholder is not present
129 |
130 | ## 0.0.2 [Sept 2014]
131 |
132 | * Initial beta release of the vimwiki_markdown gem
133 |
--------------------------------------------------------------------------------
/example_files/default.tpl:
--------------------------------------------------------------------------------
1 |
2 |
3 |