vimwiki_markdown 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/changelog.md +4 -0
- data/lib/vimwiki_markdown/version.rb +1 -1
- data/lib/vimwiki_markdown/vimwiki_link.rb +5 -2
- data/spec/lib/vimwiki_markdown/vimwiki_link_spec.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5a191248476c71d6d9f33309db8800da0a0d7405e89f13b58b10a58187f5fde
|
4
|
+
data.tar.gz: 1220ed04bf3a24eab1598e31b974b1a101351b9e7e12a7314bc98a4b63434c79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9cfce9007b1a2627f621a7d5e2c164ef022576460d430849983a672e04bf6d5a711291793f5b89da9c483e8993c295abd57a939e01c29a10a45234d96ad9c0e
|
7
|
+
data.tar.gz: e00bb2831a4a8c7af9599e51d76a4d41d3aacf6cb00a7ad768e18e7771ab581b778881048dc0d2faeec54e26bad6ecc0a881da2c82600751745f87652b6956f5
|
data/changelog.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 0.4.2 [June 16 2019]
|
2
|
+
Allow "fragments" in markdown style links such as those generated by :VimwikiTOC or or when using a diary_caption_level.
|
3
|
+
Thanks to @djeremiah - see https://github.com/patrickdavey/vimwiki_markdown/pull/23
|
4
|
+
|
1
5
|
## 0.4.1 [June 16 2019]
|
2
6
|
Allow "unsafe" HTML tags in markdown content (iframe etc.)
|
3
7
|
|
@@ -9,13 +9,14 @@
|
|
9
9
|
|
10
10
|
module VimwikiMarkdown
|
11
11
|
class VimwikiLink
|
12
|
-
MARKDOWN_LINK_REGEX = /\[(?<title>.*)\]\((?<uri
|
12
|
+
MARKDOWN_LINK_REGEX = /\[(?<title>.*)\]\((?<uri>(?:(?!#).)*)(?<fragment>(?:#)?.*)\)/
|
13
13
|
|
14
|
-
attr_reader :title, :uri, :source_markdown_directory, :markdown_extension, :root_path
|
14
|
+
attr_reader :title, :uri, :fragment, :source_markdown_directory, :markdown_extension, :root_path
|
15
15
|
|
16
16
|
def initialize(markdown_link, source_markdown_filepath, markdown_extension, root_path)
|
17
17
|
@title = markdown_link.match(MARKDOWN_LINK_REGEX)[:title]
|
18
18
|
@uri = markdown_link.match(MARKDOWN_LINK_REGEX)[:uri]
|
19
|
+
@fragment = markdown_link.match(MARKDOWN_LINK_REGEX)[:fragment]
|
19
20
|
@markdown_extension = markdown_extension
|
20
21
|
@root_path = root_path
|
21
22
|
@source_markdown_directory = Pathname.new(source_markdown_filepath).dirname
|
@@ -34,6 +35,8 @@ module VimwikiMarkdown
|
|
34
35
|
path = Pathname.new(uri)
|
35
36
|
@uri = "#{path.dirname + path.basename(markdown_extension).to_s.parameterize}.html"
|
36
37
|
end
|
38
|
+
|
39
|
+
@uri = "#{uri}#{fragment.empty? ? '' : '#' + fragment.parameterize}"
|
37
40
|
end
|
38
41
|
|
39
42
|
def vimwiki_markdown_file_exists?
|
@@ -13,6 +13,14 @@ module VimwikiMarkdown
|
|
13
13
|
expect(link.uri).to eq("http://www.google.com")
|
14
14
|
end
|
15
15
|
|
16
|
+
it "should render fragment-only links correctly" do
|
17
|
+
markdown_link = "[test](#Wiki Heading)"
|
18
|
+
|
19
|
+
link = VimwikiLink.new(markdown_link, source_filepath, markdown_extension, root_path)
|
20
|
+
expect(link.title).to eq("test")
|
21
|
+
expect(link.uri).to eq("#wiki-heading")
|
22
|
+
end
|
23
|
+
|
16
24
|
context "with an existing markdown file matching name" do
|
17
25
|
let(:existing_file) { "test#{markdown_extension}" }
|
18
26
|
let(:existing_file_no_extension) { existing_file.gsub(/#{markdown_extension}$/,"") }
|
@@ -44,6 +52,14 @@ module VimwikiMarkdown
|
|
44
52
|
expect(link.uri).to eq("#{existing_file_no_extension}.html")
|
45
53
|
end
|
46
54
|
|
55
|
+
it "must convert same-directory markdown links with url fragments correctly" do
|
56
|
+
markdown_link = "[test](#{existing_file_no_extension}#Wiki Heading)"
|
57
|
+
|
58
|
+
link = VimwikiLink.new(markdown_link, source_filepath, markdown_extension, root_path)
|
59
|
+
expect(link.title).to eq("test")
|
60
|
+
expect(link.uri).to eq("#{existing_file_no_extension}.html#wiki-heading")
|
61
|
+
end
|
62
|
+
|
47
63
|
context "subdirectory linked files" do
|
48
64
|
let(:existing_file) { "subdirectory/test.md" }
|
49
65
|
|
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.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Davey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|