vimwiki_markdown 0.6.0 → 0.8.2
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/.travis.yml +5 -3
- data/A.png +0 -0
- data/B.png +0 -0
- data/README.md +9 -0
- data/changelog.md +18 -0
- data/lib/vimwiki_markdown/options.rb +2 -1
- data/lib/vimwiki_markdown/version.rb +1 -1
- data/lib/vimwiki_markdown/vimwiki_link.rb +6 -1
- data/lib/vimwiki_markdown/vimwiki_toc_filter.rb +34 -0
- data/lib/vimwiki_markdown/wiki_body.rb +2 -1
- data/spec/lib/vimwiki_markdown/options_spec.rb +5 -0
- data/spec/lib/vimwiki_markdown/vimwiki_link_spec.rb +11 -0
- data/vimwiki_markdown.gemspec +2 -2
- metadata +15 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c9f4165d6c964688b29b13f05378ad2d7f8aa04621121e718e3bf25a9832ecc
|
4
|
+
data.tar.gz: d76fa5a6a5081ff3cde0e8d556bca8e45e90f25618ad4b623e0949c88ed18e5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 909ccbcc5420b3da2b2c62d40bf5e6f8223afdd2044386f33809598d741cb19ae197d728f22bff724fd99c2d109feb917fc862287a61ab22004ee50486b0ce93
|
7
|
+
data.tar.gz: 1ed5e03a0811ce63df21004ae8f10020a6d8fd758280d6cc0e6dca353ab49431190cf9f23d9ff230713e9285cf69231d314a7bfcd7fa8e681e889d2ba6b634af
|
data/.travis.yml
CHANGED
data/A.png
ADDED
Binary file
|
data/B.png
ADDED
Binary file
|
data/README.md
CHANGED
@@ -6,6 +6,15 @@ to be converted to HTML.
|
|
6
6
|
|
7
7
|
It is currently a work in progress (but working for me ;)
|
8
8
|
|
9
|
+
## Example
|
10
|
+
It turns this:
|
11
|
+
|
12
|
+

|
13
|
+
|
14
|
+
into
|
15
|
+
|
16
|
+

