pandoc-ruby 2.1.3 → 2.1.4
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/README.md +28 -23
- data/lib/pandoc-ruby.rb +2 -2
- data/pandoc-ruby.gemspec +2 -2
- data/test/test_pandoc_ruby.rb +47 -1
- 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: 7ec374a42893d6b60b7b22ab158a0c1aaa5eaad560523ff4f9fb57272587f20d
|
4
|
+
data.tar.gz: f6c841353fa08a7182276fff06eb5bcef5e36d95a3560ca3ae7114048ac48156
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
8
|
-
DocBook, LaTeX,
|
9
|
-
|
10
|
-
OpenDocument XML, ODT, GNU Texinfo, MediaWiki
|
11
|
-
HTML slide shows, EPUB,
|
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,
|
16
|
-
[install Pandoc](http://johnmacfarlane.net/pandoc/installing.html).
|
15
|
+
First, [install Pandoc](http://johnmacfarlane.net/pandoc/installing.html).
|
17
16
|
|
18
|
-
|
17
|
+
PandocRuby is available on [RubyGems](http://rubygems.org/gems/pandoc-ruby):
|
19
18
|
|
20
|
-
```
|
21
|
-
gem
|
19
|
+
```bash
|
20
|
+
gem install pandoc-ruby
|
22
21
|
```
|
23
22
|
|
24
|
-
|
23
|
+
To install with [Bundler](https://bundler.io/), add the following to your
|
24
|
+
Gemfile:
|
25
25
|
|
26
|
-
```
|
27
|
-
gem
|
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
|
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
|
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
|
-
|
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
|
-
|
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`
|
data/lib/pandoc-ruby.rb
CHANGED
@@ -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)}
|
308
|
+
elsif argument.to_s =~ /\s/
|
309
|
+
"#{format_flag(flag)} \"#{argument}\""
|
310
310
|
else
|
311
311
|
"#{format_flag(flag)} #{argument}"
|
312
312
|
end
|
data/pandoc-ruby.gemspec
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = 'pandoc-ruby'
|
8
|
-
s.version = '2.1.
|
8
|
+
s.version = '2.1.4'
|
9
9
|
s.authors = ['William Melody']
|
10
|
-
s.date = '2020-03-
|
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 = [
|
data/test/test_pandoc_ruby.rb
CHANGED
@@ -154,7 +154,23 @@ describe PandocRuby do
|
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
|
-
it '
|
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.
|
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-
|
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
|