vimwiki_markdown 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e37c0a3c822ebbda20854bb19ea14a7d0e528c06
4
- data.tar.gz: 12f867ec84d491a59e58e2baed0eb625c1bf4b47
3
+ metadata.gz: b00af17960fc23705d96d60e6dd3ab4036f8b12b
4
+ data.tar.gz: 6f6d35477b555f7abf47e6c2cc23291a7ab56252
5
5
  SHA512:
6
- metadata.gz: 812bcf4b95827c58ec36ed25329078067d10a48edbb093fd038b14cafe5fcad51fe9421f278865af915bd3dc6c879edb51c14fd5c7807ae94be08ff0a2143eaa
7
- data.tar.gz: 9f801937fa659e5b5b68b036dffcc40869a85aa8ca494e10dc2243c25c53f324abb92b60ba5dcfec0ee269a5c1820bc3bc48576d369e08fb200de162e50cc3f7
6
+ metadata.gz: 99fadb55eb3b50e44132e3644da44950b798a23ce6caca3e57f82b4a0b430489250078e438bdf50ce8134cd952e2424a143705bcdf61f1be008d62981f79100c
7
+ data.tar.gz: ff30cca42e3ff6c5d741cbd9e2a721438b62163a012d86be2be1bb9de2ab1e96d14dbb349f465452c3a38c3d59010725f628bcb9925c57c3de07c6bf2ddd1722
data/Guardfile CHANGED
@@ -1,11 +1,5 @@
1
1
  guard :rspec, cmd: 'bundle exec rspec' do
2
- # watch /spec/ files
3
- watch(%r{^spec/(.+).rb$}) do |m|
4
- "spec/#{m[1]}.rb"
5
- end
6
-
7
- # watch /lib/ files
8
- watch(%r{^lib/(.+).rb$}) do |m|
9
- "spec/#{m[1]}_spec.rb"
10
- end
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" }
11
5
  end
data/README.md CHANGED
@@ -5,19 +5,43 @@ to be converted to HTML.
5
5
 
6
6
  It is currently a work in progress (but working for me ;)
7
7
 
8
- ## Installation
8
+ ## Requirements
9
9
 
10
- Add this line to your application's Gemfile:
10
+ Ruby installed on your computer
11
11
 
12
- gem 'vimwiki_markdown'
12
+ https://www.ruby-lang.org/en/installation/
13
13
 
14
- And then execute:
14
+ Install the vimwiki_markdown gem
15
15
 
16
- $ bundle
16
+ $ gem install vimwiki_markdown
17
17
 
