pandoc-ruby 2.1.3 → 2.1.4

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: 650e0986f59f42561631dfdce08087dceb3de5e5b29e1f14172238aa035ea364
4
- data.tar.gz: e8b2c8d850877561d3c7336fdc9aa1ae2f3282be0f3e8f7de12211f7d64c0bc1
3
+ metadata.gz: 7ec374a42893d6b60b7b22ab158a0c1aaa5eaad560523ff4f9fb57272587f20d
4
+ data.tar.gz: f6c841353fa08a7182276fff06eb5bcef5e36d95a3560ca3ae7114048ac48156
5
5
  SHA512:
6
- metadata.gz: 8bf133e569fcdcd1bff4367d532cf076677e6535e803fe737034871897a6b4ec25994a3a9c56f3913510d32c7d7560142881ab852b6d989bd7f491a4d0fac579
7
- data.tar.gz: fa7eb59f4b16126a3b838dfd91932080a0ff2eb7a9613f7c7a6041c1dfa74831fc56d3af87d60fbc4916449aa620d3e99cdf613cf119b32421e154d63d134d9f
6
+ metadata.gz: a81a3373767b06a74a75bc0c15edb546071d7ccbbd588f5ca5a5f075065b7ad02acbe71c90fb111e1cebf5d666798ca11b426f5222faef4bf5c33523bee14127
7
+ data.tar.gz: 65b26a50284f935ded2d61b895fc492d8fa04a1fd51bd45d13aa7da2aba657a8c96b4f4e7cd2595cde6ecaaa49bbf94a6c76c3c6b42c559ebd477604f20e5ce9
data/README.md CHANGED
@@ -4,29 +4,31 @@ PandocRuby is a wrapper for [Pandoc](http://johnmacfarlane.net/pandoc/), a
4
4
  Haskell library with command line tools for converting one markup format to
5
5
  another.
6
6
 
7
- Pandoc can convert documents in markdown, reStructuredText, textile, HTML,
8
- DocBook, LaTeX, or MediaWiki markup to a variety of formats, including
9
- markdown, reStructuredText, HTML, LaTeX, ConTeXt, PDF, RTF, DocBook XML,
10
- OpenDocument XML, ODT, GNU Texinfo, MediaWiki markup, groff man pages,
11
- HTML slide shows, EPUB, and Microsoft Word docx.
7
+ Pandoc can convert documents from a variety of formats including markdown,
8
+ reStructuredText, textile, HTML, DocBook, LaTeX, and MediaWiki markup to a
9
+ variety of other formats, including markdown, reStructuredText, HTML, LaTeX,
10
+ ConTeXt, PDF, RTF, DocBook XML, OpenDocument XML, ODT, GNU Texinfo, MediaWiki
11
+ markup, groff man pages, HTML slide shows, EPUB, Microsoft Word docx, and more.
12
12
 
13
13
  ## Installation
14
14
 
15
- First, make sure to
16
- [install Pandoc](http://johnmacfarlane.net/pandoc/installing.html).
15
+ First, [install Pandoc](http://johnmacfarlane.net/pandoc/installing.html).
17
16
 
18
- Next, add PandocRuby to your Gemfile
17
+ PandocRuby is available on [RubyGems](http://rubygems.org/gems/pandoc-ruby):
19
18
 
20
- ```ruby
21
- gem 'pandoc-ruby'
19
+ ```bash
20
+ gem install pandoc-ruby
22
21
  ```
23
22
 
24
- or install PandocRuby from [RubyGems](http://rubygems.org/gems/pandoc-ruby).
23
+ To install with [Bundler](https://bundler.io/), add the following to your
24
+ Gemfile:
25
25
 
26
- ```bash
27
- gem install pandoc-ruby
26
+ ```ruby
27
+ gem 'pandoc-ruby'
28
28
  ```
29
29
 
30
+ Then run `bundle install`
31
+
30
32
  ## Usage
31
33
 
32
34
  ```ruby
@@ -35,7 +37,7 @@ require 'pandoc-ruby'
35
37
  puts @converter.convert
36
38
  ```
37
39
 
38
- This takes the Markdown formatted file and converts it to reStructuredText.
40
+ This takes the Markdown formatted string and converts it to reStructuredText.
39
41
 
40
42
  You can also use the `#convert` class method:
41
43
 
@@ -44,8 +46,7 @@ puts PandocRuby.convert('# Markdown Title', from: :markdown, to: :html)
44
46
  ```
45
47
 
46
48
  Other arguments are simply converted into command line options, accepting
47
- symbols or strings for options without arguments and hashes of strings or
48
- symbols for options with arguments.
49
+ symbols and strings for options and hashes for options with arguments.
49
50
 
50
51
  ```ruby
51
52
  PandocRuby.convert('# Markdown Title', :s, {f: :markdown, to: :rst}, '--wrap=none', :table_of_contents)
@@ -76,7 +77,14 @@ PandocRuby.html("<h1>hello</h1>").to_latex
76
77
  # => "\\section{hello}"
77
78
  ```
78
79
 
79
- PandocRuby assumes the `pandoc` executable is via your environment's `$PATH`
80
+ Available readers and writers are can be found in the following
81
+ variables:
82
+ - [`PandocRuby::READERS`](lib/pandoc-ruby.rb#L10)
83
+ - [`PandocRuby::STRING_WRITERS`](lib/pandoc-ruby.rb#L48)
84
+ - [`PandocRuby::BINARY_WRITERS`](lib/pandoc-ruby.rb#L104)
85
+ - [`PandocRuby::WRITERS`](lib/pandoc-ruby.rb#L113)
86
+
87
+ PandocRuby assumes the `pandoc` executable is in your environment's `$PATH`
80
88
  variable. If you'd like to set an explicit path to the `pandoc` executable,
81
89
  you can do so with `PandocRuby.pandoc_path = '/path/to/pandoc'`
82
90
 
@@ -108,20 +116,17 @@ used to modify the behavior of readers and writers. To use an extension,
108
116
  add the extension with a `+` or `-` after the reader or writer name:
109
117
 
110
118
  ```ruby
111
- # Without extension
119
+ # Without extension:
112
120
  PandocRuby.new("Line 1\n# Heading", from: 'markdown_strict').to_html
113
121
  # => "<p>Line 1</p>\n<h1>Heading</h1>\n"
114
122
 
115
- # With extension:
116
- >> PandocRuby.new("Line 1\n# Heading", from: 'markdown_strict+blank_before_header').to_html
123
+ # With `+blank_before_header` extension:
124
+ PandocRuby.new("Line 1\n# Heading", from: 'markdown_strict+blank_before_header').to_html
117
125
  # => "<p>Line 1 # Heading</p>\n
118
126
  ```
119
127
 
120
128
  ### More Information
121
129
 
122
- Available format readers and writers are available in the `PandocRuby::READERS`
123
- and `PandocRuby::WRITERS` constants.
124
-
125
130
  For more information on Pandoc, see the
126
131
  [Pandoc documentation](http://johnmacfarlane.net/pandoc/)
127
132
  or run `man pandoc`
@@ -305,8 +305,8 @@ class PandocRuby
305
305
 
306
306
  if argument.nil?
307
307
  format_flag(flag)
308
- elsif argument =~ /\s/
309
- "#{format_flag(flag)} '#{argument}'"
308
+ elsif argument.to_s =~ /\s/
309
+ "#{format_flag(flag)} \"#{argument}\""
310
310
  else
311
311
  "#{format_flag(flag)} #{argument}"
312
312
  end
@@ -5,9 +5,9 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = 'pandoc-ruby'
8
- s.version = '2.1.3'
8
+ s.version = '2.1.4'
9
9
  s.authors = ['William Melody']
10
- s.date = '2020-03-23'
10
+ s.date = '2020-03-25'
11
11
  s.description = 'Ruby wrapper for Pandoc'
12
12
  s.email = 'hi@williammelody.com'
13
13
  s.extra_rdoc_files = [
@@ -154,7 +154,23 @@ describe PandocRuby do
154
154
  end
155
155
  end
156
156
 
157
- it 'supports output filenames without spaces' do
157
+ it 'quotes output filenames with spaces' do
158
+ Tempfile.create('example with spaces') do |file|
159
+ converter = PandocRuby.new(
160
+ '# Example',
161
+ :from => 'markdown',
162
+ :to => 'html',
163
+ :output => file.path
164
+ )
165
+ converter \
166
+ .expects(:execute) \
167
+ .with("pandoc --from markdown --to html --output \"#{file.path}\"") \
168
+ .returns(true)
169
+ assert converter.convert
170
+ end
171
+ end
172
+
173
+ it 'outputs to filenames with spaces' do
158
174
  Tempfile.create('example with spaces') do |file|
159
175
  PandocRuby.convert(
160
176
  '# Example',
@@ -162,6 +178,36 @@ describe PandocRuby do
162
178
  :to => 'html',
163
179
  :output => file.path
164
180
  )
181
+
182
+ file.rewind
183
+ assert_equal("<h1 id=\"example\">Example</h1>\n", file.read)
184
+ end
185
+ end
186
+
187
+ it 'quotes output filenames as Pathname objects' do
188
+ Tempfile.create('example with spaces') do |file|
189
+ converter = PandocRuby.new(
190
+ '# Example',
191
+ :from => 'markdown',
192
+ :to => 'html',
193
+ :output => Pathname.new(file.path)
194
+ )
195
+ converter \
196
+ .expects(:execute) \
197
+ .with("pandoc --from markdown --to html --output \"#{file.path}\"") \
198
+ .returns(true)
199
+ assert converter.convert
200
+ end
201
+ end
202
+
203
+ it 'outputs to filenames as Pathname objects' do
204
+ Tempfile.create('example with spaces') do |file|
205
+ PandocRuby.convert(
206
+ '# Example',
207
+ :from => 'markdown',
208
+ :to => 'html',
209
+ :output => Pathname.new(file.path)
210
+ )
165
211
  file.rewind
166
212
  assert_equal("<h1 id=\"example\">Example</h1>\n", file.read)
167
213
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pandoc-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.3
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Melody
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-23 00:00:00.000000000 Z
11
+ date: 2020-03-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby wrapper for Pandoc
14
14
  email: hi@williammelody.com