|
17
|
+
|
9
18
|
## Requirements
|
10
19
|
|
11
20
|
Ruby installed on your computer & up to date version of vimwiki
|
data/changelog.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
## 0.8.2 [22 June 2022]
|
2
|
+
Remove deprecation warning for EscapeUtils.escape_html
|
3
|
+
see https://github.com/patrickdavey/vimwiki_markdown/pull/43
|
4
|
+
|
5
|
+
## 0.8.1 [March 7 2022]
|
6
|
+
Update commonmarker version, fixes security issue!
|
7
|
+
|
8
|
+
## 0.8.0 [March 7 2022]
|
9
|
+
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.
|
10
|
+
|
11
|
+
This means any generated (dupliate) bookmarks are going to be broken though, so, this is backwardly incompatible
|
12
|
+
|
13
|
+
see https://github.com/patrickdavey/vimwiki_markdown/pull/39
|
14
|
+
|
15
|
+
## 0.7.0 [July 8 2021]
|
16
|
+
Fixes an issue whereby non english filenames were being replaced with empty strings
|
17
|
+
see https://github.com/patrickdavey/vimwiki_markdown/pull/35
|
18
|
+
|
1
19
|
## 0.6.0 [April 26 2020]
|
2
20
|
Support for todo lists with enhanced state options. Thanks to @primercuervo
|
3
21
|
|
@@ -34,7 +34,12 @@ module VimwikiMarkdown
|
|
34
34
|
def rewrite_local_links!
|
35
35
|
if vimwiki_markdown_file_exists?
|
36
36
|
path = Pathname.new(uri)
|
37
|
-
|
37
|
+
|
38
|
+
link_path = path.basename(markdown_extension).to_s.parameterize
|
39
|
+
|
40
|
+
link_path = path.basename(markdown_extension).to_s if link_path.match(/^\s*$/)
|
41
|
+
|
42
|
+
@uri = "#{path.dirname + link_path}.html"
|
38
43
|
@fragment = fragment.parameterize.prepend("#") unless fragment.empty?
|
39
44
|
elsif /^file:/.match(uri)
|
40
45
|
# begins with file: -> force absolute path if file exists
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "cgi"
|
2
|
+
|
3
|
+
class VimwikiTOCFilter < HTML::Pipeline::TableOfContentsFilter
|
4
|
+
def call
|
5
|
+
result[:toc] = String.new('')
|
6
|
+
|
7
|
+
headers = Hash.new(1)
|
8
|
+
doc.css('h1, h2, h3, h4, h5, h6').each do |node|
|
9
|
+
text = node.text
|
10
|
+
id = ascii_downcase(text)
|
11
|
+
id.gsub!(PUNCTUATION_REGEXP, '') # remove punctuation
|
12
|
+
id.tr!(' ', '-') # replace spaces with dash
|
13
|
+
|
14
|
+
uniq = headers[id] > 1 ? "-#{headers[id]}" : ''
|
15
|
+
headers[id] += 1
|
16
|
+
if header_content = node.children.first
|
17
|
+
result[:toc] << %(<li><a href="##{id}#{uniq}">#{CGI.escape_html(text)}</a></li>\n)
|
18
|
+
header_content.add_previous_sibling(%(<a id="#{id}#{uniq}" class="anchor" href="##{id}#{uniq}" aria-hidden="true">#{anchor_icon}</a>))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
result[:toc] = %(<ul class="section-nav">\n#{result[:toc]}</ul>) unless result[:toc].empty?
|
22
|
+
doc
|
23
|
+
end
|
24
|
+
|
25
|
+
if RUBY_VERSION >= '2.4'
|
26
|
+
def ascii_downcase(str)
|
27
|
+
str.downcase(:ascii)
|
28
|
+
end
|
29
|
+
else
|
30
|
+
def ascii_downcase(str)
|
31
|
+
str.downcase
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -3,6 +3,7 @@ require 'github/markup'
|
|
3
3
|
require 'html/pipeline'
|
4
4
|
require 'pathname'
|
5
5
|
require "vimwiki_markdown/vimwiki_link"
|
6
|
+
require "vimwiki_markdown/vimwiki_toc_filter"
|
6
7
|
|
7
8
|
class VimwikiMarkdown::WikiBody
|
8
9
|
|
@@ -23,7 +24,7 @@ class VimwikiMarkdown::WikiBody
|
|
23
24
|
|
24
25
|
pipeline = HTML::Pipeline.new([
|
25
26
|
HTML::Pipeline::SyntaxHighlightFilter,
|
26
|
-
|
27
|
+
VimwikiTOCFilter
|
27
28
|
], { scope: "highlight"})
|
28
29
|
@result = pipeline.call(html)
|
29
30
|
@result = @result[:output].to_s
|
@@ -43,6 +43,11 @@ module VimwikiMarkdown
|
|
43
43
|
expect(Options.new.output_fullpath).to eq("#{subject.output_dir}name-with-spaces.html")
|
44
44
|
end
|
45
45
|
|
46
|
+
it "must not change filenames if paramteriezed returns an empty string" do
|
47
|
+
allow_any_instance_of(Options).to receive(:input_file) { "~/foo/世界.md" }
|
48
|
+
expect(Options.new.output_fullpath).to eq("#{subject.output_dir}世界.html")
|
49
|
+
end
|
50
|
+
|
46
51
|
it "must correctly deal with filenames with capitalization issues" do
|
47
52
|
allow_any_instance_of(Options).to receive(:input_file) { "~/foo/NAME WITH SPACES.md" }
|
48
53
|
expect(Options.new.output_fullpath).to eq("#{subject.output_dir}name-with-spaces.html")
|
@@ -68,6 +68,17 @@ module VimwikiMarkdown
|
|
68
68
|
expect(link.to_s).to eq("[test](#{existing_file_no_extension}.html#wiki-heading)")
|
69
69
|
end
|
70
70
|
|
71
|
+
context "with chinese or unparamaterizable chars" do
|
72
|
+
let(:existing_file) { "世界#{markdown_extension}" }
|
73
|
+
|
74
|
+
it "must convert same-directory markdown links without paramaterization correctly" do
|
75
|
+
markdown_link = "[test](#{existing_file_no_extension})"
|
76
|
+
|
77
|
+
link = VimwikiLink.new(markdown_link, source_filepath, markdown_extension, root_path, output_dir)
|
78
|
+
expect(link.to_s).to eq("[test](#{existing_file_no_extension}.html)")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
71
82
|
context "subdirectory linked files" do
|
72
83
|
let(:existing_file) { "subdirectory/test.md" }
|
73
84
|
|
data/vimwiki_markdown.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler"
|
21
|
+
spec.add_development_dependency "bundler"
|
22
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"
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
|
30
30
|
spec.add_runtime_dependency "activesupport", "~> 4.1"
|
31
31
|
spec.add_runtime_dependency "github-markup", "~> 3.0"
|
32
|
-
spec.add_runtime_dependency "commonmarker", "~> 0.
|
32
|
+
spec.add_runtime_dependency "commonmarker", "~> 0.23.4"
|
33
33
|
spec.add_runtime_dependency "html-pipeline", "~> 2.0"
|
34
34
|
spec.add_runtime_dependency "rouge", "~> 3.3"
|
35
35
|
spec.add_runtime_dependency "escape_utils", "~> 1.2"
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vimwiki_markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Davey
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
159
|
+
version: 0.23.4
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
166
|
+
version: 0.23.4
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: html-pipeline
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,6 +220,8 @@ files:
|
|
220
220
|
- ".rspec"
|
221
221
|
- ".rubocop.yml"
|
222
222
|
- ".travis.yml"
|
223
|
+
- A.png
|
224
|
+
- B.png
|
223
225
|
- Gemfile
|
224
226
|
- Guardfile
|
225
227
|
- LICENSE.txt
|
@@ -234,6 +236,7 @@ files:
|
|
234
236
|
- lib/vimwiki_markdown/template.rb
|
235
237
|
- lib/vimwiki_markdown/version.rb
|
236
238
|
- lib/vimwiki_markdown/vimwiki_link.rb
|
239
|
+
- lib/vimwiki_markdown/vimwiki_toc_filter.rb
|
237
240
|
- lib/vimwiki_markdown/wiki_body.rb
|
238
241
|
- spec/lib/vimwiki_markdown/options_spec.rb
|
239
242
|
- spec/lib/vimwiki_markdown/template_spec.rb
|
@@ -245,7 +248,7 @@ homepage: https://github.com/patrickdavey/wimwiki_markdown
|
|
245
248
|
licenses:
|
246
249
|
- MIT
|
247
250
|
metadata: {}
|
248
|
-
post_install_message:
|
251
|
+
post_install_message:
|
249
252
|
rdoc_options: []
|
250
253
|
require_paths:
|
251
254
|
- lib
|
@@ -260,8 +263,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
260
263
|
- !ruby/object:Gem::Version
|
261
264
|
version: '0'
|
262
265
|
requirements: []
|
263
|
-
rubygems_version: 3.
|
264
|
-
signing_key:
|
266
|
+
rubygems_version: 3.2.3
|
267
|
+
signing_key:
|
265
268
|
specification_version: 4
|
266
269
|
summary: Converts a github flavoured markdown vimwiki file into html.
|
267
270
|
test_files:
|