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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2fd707b900cb57f83d9b363ca7ecdfb1ef7bc3c0784b6d837d025506bfb23c9
4
- data.tar.gz: 0ab730e8add13342a0d1188d281185c80ec23dbd2b4f7a88fd37953c665b2eab
3
+ metadata.gz: c5a191248476c71d6d9f33309db8800da0a0d7405e89f13b58b10a58187f5fde
4
+ data.tar.gz: 1220ed04bf3a24eab1598e31b974b1a101351b9e7e12a7314bc98a4b63434c79
5
5
  SHA512:
6
- metadata.gz: 0e4bd0e9039a5dd14a1183eba6d1fab3bdf6d184bed9838be0da24be1ccd369c48f00d40fa35085f6355baf259907a1842ed8bfb242ff79152be91f955360615
7
- data.tar.gz: 1efbc7939774eaca7b8d6b731a252cf2248da1f9bad622b3c74c567f35eea2572070e006b75d449fe005fefb6b48b1b52593ec8742ad3e60ae57e3b4aa7b1e08
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
 
@@ -1,3 +1,3 @@
1
1
  module VimwikiMarkdown
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -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.1
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: 2019-06-17 00:00:00.000000000 Z
11
+ date: 2020-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler