vimwiki_markdown 0.4.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +12 -2
- data/changelog.md +12 -0
- data/example_files/default.tpl +39 -0
- data/lib/vimwiki_markdown/version.rb +1 -1
- data/lib/vimwiki_markdown/vimwiki_link.rb +27 -4
- data/lib/vimwiki_markdown/wiki_body.rb +15 -3
- data/spec/lib/vimwiki_markdown/vimwiki_link_spec.rb +70 -40
- data/spec/lib/vimwiki_markdown/wiki_body_spec.rb +31 -1
- data/spec/spec_helper.rb +22 -0
- data/vimwiki_markdown.gemspec +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 94fcdf721504210b46ed56769e3529838982092414094c950ccddaa747086f9f
|
|
4
|
+
data.tar.gz: 219b35ea5da34b1cf75f962432073a8f97c972a62d14403b35dfae442f98b794
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5c51b9de26115ee93f512404af7e84544088406df98a4c0861095da736dd78821f12e59b40e639f7bbea13f20bc460eb14bf9b4daa911c3bd00202ccd587f1e9
|
|
7
|
+
data.tar.gz: 5ccfb995fa5e7966379fc34dc40a0799614bf59b59d780fc0932a413a3876bebccdbc3bf4166cbda209a9e8bbc78593673816a44b4a5768cc90a80e6fc33f958
|
data/README.md
CHANGED
|
@@ -56,14 +56,24 @@ of the site (e.g. `./` or `../../` etc)
|
|
|
56
56
|
You can also have a `%date%` marker in your template file
|
|
57
57
|
It will get rewritten with todays date in the format 29 March 2019
|
|
58
58
|
|
|
59
|
+
#### Support for tasklists
|
|
60
|
+
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)
|
|
61
|
+
|
|
62
|
+
#### Support for :local and :file links
|
|
63
|
+
|
|
64
|
+
We have partial support for the `:local` and `:file` link types for vimwiki.
|
|
65
|
+
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:
|
|
66
|
+
|
|
67
|
+
* `[link text](local:bar.txt)` when output to HTML becomes `<a href="../bar.txt">link text</a>`
|
|
68
|
+
* `[link text](file:bar.txt)` when output to HTML becomes `<a href="/absolute/path/to/file">link text</a>`
|
|
69
|
+
|
|
59
70
|
#### Optional %nohtml
|
|
60
71
|
|
|
61
72
|
If you place the text %nohtml anywhere in a wiki page, it will not be processed into html
|
|
62
73
|
|
|
63
74
|
## Contributing
|
|
64
75
|
|
|
65
|
-
Pull requests are very welcome
|
|
66
|
-
more interesting vimwiki links (e.g. :local etc.)
|
|
76
|
+
Pull requests are very welcome
|
|
67
77
|
|
|
68
78
|
1. Fork it ( https://github.com/patrickdavey/vimwiki_markdown/fork )
|
|
69
79
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
data/changelog.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 0.6.0 [April 26 2020]
|
|
2
|
+
Support for todo lists with enhanced state options. Thanks to @primercuervo
|
|
3
|
+
|
|
4
|
+
## 0.5.0 [April 26 2020]
|
|
5
|
+
Partial support for `local` and `file` links in urls. Thanks to @tfachmann for the PR
|
|
6
|
+
|
|
7
|
+
## 0.4.4 [June 16 2019]
|
|
8
|
+
Allow fragments if they are for local vimwiki links only
|
|
9
|
+
|
|
10
|
+
## 0.4.3 [June 16 2019]
|
|
11
|
+
temporarily revoke fragments until we're not altering old links
|
|
12
|
+
|
|
1
13
|
## 0.4.2 [June 16 2019]
|
|
2
14
|
Allow "fragments" in markdown style links such as those generated by :VimwikiTOC or or when using a diary_caption_level.
|
|
3
15
|
Thanks to @djeremiah - see https://github.com/patrickdavey/vimwiki_markdown/pull/23
|
data/example_files/default.tpl
CHANGED
|
@@ -4,6 +4,45 @@
|
|
|
4
4
|
<title>%title%</title>
|
|
5
5
|
|
|
6
6
|
%pygments%
|
|
7
|
+
<!--Style for Vimwiki Tasklist-->
|
|
8
|
+
<style>
|
|
9
|
+
.rejected {
|
|
10
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAMAAAAMCGV4AAAACXBIWXMAAADFAAAAxQEdzbqoAAAAB3RJTUUH4QgEFhAtuWgv9wAAAPZQTFRFmpqam5iYnJaWnJeXnpSUn5OTopCQpoqKpouLp4iIqIiIrYCAt3V1vW1tv2xsmZmZmpeXnpKS/x4e/x8f/yAg/yIi/yQk/yUl/yYm/ygo/ykp/yws/zAw/zIy/zMz/zQ0/zU1/zY2/zw8/0BA/0ZG/0pK/1FR/1JS/1NT/1RU/1VV/1ZW/1dX/1pa/15e/19f/2Zm/2lp/21t/25u/3R0/3p6/4CA/4GB/4SE/4iI/46O/4+P/52d/6am/6ur/66u/7Oz/7S0/7e3/87O/9fX/9zc/93d/+Dg/+vr/+3t/+/v//Dw//Ly//X1//f3//n5//z8////gzaKowAAAA90Uk5T/Pz8/Pz8/Pz8/Pz8/f39ppQKWQAAAAFiS0dEEnu8bAAAAACuSURBVAhbPY9ZF4FQFEZPSKbIMmWep4gMGTKLkIv6/3/GPbfF97b3w17rA0kQOPgvAeHW6uJ6+5h7HqLdwowgOzejXRXBdx6UdSru216xuOMBHHNU0clTzeSUA6EhF8V8kqroluMiU6HKcuf4phGPr1o2q9kYZWwNq1qfRRmTaXpqsyjj17KkWCxKBUBgXWueHIyiAIg18gsse4KHkLF5IKIY10WQgv7fOy4ST34BRiopZ8WLNrgAAAAASUVORK5CYII=);
|
|
11
|
+
background-repeat: no-repeat;
|
|
12
|
+
background-position: 0 .2em;
|
|
13
|
+
padding-left: 5.5em;
|
|
14
|
+
}
|
|
15
|
+
.done0 {
|
|
16
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAA7SURBVCiR7dMxEgAgCANBI3yVRzF5KxNbW6wsuH7LQ2YKQK1mkswBVERYF5Os3UV3gwd/jF2SkXy66gAZkxS6BniubAAAAABJRU5ErkJggg==);
|
|
17
|
+
background-repeat: no-repeat;
|
|
18
|
+
background-position: 0 .2em;
|
|
19
|
+
padding-left: 1.5em;
|
|
20
|
+
}
|
|
21
|
+
.done1 {
|
|
22
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABtSURBVCiR1ZO7DYAwDER9BDmTeZQMFXmUbGYpOjrEryA0wOvO8itOslFrJYAug5BMM4BeSkmjsrv3aVTa8p48Xw1JSkSsWVUFwD05IqS1tmYzk5zzae9jnVVVzGyXb8sALjse+euRkEzu/uirFomVIdDGOLjuAAAAAElFTkSuQmCC);
|
|
23
|
+
background-repeat: no-repeat;
|
|
24
|
+
background-position: 0 .15em;
|
|
25
|
+
padding-left: 1.5em;
|
|
26
|
+
}
|
|
27
|
+
.done2 {
|
|
28
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAB1SURBVCiRzdO5DcAgDAVQGxjAYgTvxlDIu1FTIRYAp8qlFISkSH7l5kk+ZIwxKiI2mIyqWoeILYRgZ7GINDOLjnmF3VqklKCUMgTee2DmM661Qs55iI3Zm/1u5h9sm4ig9z4ERHTFzLyd4G4+nFlVrYg8+qoF/c0kdpeMsmcAAAAASUVORK5CYII=);
|
|
29
|
+
background-repeat: no-repeat;
|
|
30
|
+
background-position: 0 .15em;
|
|
31
|
+
padding-left: 1.5em;
|
|
32
|
+
}
|
|
33
|
+
.done3 {
|
|
34
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABoSURBVCiR7dOxDcAgDATA/0DtUdiKoZC3YhLkHjkVKF3idJHiztKfvrHZWnOSE8Fx95RJzlprimJVnXktvXeY2S0SEZRSAAAbmxnGGKH2I5T+8VfxPhIReQSuuY3XyYWa3T2p6quvOgGrvSFGlewuUAAAAABJRU5ErkJggg==);
|
|
35
|
+
background-repeat: no-repeat;
|
|
36
|
+
background-position: 0 .15em;
|
|
37
|
+
padding-left: 1.5em;
|
|
38
|
+
}
|
|
39
|
+
.done4 {
|
|
40
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAQCAYAAAAbBi9cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAzgAAAM4BlP6ToAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAIISURBVDiNnZQ9SFtRFMd/773kpTaGJoQk1im4VDpWQcTNODhkFBcVTCNCF0NWyeDiIIiCm82QoIMIUkHUxcFBg1SEQoZszSat6cdTn1qNue92CMbEr9Sey+XC/Z/zu+f8h6ukUil3sVg0+M+4cFxk42/jH2wAqqqKSCSiPQdwcHHAnDHH9s/tN1h8V28ETdP+eU8fT9Nt62ancYdIPvJNtsu87bmjrJlrTDVM4RROJs1JrHPrD4Bar7A6cpc54iKOaTdJXCUI2UMVrQZ0Js7YPN18ECKkYNQcJe/OE/4dZsw7VqNXQMvHy3QZXQypQ6ycrtwDjf8aJ+PNEDSCzLpn7+m2pD8ZKHlKarYhy6XjEoCYGcN95qansQeA3fNdki+SaJZGTMQIOoL3W/Z89rxv+tokubNajlvk/vm+LFpF2XnUKZHI0I+QrI7Dw0OZTqdzUkpsM7mZTyfy5OPGyw1tK7AFSvmB/Ks8w8YwbUYbe6/3QEKv0vugfxWPnMLJun+d/kI/WLdizpNjMbAIKrhMF4OuwadBALqqs+RfInwUvuNi+fBd+wjogfogAFVRmffO02q01mZZ0HHdgXIzdz0QQLPezIQygX6llxNKKgOFARYCC49CqhoHIUTlss/Vx2phlYwjw8j1CAlfAiwQiJpiy7o1VHnsG5FISkoJu7Q/2YmmaV+i0ei7v38L2CBguSi5AAAAAElFTkSuQmCC);
|
|
41
|
+
background-repeat: no-repeat;
|
|
42
|
+
background-position: 0 .15em;
|
|
43
|
+
padding-left: 1.5em;
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
7
46
|
</head>
|
|
8
47
|
<body id="%title%">
|
|
9
48
|
<h2 id="title">%title%</h2>
|
|
@@ -11,21 +11,22 @@ module VimwikiMarkdown
|
|
|
11
11
|
class VimwikiLink
|
|
12
12
|
MARKDOWN_LINK_REGEX = /\[(?<title>.*)\]\((?<uri>(?:(?!#).)*)(?<fragment>(?:#)?.*)\)/
|
|
13
13
|
|
|
14
|
-
attr_reader :title, :uri, :fragment, :source_markdown_directory, :markdown_extension, :root_path
|
|
14
|
+
attr_reader :title, :uri, :fragment, :source_markdown_directory, :markdown_extension, :root_path, :output_dir
|
|
15
15
|
|
|
16
|
-
def initialize(markdown_link, source_markdown_filepath, markdown_extension, root_path)
|
|
16
|
+
def initialize(markdown_link, source_markdown_filepath, markdown_extension, root_path, output_dir)
|
|
17
17
|
@title = markdown_link.match(MARKDOWN_LINK_REGEX)[:title]
|
|
18
18
|
@uri = markdown_link.match(MARKDOWN_LINK_REGEX)[:uri]
|
|
19
19
|
@fragment = markdown_link.match(MARKDOWN_LINK_REGEX)[:fragment]
|
|
20
20
|
@markdown_extension = markdown_extension
|
|
21
21
|
@root_path = root_path
|
|
22
22
|
@source_markdown_directory = Pathname.new(source_markdown_filepath).dirname
|
|
23
|
+
@output_dir = output_dir
|
|
23
24
|
rewrite_local_links!
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
def to_s
|
|
28
|
-
"[#{title}](#{uri})"
|
|
29
|
+
"[#{title}](#{uri}#{fragment})"
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
private
|
|
@@ -34,9 +35,31 @@ module VimwikiMarkdown
|
|
|
34
35
|
if vimwiki_markdown_file_exists?
|
|
35
36
|
path = Pathname.new(uri)
|
|
36
37
|
@uri = "#{path.dirname + path.basename(markdown_extension).to_s.parameterize}.html"
|
|
38
|
+
@fragment = fragment.parameterize.prepend("#") unless fragment.empty?
|
|
39
|
+
elsif /^file:/.match(uri)
|
|
40
|
+
# begins with file: -> force absolute path if file exists
|
|
41
|
+
@uri = "#{source_markdown_directory + uri}" if uri_relative_path_exists?
|
|
42
|
+
elsif /^local:/.match(uri)
|
|
43
|
+
# begins with local: -> force relative path if file exists
|
|
44
|
+
source = Pathname.new(source_markdown_directory)
|
|
45
|
+
output = Pathname.new(output_dir)
|
|
46
|
+
@uri = "#{source.relative_path_from(output) + uri}" if uri_relative_path_exists?
|
|
37
47
|
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def uri_relative_path_exists?
|
|
51
|
+
# remove file: or local: prefix
|
|
52
|
+
tmp = uri.sub(/^file:|^local:/, "") if uri.present?
|
|
53
|
+
path, title = tmp.split(/\.?\s+\"/) # handle image title
|
|
54
|
+
path = Pathname.new(path)
|
|
55
|
+
path = path.realpath.relative_path_from(source_markdown_directory) if path.absolute?
|
|
38
56
|
|
|
39
|
-
|
|
57
|
+
if File.exist?(source_markdown_directory + path)
|
|
58
|
+
title = "\"#{title}" unless title.nil? || title.empty?
|
|
59
|
+
@uri = "#{path.to_s.gsub(/\ /, '%20')} #{title}".strip
|
|
60
|
+
return true
|
|
61
|
+
end
|
|
62
|
+
false
|
|
40
63
|
end
|
|
41
64
|
|
|
42
65
|
def vimwiki_markdown_file_exists?
|
|
@@ -25,8 +25,9 @@ class VimwikiMarkdown::WikiBody
|
|
|
25
25
|
HTML::Pipeline::SyntaxHighlightFilter,
|
|
26
26
|
HTML::Pipeline::TableOfContentsFilter
|
|
27
27
|
], { scope: "highlight"})
|
|
28
|
-
result = pipeline.call(html)
|
|
29
|
-
result[:output].to_s
|
|
28
|
+
@result = pipeline.call(html)
|
|
29
|
+
@result = @result[:output].to_s
|
|
30
|
+
enrich_li_class!
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
|
|
@@ -63,7 +64,7 @@ class VimwikiMarkdown::WikiBody
|
|
|
63
64
|
|
|
64
65
|
def convert_markdown_local_links!
|
|
65
66
|
@markdown_body = @markdown_body.gsub(/\[.*?\]\(.*?\)/) do |match|
|
|
66
|
-
VimwikiMarkdown::VimwikiLink.new(match, options.input_file, options.extension, options.root_path).to_s
|
|
67
|
+
VimwikiMarkdown::VimwikiLink.new(match, options.input_file, options.extension, options.root_path, options.output_dir).to_s
|
|
67
68
|
end
|
|
68
69
|
end
|
|
69
70
|
|
|
@@ -74,4 +75,15 @@ class VimwikiMarkdown::WikiBody
|
|
|
74
75
|
CommonMarker.render_html(content, commonmarker_opts, commonmarker_exts)
|
|
75
76
|
}
|
|
76
77
|
end
|
|
78
|
+
|
|
79
|
+
def enrich_li_class!
|
|
80
|
+
syms_hash = { " ]" => 0, ".]" => 1, "o]" => 2, "O]" => 3, "X]" => 4 }
|
|
81
|
+
checkbox = /<li>\s*\[[\s.oOX]\]/
|
|
82
|
+
checkbox_start = /<li>\s*\[/
|
|
83
|
+
@result.gsub!(checkbox) do |m|
|
|
84
|
+
m.sub(checkbox_start, '<li class="done')
|
|
85
|
+
.sub(/[\s.oOX\]]*$/, syms_hash) << '">'
|
|
86
|
+
end
|
|
87
|
+
@result
|
|
88
|
+
end
|
|
77
89
|
end
|
|
@@ -1,24 +1,33 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
module VimwikiMarkdown
|
|
4
4
|
describe VimwikiLink do
|
|
5
|
-
let(:markdown_link) { "[title](http://www.google.com)" }
|
|
6
|
-
let(:source_filepath) { "unimportant" }
|
|
7
5
|
let(:markdown_extension) { ".md" }
|
|
8
6
|
let(:root_path) { "-" }
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
context "external or fragment only" do
|
|
9
|
+
let(:markdown_link) { "[title](http://www.google.com)" }
|
|
10
|
+
let(:source_filepath) { "unimportant" }
|
|
11
|
+
let(:output_dir) { "unused in this scenario" }
|
|
12
|
+
|
|
13
|
+
it "should leave external links alone" do
|
|
14
|
+
link = VimwikiLink.new(markdown_link, source_filepath, markdown_extension, root_path, output_dir)
|
|
15
|
+
expect(link.to_s).to eq(markdown_link)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should not alter fragments which are part of a url" do
|
|
19
|
+
markdown_link = "[test](http://foo#Bar)"
|
|
20
|
+
|
|
21
|
+
link = VimwikiLink.new(markdown_link, source_filepath, markdown_extension, root_path, output_dir)
|
|
22
|
+
expect(link.to_s).to eq("[test](http://foo#Bar)")
|
|
23
|
+
end
|
|
15
24
|
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
it "should not alter fragment-only links" do
|
|
26
|
+
markdown_link = "[test](#GTD)"
|
|
18
27
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
link = VimwikiLink.new(markdown_link, source_filepath, markdown_extension, root_path, output_dir)
|
|
29
|
+
expect(link.to_s).to eq("[test](#GTD)")
|
|
30
|
+
end
|
|
22
31
|
end
|
|
23
32
|
|
|
24
33
|
context "with an existing markdown file matching name" do
|
|
@@ -27,10 +36,12 @@ module VimwikiMarkdown
|
|
|
27
36
|
let(:temp_wiki_dir) { Pathname.new(Dir.mktmpdir("temp_wiki_")) }
|
|
28
37
|
let(:markdown_link) { "[test](#{existing_file})" }
|
|
29
38
|
let(:source_filepath) { temp_wiki_dir + "index.md" }
|
|
39
|
+
let(:output_dir) { temp_wiki_dir + "temp_output_dir" }
|
|
30
40
|
|
|
31
41
|
before(:each) do
|
|
32
42
|
# here we create a stub test filename in the directory,
|
|
33
43
|
FileUtils.mkdir_p((temp_wiki_dir + existing_file).dirname)
|
|
44
|
+
FileUtils.mkdir_p(output_dir)
|
|
34
45
|
FileUtils.touch(temp_wiki_dir + existing_file)
|
|
35
46
|
end
|
|
36
47
|
|
|
@@ -39,43 +50,37 @@ module VimwikiMarkdown
|
|
|
39
50
|
end
|
|
40
51
|
|
|
41
52
|
it "must convert same-directory markdown links correctly" do
|
|
42
|
-
link = VimwikiLink.new(markdown_link, source_filepath, markdown_extension, root_path)
|
|
43
|
-
expect(link.
|
|
44
|
-
expect(link.uri).to eq("#{existing_file_no_extension}.html")
|
|
53
|
+
link = VimwikiLink.new(markdown_link, source_filepath, markdown_extension, root_path, output_dir)
|
|
54
|
+
expect(link.to_s).to eq("[test](#{existing_file_no_extension}.html)")
|
|
45
55
|
end
|
|
46
56
|
|
|
47
57
|
it "must convert same-directory markdown links with no extension correctly" do
|
|
48
|
-
markdown_link =
|
|
58
|
+
markdown_link = "[test](#{existing_file_no_extension})"
|
|
49
59
|
|
|
50
|
-
link = VimwikiLink.new(markdown_link, source_filepath, markdown_extension, root_path)
|
|
51
|
-
expect(link.
|
|
52
|
-
expect(link.uri).to eq("#{existing_file_no_extension}.html")
|
|
60
|
+
link = VimwikiLink.new(markdown_link, source_filepath, markdown_extension, root_path, output_dir)
|
|
61
|
+
expect(link.to_s).to eq("[test](#{existing_file_no_extension}.html)")
|
|
53
62
|
end
|
|
54
63
|
|
|
55
64
|
it "must convert same-directory markdown links with url fragments correctly" do
|
|
56
65
|
markdown_link = "[test](#{existing_file_no_extension}#Wiki Heading)"
|
|
57
66
|
|
|
58
|
-
link = VimwikiLink.new(markdown_link, source_filepath, markdown_extension, root_path)
|
|
59
|
-
expect(link.
|
|
60
|
-
expect(link.uri).to eq("#{existing_file_no_extension}.html#wiki-heading")
|
|
67
|
+
link = VimwikiLink.new(markdown_link, source_filepath, markdown_extension, root_path, output_dir)
|
|
68
|
+
expect(link.to_s).to eq("[test](#{existing_file_no_extension}.html#wiki-heading)")
|
|
61
69
|
end
|
|
62
70
|
|
|
63
71
|
context "subdirectory linked files" do
|
|
64
72
|
let(:existing_file) { "subdirectory/test.md" }
|
|
65
73
|
|
|
66
74
|
it "must convert markdown links correctly" do
|
|
67
|
-
link = VimwikiLink.new(markdown_link, source_filepath, markdown_extension, root_path)
|
|
68
|
-
expect(link.
|
|
69
|
-
expect(link.uri).to eq("#{existing_file_no_extension}.html")
|
|
75
|
+
link = VimwikiLink.new(markdown_link, source_filepath, markdown_extension, root_path, output_dir)
|
|
76
|
+
expect(link.to_s).to eq("[test](#{existing_file_no_extension}.html)")
|
|
70
77
|
end
|
|
71
78
|
|
|
72
79
|
it "must convert directory links correctly" do
|
|
73
|
-
markdown_link =
|
|
74
|
-
link = VimwikiLink.new(markdown_link, source_filepath, markdown_extension, root_path)
|
|
75
|
-
expect(link.
|
|
76
|
-
expect(link.uri).to eq("subdirectory/")
|
|
80
|
+
markdown_link = "[subdirectory](subdirectory/)"
|
|
81
|
+
link = VimwikiLink.new(markdown_link, source_filepath, markdown_extension, root_path, output_dir)
|
|
82
|
+
expect(link.to_s).to eq("[subdirectory](subdirectory/)")
|
|
77
83
|
end
|
|
78
|
-
|
|
79
84
|
end
|
|
80
85
|
|
|
81
86
|
context "../ style links" do
|
|
@@ -83,9 +88,8 @@ module VimwikiMarkdown
|
|
|
83
88
|
let(:source_filepath) { temp_wiki_dir + "subdirectory/index.md" }
|
|
84
89
|
|
|
85
90
|
it "must convert sub-directory markdown links correctly" do
|
|
86
|
-
link = VimwikiLink.new("[test](../test)", source_filepath, markdown_extension, root_path)
|
|
87
|
-
expect(link.
|
|
88
|
-
expect(link.uri).to eq("../test.html")
|
|
91
|
+
link = VimwikiLink.new("[test](../test)", source_filepath, markdown_extension, root_path, output_dir)
|
|
92
|
+
expect(link.to_s).to eq("[test](../test.html)")
|
|
89
93
|
end
|
|
90
94
|
end
|
|
91
95
|
|
|
@@ -95,24 +99,50 @@ module VimwikiMarkdown
|
|
|
95
99
|
let(:root_path) { "../"}
|
|
96
100
|
|
|
97
101
|
it "must convert absolute paths correctly" do
|
|
98
|
-
link = VimwikiLink.new("[test](/test.md)", source_filepath, markdown_extension, root_path)
|
|
99
|
-
expect(link.
|
|
102
|
+
link = VimwikiLink.new("[test](/test.md)", source_filepath, markdown_extension, root_path, output_dir)
|
|
103
|
+
expect(link.to_s).to eq("[test](/test.html)")
|
|
100
104
|
end
|
|
101
105
|
|
|
102
106
|
it "must convert absolute paths without extension correctly" do
|
|
103
|
-
link = VimwikiLink.new("[test](/test)", source_filepath, markdown_extension, root_path)
|
|
104
|
-
expect(link.
|
|
107
|
+
link = VimwikiLink.new("[test](/test)", source_filepath, markdown_extension, root_path, output_dir)
|
|
108
|
+
expect(link.to_s).to eq("[test](/test.html)")
|
|
105
109
|
end
|
|
106
110
|
|
|
107
111
|
context "from the root directory" do
|
|
108
112
|
let(:source_filepath) { temp_wiki_dir + "index.md" }
|
|
109
113
|
|
|
110
114
|
it "must convert absolute paths correctly" do
|
|
111
|
-
link = VimwikiLink.new("[test](/test)", source_filepath, markdown_extension, ".")
|
|
112
|
-
expect(link.
|
|
115
|
+
link = VimwikiLink.new("[test](/test)", source_filepath, markdown_extension, ".", output_dir)
|
|
116
|
+
expect(link.to_s).to eq("[test](/test.html)")
|
|
113
117
|
end
|
|
114
118
|
end
|
|
115
119
|
end
|
|
120
|
+
|
|
121
|
+
context "links with local: files" do
|
|
122
|
+
let(:sample_png) { "foo.png" }
|
|
123
|
+
|
|
124
|
+
before do
|
|
125
|
+
FileUtils.touch(temp_wiki_dir + sample_png)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it "must convert local paths correctly" do
|
|
129
|
+
link = VimwikiLink.new("[test](local:#{sample_png})", source_filepath, markdown_extension, root_path, output_dir)
|
|
130
|
+
expect(link.to_s).to eq("[test](../#{sample_png})")
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
context "links with file: files" do
|
|
135
|
+
let(:sample_png) { "foo.png" }
|
|
136
|
+
|
|
137
|
+
before do
|
|
138
|
+
FileUtils.touch(temp_wiki_dir + sample_png)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
it "must convert local paths correctly" do
|
|
142
|
+
link = VimwikiLink.new("[test](file:#{sample_png})", source_filepath, markdown_extension, root_path, output_dir)
|
|
143
|
+
expect(link.to_s).to eq("[test](#{temp_wiki_dir + sample_png})")
|
|
144
|
+
end
|
|
145
|
+
end
|
|
116
146
|
end
|
|
117
147
|
end
|
|
118
148
|
end
|
|
@@ -6,7 +6,7 @@ require 'rspec-html-matchers'
|
|
|
6
6
|
module VimwikiMarkdown
|
|
7
7
|
describe WikiBody do
|
|
8
8
|
|
|
9
|
-
let(:wiki_body) { WikiBody.new(double(:options, input_file: 'blah', extension: 'md', root_path: '-')) }
|
|
9
|
+
let(:wiki_body) { WikiBody.new(double(:options, input_file: 'blah', extension: 'md', root_path: '-', output_dir: ".")) }
|
|
10
10
|
let(:markdown_file_content) { wiki_index_markdown }
|
|
11
11
|
|
|
12
12
|
it "must convert wiki links" do
|
|
@@ -52,6 +52,36 @@ module VimwikiMarkdown
|
|
|
52
52
|
expect(wiki_body.to_s).to match(/<a href="there.html">there<\/a>/)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
it "must enrich task list unchecked" do
|
|
56
|
+
allow_any_instance_of(VimwikiMarkdown::VimwikiLink).to receive(:vimwiki_markdown_file_exists?).and_return(true)
|
|
57
|
+
allow(wiki_body).to receive(:get_wiki_markdown_contents).and_return("- [ ] This is one line")
|
|
58
|
+
expect(wiki_body.to_s).to match(/<li class="done0"> This is one line<\/li>/)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "must enrich task list checked" do
|
|
62
|
+
allow_any_instance_of(VimwikiMarkdown::VimwikiLink).to receive(:vimwiki_markdown_file_exists?).and_return(true)
|
|
63
|
+
allow(wiki_body).to receive(:get_wiki_markdown_contents).and_return("- [X] This is a checked line")
|
|
64
|
+
expect(wiki_body.to_s).to match(/<li class="done4"> This is a checked line<\/li>/)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "must enrich task list parent 1" do
|
|
68
|
+
allow_any_instance_of(VimwikiMarkdown::VimwikiLink).to receive(:vimwiki_markdown_file_exists?).and_return(true)
|
|
69
|
+
allow(wiki_body).to receive(:get_wiki_markdown_contents).and_return("- [.] This is a parent 1 line")
|
|
70
|
+
expect(wiki_body.to_s).to match(/<li class="done1"> This is a parent 1 line<\/li>/)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "must enrich task list parent 2" do
|
|
74
|
+
allow_any_instance_of(VimwikiMarkdown::VimwikiLink).to receive(:vimwiki_markdown_file_exists?).and_return(true)
|
|
75
|
+
allow(wiki_body).to receive(:get_wiki_markdown_contents).and_return("- [o] This is a parent 2 line")
|
|
76
|
+
expect(wiki_body.to_s).to match(/<li class="done2"> This is a parent 2 line<\/li>/)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "must enrich task list parent 3" do
|
|
80
|
+
allow_any_instance_of(VimwikiMarkdown::VimwikiLink).to receive(:vimwiki_markdown_file_exists?).and_return(true)
|
|
81
|
+
allow(wiki_body).to receive(:get_wiki_markdown_contents).and_return("- [O] This is a parent 3 line")
|
|
82
|
+
expect(wiki_body.to_s).to match(/<li class="done3"> This is a parent 3 line<\/li>/)
|
|
83
|
+
end
|
|
84
|
+
|
|
55
85
|
describe "syntax highlighting" do
|
|
56
86
|
it "must give correct classes" do
|
|
57
87
|
allow(wiki_body).to receive(:get_wiki_markdown_contents)
|
data/spec/spec_helper.rb
CHANGED
|
@@ -107,6 +107,28 @@ def wiki_index_markdown
|
|
|
107
107
|
|
|
108
108
|
> this is a blockquote
|
|
109
109
|
> without a linebreak
|
|
110
|
+
|
|
111
|
+
## Test for checks
|
|
112
|
+
|
|
113
|
+
- [ ] This is one line
|
|
114
|
+
- [X] This is a checked line
|
|
115
|
+
- [ ] This is a parent line 1
|
|
116
|
+
- [ ] This is a child line 1
|
|
117
|
+
- [ ] This is a child line 2
|
|
118
|
+
- [.] This is a parent line 2
|
|
119
|
+
- [X] This is a child line 1
|
|
120
|
+
- [ ] This is a child line 2
|
|
121
|
+
- [ ] This is a child line 3
|
|
122
|
+
- [o] This is a parent line 2
|
|
123
|
+
- [X] This is a child line 1
|
|
124
|
+
- [X] This is a child line 2
|
|
125
|
+
- [ ] This is a child line 3
|
|
126
|
+
- [O] This is a parent line 3
|
|
127
|
+
- [X] This is a child line 1
|
|
128
|
+
- [X] This is a child line 2
|
|
129
|
+
- [X] This is a child line 3
|
|
130
|
+
- [ ] This is a child line 4
|
|
131
|
+
|
|
110
132
|
"
|
|
111
133
|
end
|
|
112
134
|
|
data/vimwiki_markdown.gemspec
CHANGED
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
|
19
19
|
spec.require_paths = ["lib"]
|
|
20
20
|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.0"
|
|
22
|
-
spec.add_development_dependency "rake", "~>
|
|
22
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.0"
|
|
24
24
|
spec.add_development_dependency "pry", "~> 0.12"
|
|
25
25
|
spec.add_development_dependency "rspec-its", "~> 1.1"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vimwiki_markdown
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Patrick Davey
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-06-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '12.3'
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '12.3'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rspec
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -260,8 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
260
260
|
- !ruby/object:Gem::Version
|
|
261
261
|
version: '0'
|
|
262
262
|
requirements: []
|
|
263
|
-
|
|
264
|
-
rubygems_version: 2.7.9
|
|
263
|
+
rubygems_version: 3.0.4
|
|
265
264
|
signing_key:
|
|
266
265
|
specification_version: 4
|
|
267
266
|
summary: Converts a github flavoured markdown vimwiki file into html.
|