paru 0.2.5 → 0.2.5.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e35691d50c4e8cf7e53951d9ba6988dc42137720
|
4
|
+
data.tar.gz: c9f3c94e69dd101e0f9f369e531ae7e5ce74681b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd6440963be644a3833c2902bd403d30f66785efdfe0c7f34997b172dac19356da484e232b924339c35e7fb3905940e723f875834da2a68b16976758929c4b42
|
7
|
+
data.tar.gz: 3d4c0c55ab5ab82c4d129afdbe2a779ea54f20ecdcec1dd6a42e1680d6e26eae37ad98a07871a7160e4f9167c80743bab8adca4d91b22d293fa71bec1ab6a0b2
|
data/lib/paru/pandoc.rb
CHANGED
@@ -19,6 +19,8 @@
|
|
19
19
|
require "shellwords"
|
20
20
|
require "yaml"
|
21
21
|
|
22
|
+
require_relative "error.rb"
|
23
|
+
|
22
24
|
module Paru
|
23
25
|
# Pandoc is a wrapper around the pandoc document converter. See
|
24
26
|
# <http://pandoc.org/README.html> for details about pandoc. The Pandoc
|
@@ -76,6 +78,9 @@ module Paru
|
|
76
78
|
#
|
77
79
|
#
|
78
80
|
class Pandoc
|
81
|
+
|
82
|
+
# Path to the pandoc executatble to use by paru.
|
83
|
+
PARU_PANDOC_PATH = "PARU_PANDOC_PATH"
|
79
84
|
|
80
85
|
# Gather information about the pandoc installation. It runs +pandoc
|
81
86
|
# --version+ and extracts pandoc's version number and default data
|
@@ -85,18 +90,7 @@ module Paru
|
|
85
90
|
# @return [Hash{:version => String, :data_dir => String}] Pandoc's
|
86
91
|
# version, such as "1.17.0.4" and the data directory, such as "/home/huub/.pandoc".
|
87
92
|
def self.info()
|
88
|
-
|
89
|
-
IO.popen('pandoc --version', 'r+') do |p|
|
90
|
-
p.close_write
|
91
|
-
output << p.read
|
92
|
-
end
|
93
|
-
version = output.match(/pandoc (\d+\.\d+.*)$/)[1]
|
94
|
-
data_dir = output.match(/Default user data directory: (.+)$/)[1]
|
95
|
-
|
96
|
-
{
|
97
|
-
:version => version,
|
98
|
-
:data_dir => data_dir
|
99
|
-
}
|
93
|
+
@@info
|
100
94
|
end
|
101
95
|
|
102
96
|
# Create a new Pandoc converter, optionally configured by a block with
|
@@ -153,6 +147,7 @@ module Paru
|
|
153
147
|
# @example Using <<
|
154
148
|
# output = converter << 'this is a *strong* word'
|
155
149
|
def convert(input)
|
150
|
+
begin
|
156
151
|
output = ''
|
157
152
|
IO.popen(to_command, 'r+') do |p|
|
158
153
|
p << input
|
@@ -160,6 +155,9 @@ module Paru
|
|
160
155
|
output << p.read
|
161
156
|
end
|
162
157
|
output
|
158
|
+
rescue StandardError => err
|
159
|
+
throw Error.new "Error while running '#{to_command}' on input:\n\n#{input}\n\nPandoc responds: '#{err.message}'"
|
160
|
+
end
|
163
161
|
end
|
164
162
|
alias << convert
|
165
163
|
|
@@ -169,7 +167,7 @@ module Paru
|
|
169
167
|
# @param option_sep [String] the string to separate options with
|
170
168
|
# @return [String] This converter's command line invocation string.
|
171
169
|
def to_command(option_sep = " \\\n\t")
|
172
|
-
"
|
170
|
+
"#{@@pandoc_exec.shellescape}\t#{to_option_string option_sep}"
|
173
171
|
end
|
174
172
|
|
175
173
|
private
|
@@ -199,8 +197,42 @@ module Paru
|
|
199
197
|
options_arr.join(option_sep)
|
200
198
|
end
|
201
199
|
|
200
|
+
# determine pandoc_executable to use in paru
|
201
|
+
@@pandoc_exec = if ENV.has_key? PARU_PANDOC_PATH
|
202
|
+
ENV[PARU_PANDOC_PATH]
|
203
|
+
else
|
204
|
+
"pandoc"
|
205
|
+
end
|
206
|
+
|
207
|
+
begin
|
208
|
+
version_string = ''
|
209
|
+
IO.popen("#{@@pandoc_exec} --version", 'r+') do |p|
|
210
|
+
p.close_write
|
211
|
+
version_string << p.read
|
212
|
+
end
|
213
|
+
rescue StandardError => err
|
214
|
+
throw Error.new "Unable to run pandoc via command '#{@@pandoc_exec} --version': #{err.message}"
|
215
|
+
end
|
216
|
+
|
217
|
+
version = version_string.match(/pandoc (\d+\.\d+.*)$/)[1]
|
218
|
+
data_dir = version_string.match(/Default user data directory: (.+)$/)[1]
|
219
|
+
|
220
|
+
@@info = {
|
221
|
+
:version => version,
|
222
|
+
:data_dir => data_dir
|
223
|
+
}
|
224
|
+
|
225
|
+
# Load the options for the appropriate major version of pandoc
|
226
|
+
major_version = @@info[:version].split(".").first.to_i
|
227
|
+
|
228
|
+
if not [1, 2].include? major_version
|
229
|
+
throw Error.new "Unknown major pandoc version: '#{major_version}'. Expected the major version to be '1' or '2'. Please check the pandoc path: '#{@@pandoc_exec}'."
|
230
|
+
# defaults to version 1
|
231
|
+
major_version = 1
|
232
|
+
end
|
233
|
+
|
202
234
|
# For each pandoc command line option a method is defined as follows:
|
203
|
-
OPTIONS = YAML.load_file File.join(__dir__,
|
235
|
+
OPTIONS = YAML.load_file File.join(__dir__, "pandoc_options_version_#{major_version}.yaml")
|
204
236
|
|
205
237
|
OPTIONS.keys.each do |option|
|
206
238
|
if OPTIONS[option].is_a? Array then
|
@@ -17,6 +17,7 @@
|
|
17
17
|
# along with Paru. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
# See http://pandoc.org/README.html for an overview of all options
|
19
19
|
#++
|
20
|
+
# Options for pandoc version 1.x, in order of occurrence in the pandoc manual.
|
20
21
|
# General options
|
21
22
|
from: ""
|
22
23
|
read: ""
|
@@ -0,0 +1,111 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2015, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
|
3
|
+
#
|
4
|
+
# This file is part of Paru
|
5
|
+
#
|
6
|
+
# Paru is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Paru is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with Paru. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
# See http://pandoc.org/README.html for an overview of all options
|
19
|
+
#++
|
20
|
+
# In order as listed in the output of `pandoc- h` for pandoc version 2.x
|
21
|
+
from: ""
|
22
|
+
read: ""
|
23
|
+
to: ""
|
24
|
+
write: ""
|
25
|
+
output: ""
|
26
|
+
data_dir: ""
|
27
|
+
base_header_level: 1
|
28
|
+
indented-code-classes: ""
|
29
|
+
filter: [""]
|
30
|
+
lua-filter: [""]
|
31
|
+
preserver-tabs: true
|
32
|
+
tab-stop: 4
|
33
|
+
track-changes: "accept"
|
34
|
+
file-scope: ""
|
35
|
+
extract-media: ""
|
36
|
+
standalone: true
|
37
|
+
template: ""
|
38
|
+
metadata: [""]
|
39
|
+
variable: [""]
|
40
|
+
print-default-template: ""
|
41
|
+
print-default-data-file: ""
|
42
|
+
dpi: 96
|
43
|
+
eol: "native"
|
44
|
+
wrap: "auto"
|
45
|
+
columns: 78
|
46
|
+
toc: true
|
47
|
+
table-of-contents: true
|
48
|
+
no-highlight: true
|
49
|
+
highlight-style: ""
|
50
|
+
syntax-definition: ""
|
51
|
+
include-in-header: [""]
|
52
|
+
include-before-body: [""]
|
53
|
+
include-after-body: [""]
|
54
|
+
resource-path: ""
|
55
|
+
self-contained: true
|
56
|
+
html-q-tags: true
|
57
|
+
ascii: true
|
58
|
+
reference-links: true
|
59
|
+
reference-location: "block"
|
60
|
+
atx-headers: ""
|
61
|
+
top-level-division: "section"
|
62
|
+
number-sections: true
|
63
|
+
number-offset: 2
|
64
|
+
listings: true
|
65
|
+
incremental: true
|
66
|
+
slide-level: 1
|
67
|
+
section-divs: true
|
68
|
+
default-image-extension: "png"
|
69
|
+
email-obfuscation: "none"
|
70
|
+
id-prefix: ""
|
71
|
+
title-prefix: ""
|
72
|
+
css: [""]
|
73
|
+
reference-doc: ""
|
74
|
+
epub-subdirectory: ""
|
75
|
+
epub-cover-image: ""
|
76
|
+
epub-metadata: ""
|
77
|
+
epub-embed-font: ""
|
78
|
+
epub-chapter-level: 1
|
79
|
+
latex-engine: ""
|
80
|
+
latex-engine-opt: ""
|
81
|
+
bibliography: ""
|
82
|
+
csl: ""
|
83
|
+
citation-abbreviation: ""
|
84
|
+
natbib: true
|
85
|
+
biblatex: true
|
86
|
+
latexmathml: ""
|
87
|
+
asciimathml: ""
|
88
|
+
mathml: true
|
89
|
+
mimetex: ""
|
90
|
+
webtex: ""
|
91
|
+
jsmath: ""
|
92
|
+
mathjax: ""
|
93
|
+
katex: ""
|
94
|
+
katex-stylesheet: ""
|
95
|
+
gladtex: true
|
96
|
+
abbreviations: ""
|
97
|
+
trace: true
|
98
|
+
dump-args: true
|
99
|
+
ignore-args: true
|
100
|
+
verbose: true
|
101
|
+
quiet: true
|
102
|
+
fail-if-warnings: true
|
103
|
+
log: ""
|
104
|
+
bash-completion: true
|
105
|
+
list_input_formats: true
|
106
|
+
list_output_formats: true
|
107
|
+
list_extensions: true
|
108
|
+
list_highlight_languages: true
|
109
|
+
list_highlight_styles: true
|
110
|
+
version: true
|
111
|
+
help: true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.5
|
4
|
+
version: 0.2.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Huub de Beer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Use Pandoc (http://www.pandoc.org) with ruby
|
14
14
|
email: Huub@heerdebeer.org
|
@@ -84,7 +84,8 @@ files:
|
|
84
84
|
- lib/paru/filter_error.rb
|
85
85
|
- lib/paru/pandoc.rb
|
86
86
|
- lib/paru/pandoc2yaml.rb
|
87
|
-
- lib/paru/
|
87
|
+
- lib/paru/pandoc_options_version_1.yaml
|
88
|
+
- lib/paru/pandoc_options_version_2.yaml
|
88
89
|
- lib/paru/selector.rb
|
89
90
|
homepage: https://heerdebeer.org/Software/markdown/paru/
|
90
91
|
licenses:
|
@@ -106,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
107
|
version: '0'
|
107
108
|
requirements: []
|
108
109
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.5.2
|
110
111
|
signing_key:
|
111
112
|
specification_version: 4
|
112
113
|
summary: Paru is a ruby wrapper around pandoc
|