18
- Or install it yourself as:
18
+ Note, the current version of vimwiki does not allow binaries to be called
19
+ for the generation of html. This was added on the master branch in [this commit](https://github.com/vimwiki/vimwiki/commit/c1a5bb51adc8cacaa70e2804106817b68295f932)
20
+
21
+ Currently you will need to make sure you are running the dev branch of vimwiki, or add that commit in yourself
22
+
23
+ ## Setup
24
+
25
+ Ensure that your vimiwiki directive in your .vimrc is setup for markdown. For
26
+ this we use the custom_wiki2html parameter. My .vimrc looks like this:
27
+
28
+ let g:vimwiki_list = [{'path': '~/vimwiki', 'template_path': '~/vimwiki/templates/',
29
+ \ 'template_default': 'default', 'syntax': 'markdown', 'ext': '.md',
30
+ \ 'path_html': '~/vimwiki/site_html/', 'custom_wiki2html': 'vimwiki_markdown',
31
+ \ 'template_ext': '.tpl'}]
32
+
33
+ The most important part is the *'custom_wiki2html': 'vimwiki_markdown'*
34
+
35
+ ### VimWiki Template
36
+
37
+ It is a requirement that your template file contain a placeholder
38
+ for the syntax highlighting code to be placed. In order to do this,
39
+ open up your default.tpl (or whatever your template file is called)
40
+ and ensure that before the closing </head> tag you put
41
+ `%pygments%`
42
+
43
+ A sample tpl file is available here https://raw.githubusercontent.com/patrickdavey/vimwiki_markdown/master/example_files/default.tpl
19
44
 
20
- $ gem install vimwiki_markdown
21
45
 
22
46
  ## Contributing
23
47
 
@@ -26,3 +50,8 @@ Or install it yourself as:
26
50
  3. Commit your changes (`git commit -am 'Add some feature'`)
27
51
  4. Push to the branch (`git push origin my-new-feature`)
28
52
  5. Create a new Pull Request
53
+
54
+
55
+ ## License
56
+
57
+ [MIT License](http://opensource.org/licenses/mit-license.php)
data/changelog.md ADDED
@@ -0,0 +1,7 @@
1
+ ## 0.0.3 [Oct 30th 2014]
2
+
3
+ * Raise warning if pygments placeholder is not present
4
+
5
+ ## 0.0.2 [Sept 2014]
6
+
7
+ * Initial beta release of the vimwiki_markdown gem
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>%title%</title>
5
+
6
+ %pygments%
7
+ </head>
8
+ <body id="%title%">
9
+ <h2 id="title">%title%</h2>
10
+ %content%
11
+ </body>
12
+ </html>
@@ -0,0 +1,4 @@
1
+ module VimwikiMarkdown
2
+ class MissingRequiredParamError < StandardError
3
+ end
4
+ end
@@ -7,6 +7,7 @@ module VimwikiMarkdown
7
7
  @options = options
8
8
  get_template_contents
9
9
 
10
+ validate_template
10
11
  end
11
12
 
12
13
  def to_s
@@ -24,11 +25,21 @@ module VimwikiMarkdown
24
25
  end
25
26
 
26
27
  def fixtags(template)
27
- @template = template.gsub('%title%',title).gsub('%pygments%', Pygments.css('.highlight'))
28
+ @template = template.gsub('%title%',title).gsub('%pygments%',pygments_wrapped_in_tags)
29
+ end
30
+
31
+ def pygments_wrapped_in_tags
32
+ "<style type=\"text/css\">
33
+ #{Pygments.css('.highlight')}
34
+ </style>"
28
35
  end
29
36
 
30
37
  def title
31
38
  options.title
32
39
  end
40
+
41
+ def validate_template
42
+ raise MissingRequiredParamError.new("ERROR: vimwiki template must contain %pygments% placeholder token. Please visit https://github.com/patrickdavey/vimwiki_markdown for more information") unless @template =~ /%pygments%/
43
+ end
33
44
  end
34
45
  end
@@ -1,3 +1,3 @@
1
1
  module VimwikiMarkdown
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -2,6 +2,7 @@ require "vimwiki_markdown/version"
2
2
  require "vimwiki_markdown/options"
3
3
  require "vimwiki_markdown/template"
4
4
  require "vimwiki_markdown/wiki_body"
5
+ require "vimwiki_markdown/exceptions"
5
6
 
6
7
  module VimwikiMarkdown
7
8
  def self.convert_wikimardown_to_html
@@ -13,5 +14,9 @@ module VimwikiMarkdown
13
14
  combined_body_template = template_html.to_s.gsub('%content%', body_html.to_s)
14
15
 
15
16
  File.write(options.output_fullpath, combined_body_template)
17
+
18
+ rescue MissingRequiredParamError => e
19
+ warn e.message
20
+ exit(0)
16
21
  end
17
22
  end
@@ -1,13 +1,14 @@
1
1
  require 'spec_helper'
2
2
  require 'vimwiki_markdown/options'
3
3
  require 'vimwiki_markdown/template'
4
+ require 'vimwiki_markdown/exceptions'
4
5
  require 'rspec-html-matchers'
5
6
 
6
7
  module VimwikiMarkdown
7
8
  describe Template do
9
+ let(:options) { Options.new }
8
10
 
9
11
  context "template" do
10
- let(:options) { Options.new }
11
12
 
12
13
  subject { Template.new(options).to_s }
13
14
  before do
@@ -18,5 +19,16 @@ module VimwikiMarkdown
18
19
  it { should have_tag('title', text: 'Index') }
19
20
  it { should have_tag('h2', text: 'Index') }
20
21
  end
22
+
23
+ context "missing pygments" do
24
+ before do
25
+ allow(Options).to receive(:arguments).and_return(Options::DEFAULTS)
26
+ end
27
+
28
+ it "should raise an invalid exception for missing pygments" do
29
+ allow(File).to receive(:open).with(options.template_filename,"r").and_return(StringIO.new(template_missing_pygments))
30
+ expect { Template.new(options).to_s }.to raise_exception(MissingRequiredParamError)
31
+ end
32
+ end
21
33
  end
22
34
  end
data/spec/spec_helper.rb CHANGED
@@ -128,9 +128,8 @@ def wiki_template
128
128
  </script>
129
129
  <title>%title%</title>
130
130
  <meta http-equiv="Content-Type" content="text/html; charset=%encoding%">
131
- <style>
132
- %pygments%
133
- </style>
131
+
132
+ %pygments%
134
133
  </head>
135
134
  <body id="%title%">
136
135
  <div class="navbar navbar-inverse navbar-fixed-top">
@@ -153,3 +152,7 @@ def wiki_template
153
152
  </html>
154
153
  WIKITEMPLATE
155
154
  end
155
+
156
+ def template_missing_pygments
157
+ wiki_template.gsub!('%pygments%','')
158
+ end
@@ -1,4 +1,3 @@
1
- require 'pry'
2
1
  # coding: utf-8
3
2
  lib = File.expand_path('../lib', __FILE__)
4
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -22,15 +21,15 @@ Gem::Specification.new do |spec|
22
21
  spec.add_development_dependency "bundler", "~> 1.6"
23
22
  spec.add_development_dependency "rake"
24
23
  spec.add_development_dependency "rspec", "~> 3.0"
25
- spec.add_development_dependency "pry"
26
- spec.add_development_dependency "rspec-its"
27
- spec.add_development_dependency "rspec-html-matchers"
28
- spec.add_development_dependency "guard-rspec"
24
+ spec.add_development_dependency "pry", ">= 0.9.12"
25
+ spec.add_development_dependency "rspec-its", "~> 1.1.0"
26
+ spec.add_development_dependency "rspec-html-matchers", "~> 0.6.1"
27
+ spec.add_development_dependency "guard-rspec", "~> 4.3"
29
28
 
30
29
  spec.add_runtime_dependency "activesupport", "~> 4.1.6"
31
- spec.add_runtime_dependency "github-markup"
32
- spec.add_runtime_dependency "github-markdown"
30
+ spec.add_runtime_dependency "github-markup", "~> 1.3.0"
31
+ spec.add_runtime_dependency "github-markdown", "~> 0.6.7"
33
32
  spec.add_runtime_dependency "github-linguist", "~> 3.1.5"
34
33
  spec.add_runtime_dependency "redcarpet", "~> 3.1.2"
35
- spec.add_runtime_dependency "html-pipeline"
34
+ spec.add_runtime_dependency "html-pipeline", "~> 1.11.0"
36
35
  end
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.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Davey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-14 00:00:00.000000000 Z
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,56 +58,56 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.9.12
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 0.9.12
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec-its
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 1.1.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: 1.1.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec-html-matchers
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 0.6.1
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 0.6.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: guard-rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: '4.3'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: '4.3'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: activesupport
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -126,30 +126,30 @@ dependencies:
126
126
  name: github-markup
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '0'
131
+ version: 1.3.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '0'
138
+ version: 1.3.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: github-markdown
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ">="
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '0'
145
+ version: 0.6.7
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ">="
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '0'
152
+ version: 0.6.7
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: github-linguist
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -182,16 +182,16 @@ dependencies:
182
182
  name: html-pipeline
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ">="
185
+ - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: '0'
187
+ version: 1.11.0
188
188
  type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ">="
192
+ - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: '0'
194
+ version: 1.11.0
195
195
  description: Converts a vimwiki markdown file to html. It parses [[links]] and has
196
196
  support for syntax highlighting.
197
197
  email:
@@ -209,15 +209,18 @@ files:
209
209
  - README.md
210
210
  - Rakefile
211
211
  - bin/vimwiki_markdown
212
+ - changelog.md
213
+ - example_files/default.tpl
212
214
  - lib/vimwiki_markdown.rb
215
+ - lib/vimwiki_markdown/exceptions.rb
213
216
  - lib/vimwiki_markdown/options.rb
214
217
  - lib/vimwiki_markdown/template.rb
215
218
  - lib/vimwiki_markdown/version.rb
216
219
  - lib/vimwiki_markdown/wiki_body.rb
217
- - spec/options_spec.rb
220
+ - spec/lib/vimwiki_markdown/options_spec.rb
221
+ - spec/lib/vimwiki_markdown/template_spec.rb
222
+ - spec/lib/vimwiki_markdown/wiki_body_spec.rb
218
223
  - spec/spec_helper.rb
219
- - spec/template_spec.rb
220
- - spec/wiki_body_spec.rb
221
224
  - vimwiki_markdown.gemspec
222
225
  homepage: https://github.com/patrickdavey/wimwiki_markdown
223
226
  licenses:
@@ -244,7 +247,7 @@ signing_key:
244
247
  specification_version: 4
245
248
  summary: Converts a github flavoured markdown vimwiki file into html.
246
249
  test_files:
247
- - spec/options_spec.rb
250
+ - spec/lib/vimwiki_markdown/options_spec.rb
251
+ - spec/lib/vimwiki_markdown/template_spec.rb
252
+ - spec/lib/vimwiki_markdown/wiki_body_spec.rb
248
253
  - spec/spec_helper.rb
249
- - spec/template_spec.rb
250
- - spec/wiki_body_spec.rb