pandoc-ruby 2.1.0 → 2.1.1

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: cbbaf2248f0a6fa408258b8d8a49c19f78e2688a81ee5000f8c23f4d0eb1bebc
4
- data.tar.gz: b819cb5b8406a798a6dcc6a7c472e34ff286e4882edbb076d72482a6202ceba6
3
+ metadata.gz: 560fc0d0f2fe55196b4f1d981d66748af59d29f7b86afa4797fd25109d7ad04c
4
+ data.tar.gz: 991843c076e7816e99ba11778190e4a0e2b0385f9659a0e5579ecbc5b743d4e0
5
5
  SHA512:
6
- metadata.gz: f96d584f2c2998282a714cbdb86acdd87243505edafc85b4d8efe2fda1d5645f7e0a4f49d104e07bec12f7dce5e55fe91ad251210d3af1146f9c2aaf62c6eebc
7
- data.tar.gz: cfd58d1cd5fd113a9a700b4dae8b87399d9d2affe9c9727832ca6e12584d5e1b1fd279545bf94a065b35fd61b529a9dbdbeee79070f60b40bdcd0b83f96dc39e
6
+ metadata.gz: 8ef270181fe562d955430d0e7fd8198d3a6ddffb4737c2b725f30a7333cd6d49ec36b1e16e72ce7c11273445506b9a861a0cbd42c2a0be15e6ac6d11e2086e04
7
+ data.tar.gz: a70b8400f8d38bebce010bab5dc8be1ac6b4559b1ad332b237fb2befea15d9080e4850d5a1aab68160513a269000be9c4f3549862b726b092e3fff5047666dfd
data/README.md CHANGED
@@ -10,9 +10,6 @@ markdown, reStructuredText, HTML, LaTeX, ConTeXt, PDF, RTF, DocBook XML,
10
10
  OpenDocument XML, ODT, GNU Texinfo, MediaWiki markup, groff man pages,
11
11
  HTML slide shows, EPUB, and Microsoft Word docx.
12
12
 
13
- *This documentation is for version 2 and higher. For version 1 documentation
14
- [see here](https://github.com/xwmx/pandoc-ruby/blob/v1.0.0/README.markdown).*
15
-
16
13
  ## Installation
17
14
 
18
15
  First, make sure to
@@ -34,7 +31,7 @@ gem install pandoc-ruby
34
31
 
35
32
  ```ruby
36
33
  require 'pandoc-ruby'
37
- @converter = PandocRuby.new('# Markdown Title', :from => :markdown, :to => :rst)
34
+ @converter = PandocRuby.new('# Markdown Title', from: :markdown, to: :rst)
38
35
  puts @converter.convert
39
36
  ```
40
37
 
@@ -43,7 +40,7 @@ This takes the Markdown formatted file and converts it to reStructuredText.
43
40
  You can also use the `#convert` class method:
44
41
 
45
42
  ```ruby
46
- puts PandocRuby.convert('# Markdown Title', :from => :markdown, :to => :html)
43
+ puts PandocRuby.convert('# Markdown Title', from: :markdown, to: :html)
47
44
  ```
48
45
 
49
46
  Other arguments are simply converted into command line options, accepting
@@ -51,7 +48,7 @@ symbols or strings for options without arguments and hashes of strings or
51
48
  symbols for options with arguments.
52
49
 
53
50
  ```ruby
54
- PandocRuby.convert('# Markdown Title', :s, {:f => :markdown, :to => :rst}, 'no-wrap', :table_of_contents)
51
+ PandocRuby.convert('# Markdown Title', :s, {f: :markdown, to: :rst}, 'no-wrap', :table_of_contents)
55
52
  ```
56
53
 
57
54
  is equivalent to
@@ -83,17 +80,45 @@ PandocRuby assumes the `pandoc` executable is via your environment's `$PATH`
83
80
  variable. If you'd like to set an explicit path to the `pandoc` executable,
84
81
  you can do so with `PandocRuby.pandoc_path = '/path/to/pandoc'`
85
82
 
83
+ ### Converting Files
84
+
86
85
  PandocRuby can also take an array of one or more file paths as the first
87
86
  argument. The files will be concatenated together with a blank line between
88
87
  each and used as input.
89
88
 
90
89
  ```ruby
91
90
  # One file path as a single-element array.
92
- PandocRuby.html(['/path/to/file1.html']).to_markdown
91
+ PandocRuby.new(['/path/to/file1.docx'], from: 'docx').to_html
93
92
  # Multiple file paths as an array.
94
- PandocRuby.html(['/path/to/file1.html', '/path/to/file2.html']).to_markdown
93
+ PandocRuby.new(['/path/to/file1.docx', '/path/to/file1.docx'], from: 'docx').to_html
94
+ ```
95
+
96
+ If you are trying to generate a standalone file with full file headers rather
97
+ than just a marked up fragment, remember to pass the `:standalone` option so
98
+ the correct header and footer are added.
99
+
100
+ ```ruby
101
+ PandocRuby.new("# Some title", :standalone).to_rtf
102
+ ```
103
+
104
+ ### Extensions
105
+
106
+ Pandoc [extensions](https://pandoc.org/MANUAL.html#extensions) can be
107
+ used to modify the behavior of readers and writers. To use an extension,
108
+ add the extension with a `+` or `-` after the reader or writer name:
109
+
110
+ ```ruby
111
+ # Without extension
112
+ PandocRuby.new("Line 1\n# Heading", from: 'markdown_strict').to_html
113
+ # => "<p>Line 1</p>\n<h1>Heading</h1>\n"
114
+
115
+ # With extension:
116
+ >> PandocRuby.new("Line 1\n# Heading", from: 'markdown_strict+blank_before_header').to_html
117
+ # => "<p>Line 1 # Heading</p>\n
95
118
  ```
96
119
 
120
+ ### More Information
121
+
97
122
  Available format readers and writers are available in the `PandocRuby::READERS`
98
123
  and `PandocRuby::WRITERS` constants.
99
124
 
@@ -103,24 +128,15 @@ or run `man pandoc`
103
128
  ([also available here](http://johnmacfarlane.net/pandoc/pandoc.1.html)).
104
129
 
105
130
  If you'd prefer a pure-Ruby extended markdown interpreter that can output a
106
- few different formats, take a look at [Maruku](http://maruku.rubyforge.org/).
107
- If you want to use the full reStructuredText syntax from within Ruby, check
108
- out [RbST](https://github.com/xwmx/rbst), a docutils wrapper.
131
+ few different formats, take a look at
132
+ [kramdown](https://kramdown.gettalong.org/). If you want to use the full
133
+ reStructuredText syntax from within Ruby, check out
134
+ [RbST](https://github.com/xwmx/rbst), a docutils wrapper.
109
135
 
110
136
  This gem was inspired by [Albino](http://github.com/github/albino). For a
111
137
  slightly different approach to using Pandoc with Ruby, see
112
138
  [Pandoku](http://github.com/dahlia/pandoku).
113
139
 
114
- ## Additional Notes
115
-
116
- If you are trying to generate a standalone file with full file headers rather
117
- than just a marked up fragment, remember to pass the `:standalone` option so
118
- the correct header and footer are added.
119
-
120
- ```ruby
121
- PandocRuby.new("# Some title", :standalone).to_rtf
122
- ```
123
-
124
140
  ## Note on Patches/Pull Requests
125
141
 
126
142
  * Fork the project.
@@ -8,49 +8,105 @@ class PandocRuby
8
8
  # The available readers and their corresponding names. The keys are used to
9
9
  # generate methods and specify options to Pandoc.
10
10
  READERS = {
11
- 'native' => 'pandoc native',
12
- 'json' => 'pandoc JSON',
13
- 'markdown' => 'markdown',
14
- 'rst' => 'reStructuredText',
15
- 'textile' => 'textile',
16
- 'html' => 'HTML',
17
- 'latex' => 'LaTeX'
11
+ 'commonmark' => 'CommonMark Markdown',
12
+ 'creole' => 'Creole 1.0',
13
+ 'csv' => 'CSV table',
14
+ 'docbook' => 'DocBook',
15
+ 'docx' => 'Word docx',
16
+ 'dokuwiki' => 'DokuWiki markup',
17
+ 'epub' => 'EPUB',
18
+ 'fb2' => 'FictionBook2 e-book',
19
+ 'gfm' => 'GitHub-Flavored Markdown',
20
+ 'haddock' => 'Haddock markup',
21
+ 'html' => 'HTML',
22
+ 'ipynb' => 'Jupyter notebook',
23
+ 'jats' => 'JATS XML',
24
+ 'jira' => 'Jira wiki markup',
25
+ 'json' => 'JSON version of native AST',
26
+ 'latex' => 'LaTex',
27
+ 'man' => 'roff man',
28
+ 'markdown' => "Pandoc's Markdown",
29
+ 'markdown_mmd' => 'MultiMarkdown',
30
+ 'markdown_phpextra' => 'PHP Markdown Extra',
31
+ 'markdown_strict' => 'original unextended Markdown',
32
+ 'mediawiki' => 'MediaWiki markup',
33
+ 'muse' => 'Muse',
34
+ 'native' => 'native Haskell',
35
+ 'odt' => 'ODT',
36
+ 'opml' => 'OPML',
37
+ 'org' => 'Emacs Org mode',
38
+ 'rst' => 'reStructuredText',
39
+ 't2t' => 'txt2tags',
40
+ 'textile' => 'Textile',
41
+ 'tikiwiki' => 'TikiWiki markup',
42
+ 'twiki' => 'TWiki markup',
43
+ 'vimwiki' => 'Vimwiki'
18
44
  }.freeze
19
45
 
20
46
  # The available string writers and their corresponding names. The keys are
21
47
  # used to generate methods and specify options to Pandoc.
22
48
  STRING_WRITERS = {
23
- 'native' => 'pandoc native',
24
- 'json' => 'pandoc JSON',
25
- 'html' => 'HTML',
26
- 'html5' => 'HTML5',
27
- 's5' => 'S5 HTML slideshow',
28
- 'slidy' => 'Slidy HTML slideshow',
29
- 'dzslides' => 'Dzslides HTML slideshow',
30
- 'docbook' => 'DocBook XML',
31
- 'opendocument' => 'OpenDocument XML',
32
- 'latex' => 'LaTeX',
33
- 'beamer' => 'Beamer PDF slideshow',
34
- 'context' => 'ConTeXt',
35
- 'texinfo' => 'GNU Texinfo',
36
- 'man' => 'groff man',
37
- 'markdown' => 'markdown',
38
- 'plain' => 'plain',
39
- 'rst' => 'reStructuredText',
40
- 'mediawiki' => 'MediaWiki markup',
41
- 'textile' => 'textile',
42
- 'rtf' => 'rich text format',
43
- 'org' => 'emacs org mode',
44
- 'asciidoc' => 'asciidoc'
49
+ 'asciidoc' => 'AsciiDoc',
50
+ 'asciidoctor' => 'AsciiDoctor',
51
+ 'beamer' => 'LaTeX beamer slide show',
52
+ 'commonmark' => 'CommonMark Markdown',
53
+ 'context' => 'ConTeXt',
54
+ 'docbook' => 'DocBook 4',
55
+ 'docbook4' => 'DocBook 4',
56
+ 'docbook5' => 'DocBook 5',
57
+ 'dokuwiki' => 'DokuWiki markup',
58
+ 'fb2' => 'FictionBook2 e-book',
59
+ 'gfm' => 'GitHub-Flavored Markdown',
60
+ 'haddock' => 'Haddock markup',
61
+ 'html' => 'HTML, i.e. HTML5/XHTML polyglot markup',
62
+ 'html5' => 'HTML, i.e. HTML5/XHTML polyglot markup',
63
+ 'html4' => 'XHTML 1.0 Transitional',
64
+ 'icml' => 'InDesign ICML',
65
+ 'ipynb' => 'Jupyter notebook',
66
+ 'jats_archiving' => 'JATS XML, Archiving and Interchange Tag Set',
67
+ 'jats_articleauthoring' => 'JATS XML, Article Authoring Tag Set',
68
+ 'jats_publishing' => 'JATS XML, Journal Publishing Tag Set',
69
+ 'jats' => 'alias for jats_archiving',
70
+ 'jira' => 'Jira wiki markup',
71
+ 'json' => 'JSON version of native AST',
72
+ 'latex' => 'LaTex',
73
+ 'man' => 'roff man',
74
+ 'markdown' => "Pandoc's Markdown",
75
+ 'markdown_mmd' => 'MultiMarkdown',
76
+ 'markdown_phpextra' => 'PHP Markdown Extra',
77
+ 'markdown_strict' => 'original unextended Markdown',
78
+ 'mediawiki' => 'MediaWiki markup',
79
+ 'ms' => 'roff ms',
80
+ 'muse' => 'Muse',
81
+ 'native' => 'native Haskell',
82
+ 'opml' => 'OPML',
83
+ 'opendocument' => 'OpenDocument',
84
+ 'org' => 'Emacs Org mode',
85
+ 'pdf' => 'PDF',
86
+ 'plain' => 'plain text',
87
+ 'pptx' => 'PowerPoint slide show',
88
+ 'rst' => 'reStructuredText',
89
+ 'rtf' => 'Rich Text Format',
90
+ 'texinfo' => 'GNU Texinfo',
91
+ 'textile' => 'Textile',
92
+ 'slideous' => 'Slideous HTML and JavaScript slide show',
93
+ 'slidy' => 'Slidy HTML and JavaScript slide show',
94
+ 'dzslides' => 'DZSlides HTML5 + JavaScript slide show',
95
+ 'revealjs' => 'reveal.js HTML5 + JavaScript slide show',
96
+ 's5' => 'S5 HTML and JavaScript slide show',
97
+ 'tei' => 'TEI Simple',
98
+ 'xwiki' => 'XWiki markup',
99
+ 'zimwiki' => 'ZimWiki markup'
45
100
  }.freeze
46
101
 
47
102
  # The available binary writers and their corresponding names. The keys are
48
103
  # used to generate methods and specify options to Pandoc.
49
104
  BINARY_WRITERS = {
50
- 'odt' => 'OpenDocument',
105
+ 'odt' => 'OpenOffice text document',
51
106
  'docx' => 'Word docx',
52
- 'epub' => 'EPUB V2',
53
- 'epub3' => 'EPUB V3'
107
+ 'epub' => 'EPUB v2',
108
+ 'epub2' => 'EPUB v2',
109
+ 'epub3' => 'EPUB v3'
54
110
  }.freeze
55
111
 
56
112
  # All of the available Writers.
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = 'pandoc-ruby'
8
- s.version = '2.1.0'
8
+ s.version = '2.1.1'
9
9
  s.authors = ['William Melody']
10
10
  s.date = '2020-03-23'
11
11
  s.description = 'Ruby wrapper for Pandoc'
@@ -75,7 +75,7 @@ describe PandocRuby do
75
75
  assert converter.convert(:s, { :f => :markdown, :to => :rst }, 'no-wrap')
76
76
  end
77
77
 
78
- it 'converts underscore symbol ares to hyphenated long options' do
78
+ it 'converts underscore symbol args to hyphenated long options' do
79
79
  converter = PandocRuby.new(@string, {
80
80
  :email_obfuscation => :javascript
81
81
  }, :table_of_contents)
@@ -92,6 +92,44 @@ describe PandocRuby do
92
92
  assert converter.convert
93
93
  end
94
94
 
95
+ it 'supports reader extensions' do
96
+ assert_equal(
97
+ PandocRuby.convert(
98
+ "Line 1\n# Heading",
99
+ :from => 'markdown_strict',
100
+ :to => 'html'
101
+ ),
102
+ "<p>Line 1</p>\n<h1>Heading</h1>\n"
103
+ )
104
+ assert_equal(
105
+ PandocRuby.convert(
106
+ "Line 1\n# Heading",
107
+ :from => 'markdown_strict+blank_before_header',
108
+ :to => 'html'
109
+ ),
110
+ "<p>Line 1 # Heading</p>\n"
111
+ )
112
+ end
113
+
114
+ it 'supports writer extensions' do
115
+ assert_equal(
116
+ PandocRuby.convert(
117
+ "<sub>example</sub>\n",
118
+ :from => 'html',
119
+ :to => 'markdown'
120
+ ),
121
+ "~example~\n"
122
+ )
123
+ assert_equal(
124
+ PandocRuby.convert(
125
+ "<sub>example</sub>\n",
126
+ :from => 'html',
127
+ :to => 'markdown-subscript'
128
+ ),
129
+ "<sub>example</sub>\n"
130
+ )
131
+ end
132
+
95
133
  it 'raises RuntimeError from pandoc executable error' do
96
134
  assert_raises(RuntimeError) do
97
135
  PandocRuby.new('# hello', 'badopt').to_html5
@@ -177,46 +215,110 @@ Pandoc no longer times out with test file. Determine how to test.
177
215
  end
178
216
 
179
217
  it 'has reader and writer constants' do
180
- assert_equal PandocRuby::READERS,
181
- 'html' => 'HTML',
182
- 'latex' => 'LaTeX',
183
- 'textile' => 'textile',
184
- 'native' => 'pandoc native',
185
- 'markdown' => 'markdown',
186
- 'json' => 'pandoc JSON',
187
- 'rst' => 'reStructuredText'
188
-
189
- assert_equal PandocRuby::STRING_WRITERS,
190
- 'mediawiki' => 'MediaWiki markup',
191
- 'html' => 'HTML',
192
- 'plain' => 'plain',
193
- 'latex' => 'LaTeX',
194
- 's5' => 'S5 HTML slideshow',
195
- 'textile' => 'textile',
196
- 'texinfo' => 'GNU Texinfo',
197
- 'docbook' => 'DocBook XML',
198
- 'html5' => 'HTML5',
199
- 'native' => 'pandoc native',
200
- 'org' => 'emacs org mode',
201
- 'rtf' => 'rich text format',
202
- 'markdown' => 'markdown',
203
- 'man' => 'groff man',
204
- 'dzslides' => 'Dzslides HTML slideshow',
205
- 'beamer' => 'Beamer PDF slideshow',
206
- 'json' => 'pandoc JSON',
207
- 'opendocument' => 'OpenDocument XML',
208
- 'slidy' => 'Slidy HTML slideshow',
209
- 'rst' => 'reStructuredText',
210
- 'context' => 'ConTeXt',
211
- 'asciidoc' => 'asciidoc'
212
-
213
- assert_equal PandocRuby::BINARY_WRITERS,
214
- 'odt' => 'OpenDocument',
215
- 'docx' => 'Word docx',
216
- 'epub' => 'EPUB V2',
217
- 'epub3' => 'EPUB V3'
218
-
219
- assert_equal PandocRuby::WRITERS,
220
- PandocRuby::STRING_WRITERS.merge(PandocRuby::BINARY_WRITERS)
218
+ assert_equal(
219
+ PandocRuby::READERS,
220
+ 'commonmark' => 'CommonMark Markdown',
221
+ 'creole' => 'Creole 1.0',
222
+ 'csv' => 'CSV table',
223
+ 'docbook' => 'DocBook',
224
+ 'docx' => 'Word docx',
225
+ 'dokuwiki' => 'DokuWiki markup',
226
+ 'epub' => 'EPUB',
227
+ 'fb2' => 'FictionBook2 e-book',
228
+ 'gfm' => 'GitHub-Flavored Markdown',
229
+ 'haddock' => 'Haddock markup',
230
+ 'html' => 'HTML',
231
+ 'ipynb' => 'Jupyter notebook',
232
+ 'jats' => 'JATS XML',
233
+ 'jira' => 'Jira wiki markup',
234
+ 'json' => 'JSON version of native AST',
235
+ 'latex' => 'LaTex',
236
+ 'man' => 'roff man',
237
+ 'markdown' => "Pandoc's Markdown",
238
+ 'markdown_mmd' => 'MultiMarkdown',
239
+ 'markdown_phpextra' => 'PHP Markdown Extra',
240
+ 'markdown_strict' => 'original unextended Markdown',
241
+ 'mediawiki' => 'MediaWiki markup',
242
+ 'muse' => 'Muse',
243
+ 'native' => 'native Haskell',
244
+ 'odt' => 'ODT',
245
+ 'opml' => 'OPML',
246
+ 'org' => 'Emacs Org mode',
247
+ 'rst' => 'reStructuredText',
248
+ 't2t' => 'txt2tags',
249
+ 'textile' => 'Textile',
250
+ 'tikiwiki' => 'TikiWiki markup',
251
+ 'twiki' => 'TWiki markup',
252
+ 'vimwiki' => 'Vimwiki'
253
+ )
254
+
255
+ assert_equal(
256
+ PandocRuby::STRING_WRITERS,
257
+ 'asciidoc' => 'AsciiDoc',
258
+ 'asciidoctor' => 'AsciiDoctor',
259
+ 'beamer' => 'LaTeX beamer slide show',
260
+ 'commonmark' => 'CommonMark Markdown',
261
+ 'context' => 'ConTeXt',
262
+ 'docbook' => 'DocBook 4',
263
+ 'docbook4' => 'DocBook 4',
264
+ 'docbook5' => 'DocBook 5',
265
+ 'dokuwiki' => 'DokuWiki markup',
266
+ 'fb2' => 'FictionBook2 e-book',
267
+ 'gfm' => 'GitHub-Flavored Markdown',
268
+ 'haddock' => 'Haddock markup',
269
+ 'html' => 'HTML, i.e. HTML5/XHTML polyglot markup',
270
+ 'html5' => 'HTML, i.e. HTML5/XHTML polyglot markup',
271
+ 'html4' => 'XHTML 1.0 Transitional',
272
+ 'icml' => 'InDesign ICML',
273
+ 'ipynb' => 'Jupyter notebook',
274
+ 'jats_archiving' => 'JATS XML, Archiving and Interchange Tag Set',
275
+ 'jats_articleauthoring' => 'JATS XML, Article Authoring Tag Set',
276
+ 'jats_publishing' => 'JATS XML, Journal Publishing Tag Set',
277
+ 'jats' => 'alias for jats_archiving',
278
+ 'jira' => 'Jira wiki markup',
279
+ 'json' => 'JSON version of native AST',
280
+ 'latex' => 'LaTex',
281
+ 'man' => 'roff man',
282
+ 'markdown' => "Pandoc's Markdown",
283
+ 'markdown_mmd' => 'MultiMarkdown',
284
+ 'markdown_phpextra' => 'PHP Markdown Extra',
285
+ 'markdown_strict' => 'original unextended Markdown',
286
+ 'mediawiki' => 'MediaWiki markup',
287
+ 'ms' => 'roff ms',
288
+ 'muse' => 'Muse',
289
+ 'native' => 'native Haskell',
290
+ 'opml' => 'OPML',
291
+ 'opendocument' => 'OpenDocument',
292
+ 'org' => 'Emacs Org mode',
293
+ 'pdf' => 'PDF',
294
+ 'plain' => 'plain text',
295
+ 'pptx' => 'PowerPoint slide show',
296
+ 'rst' => 'reStructuredText',
297
+ 'rtf' => 'Rich Text Format',
298
+ 'texinfo' => 'GNU Texinfo',
299
+ 'textile' => 'Textile',
300
+ 'slideous' => 'Slideous HTML and JavaScript slide show',
301
+ 'slidy' => 'Slidy HTML and JavaScript slide show',
302
+ 'dzslides' => 'DZSlides HTML5 + JavaScript slide show',
303
+ 'revealjs' => 'reveal.js HTML5 + JavaScript slide show',
304
+ 's5' => 'S5 HTML and JavaScript slide show',
305
+ 'tei' => 'TEI Simple',
306
+ 'xwiki' => 'XWiki markup',
307
+ 'zimwiki' => 'ZimWiki markup'
308
+ )
309
+
310
+ assert_equal(
311
+ PandocRuby::BINARY_WRITERS,
312
+ 'odt' => 'OpenOffice text document',
313
+ 'docx' => 'Word docx',
314
+ 'epub' => 'EPUB v2',
315
+ 'epub2' => 'EPUB v2',
316
+ 'epub3' => 'EPUB v3'
317
+ )
318
+
319
+ assert_equal(
320
+ PandocRuby::WRITERS,
321
+ PandocRuby::STRING_WRITERS.merge(PandocRuby::BINARY_WRITERS)
322
+ )
221
323
  end
222
324
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pandoc-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Melody