paru 0.4.1.2 → 0.4.2.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 +4 -4
- data/lib/paru/filter/caption.rb +4 -0
- data/lib/paru/filter/cell.rb +7 -2
- data/lib/paru/filter/document.rb +1 -1
- data/lib/paru/filter/int_value.rb +39 -0
- data/lib/paru/filter/row.rb +8 -1
- data/lib/paru/filter/table.rb +12 -9
- data/lib/paru/filter/table_body.rb +6 -2
- data/lib/paru/filter/table_end.rb +8 -1
- data/lib/paru/pandoc.rb +16 -19
- data/lib/paru/pandoc_options_version_2.yaml +8 -5
- data/lib/paru.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4922ee36a90c757e70a7b386cd25496c748a441191f1ea61160ab949aaa3672f
|
4
|
+
data.tar.gz: '0882bda88d548eb798bc526d76c38b85c3e64a2308a77a167146a6a6656fd6b6'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e20858edc2f613c76592e4f4ef8daba573298d3d843234e64aa2f06fb5d94890ebf125000a287efff2395decf1d25907b1cb09fd023a31578b5866ac3651f142
|
7
|
+
data.tar.gz: 66181db17a164acfb7776e2cf4f06f56cf6b757122da039dacbfd8b032f2b5e4b3f296fa1752013d6b343652ce961a4efab200d8b05a983b32fc08b6a816aaa1
|
data/lib/paru/filter/caption.rb
CHANGED
data/lib/paru/filter/cell.rb
CHANGED
@@ -18,6 +18,7 @@
|
|
18
18
|
#++
|
19
19
|
require_relative "./block.rb"
|
20
20
|
require_relative "./value.rb"
|
21
|
+
require_relative "./int_value.rb"
|
21
22
|
|
22
23
|
module Paru
|
23
24
|
module PandocFilter
|
@@ -44,8 +45,8 @@ module Paru
|
|
44
45
|
def initialize(contents)
|
45
46
|
@attr = Attr.new contents[0]
|
46
47
|
@alignment = Value.new contents[1]
|
47
|
-
@rowspan =
|
48
|
-
@colspan =
|
48
|
+
@rowspan = IntValue.new contents[2]
|
49
|
+
@colspan = IntValue.new contents[3]
|
49
50
|
|
50
51
|
super contents[4]
|
51
52
|
end
|
@@ -62,6 +63,10 @@ module Paru
|
|
62
63
|
@children.map {|child| child.to_ast}
|
63
64
|
]
|
64
65
|
end
|
66
|
+
|
67
|
+
def to_ast()
|
68
|
+
ast_contents()
|
69
|
+
end
|
65
70
|
end
|
66
71
|
end
|
67
72
|
end
|
data/lib/paru/filter/document.rb
CHANGED
@@ -36,7 +36,7 @@ module Paru
|
|
36
36
|
|
37
37
|
# The current pandoc type version
|
38
38
|
# @see https://hackage.haskell.org/package/pandoc-types
|
39
|
-
CURRENT_PANDOC_VERSION = [1,
|
39
|
+
CURRENT_PANDOC_VERSION = [1, 22]
|
40
40
|
|
41
41
|
# Each file that is being filtered by pandoc is represented by a root
|
42
42
|
# Document. It is the root node of the AST of the document in the file.
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2020 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
|
+
#++
|
19
|
+
require_relative "./node.rb"
|
20
|
+
require_relative "../filter_error.rb"
|
21
|
+
|
22
|
+
module Paru
|
23
|
+
module PandocFilter
|
24
|
+
|
25
|
+
# An IntValue represents some sort of integer metadata about block or
|
26
|
+
# inline nodes
|
27
|
+
class IntValue
|
28
|
+
attr_accessor :value
|
29
|
+
|
30
|
+
def initialize(value)
|
31
|
+
@value = value
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_ast()
|
35
|
+
@value
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/paru/filter/row.rb
CHANGED
@@ -38,7 +38,10 @@ module Paru
|
|
38
38
|
# this Row node
|
39
39
|
def initialize(contents = [])
|
40
40
|
@attr = Attr.new contents[0]
|
41
|
-
super
|
41
|
+
super []
|
42
|
+
contents[1].each do |cell|
|
43
|
+
@children.push Cell.new cell
|
44
|
+
end
|
42
45
|
end
|
43
46
|
|
44
47
|
# The cells of this row
|
@@ -58,6 +61,10 @@ module Paru
|
|
58
61
|
]
|
59
62
|
end
|
60
63
|
|
64
|
+
def to_ast()
|
65
|
+
ast_contents()
|
66
|
+
end
|
67
|
+
|
61
68
|
# Convert this Row to an array of markdown strings, one for
|
62
69
|
# each cell
|
63
70
|
#
|
data/lib/paru/filter/table.rb
CHANGED
@@ -54,11 +54,14 @@ module Paru
|
|
54
54
|
# @param contents [Array]
|
55
55
|
def initialize(contents)
|
56
56
|
@attr = Attr.new contents[0]
|
57
|
-
@caption = Caption.new contents[1]
|
57
|
+
@caption = Caption.new contents[1]
|
58
58
|
@colspec = contents[2].map {|p| ColSpec.new p}
|
59
|
-
@head = TableHead.new contents[3]
|
60
|
-
super
|
61
|
-
|
59
|
+
@head = TableHead.new contents[3]
|
60
|
+
super []
|
61
|
+
contents[4].each do |table_body|
|
62
|
+
@children.push TableBody.new table_body
|
63
|
+
end
|
64
|
+
@foot = TableFoot.new contents[5]
|
62
65
|
end
|
63
66
|
|
64
67
|
# The AST contents of this Table node
|
@@ -83,7 +86,7 @@ module Paru
|
|
83
86
|
#
|
84
87
|
# @return [String[][]] This Table as a 2D array of cells
|
85
88
|
# represented by their markdown strings.
|
86
|
-
def to_array(
|
89
|
+
def to_array(config = {})
|
87
90
|
headers = if config.has_key? :headers then config[:headers] else false end
|
88
91
|
footers = if config.has_key? :footers then config[:footers] else false end
|
89
92
|
|
@@ -108,9 +111,9 @@ module Paru
|
|
108
111
|
#
|
109
112
|
# @param filename [String] filename to write to
|
110
113
|
# @param config [Hash] See #to_array for config options
|
111
|
-
def to_file(filename,
|
114
|
+
def to_file(filename, config = {})
|
112
115
|
CSV.open(filename, "wb") do |csv|
|
113
|
-
to_array(config).each {|row| csv << row}
|
116
|
+
to_array(**config).each {|row| csv << row}
|
114
117
|
end
|
115
118
|
end
|
116
119
|
|
@@ -127,7 +130,7 @@ module Paru
|
|
127
130
|
# default to false.
|
128
131
|
#
|
129
132
|
# @return [Table]
|
130
|
-
def self.from_array(data,
|
133
|
+
def self.from_array(data, config = {})
|
131
134
|
# With the updated Table definition, it has become complicated
|
132
135
|
# to construct a table manually. It has gotten easier to just
|
133
136
|
# construct a string containing a table in Pandoc's markdown and
|
@@ -177,7 +180,7 @@ module Paru
|
|
177
180
|
# @param config [Hash] See #from_file for details
|
178
181
|
#
|
179
182
|
# @return [Table]
|
180
|
-
def self.from_file(filename,
|
183
|
+
def self.from_file(filename, config = {})
|
181
184
|
data = []
|
182
185
|
CSV.foreach(filename) do |row|
|
183
186
|
data << row
|
@@ -44,12 +44,12 @@ module Paru
|
|
44
44
|
# @param contents [Array] The contents of this TableBody
|
45
45
|
def initialize(contents)
|
46
46
|
@attr = Attr.new contents[0]
|
47
|
-
@rowheadcolumns =
|
47
|
+
@rowheadcolumns = IntValue.new contents[1]
|
48
48
|
@rowheadercolumns = contents[2].map {|r| Row.new r}
|
49
49
|
|
50
50
|
super []
|
51
51
|
contents[3].each do |row|
|
52
|
-
@children.push Row.new row
|
52
|
+
@children.push Row.new row
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -71,6 +71,10 @@ module Paru
|
|
71
71
|
@children.map {|child| child.to_ast}
|
72
72
|
]
|
73
73
|
end
|
74
|
+
|
75
|
+
def to_ast()
|
76
|
+
ast_contents()
|
77
|
+
end
|
74
78
|
|
75
79
|
# Convert this table end to a 2D table of markdown strings for each
|
76
80
|
# cell
|
@@ -38,7 +38,10 @@ module Paru
|
|
38
38
|
# @param contents [Array]
|
39
39
|
def initialize(contents)
|
40
40
|
@attr = Attr.new contents[0]
|
41
|
-
super
|
41
|
+
super []
|
42
|
+
contents[1].each do |row|
|
43
|
+
@children.push Row.new row
|
44
|
+
end
|
42
45
|
end
|
43
46
|
|
44
47
|
def rows()
|
@@ -54,6 +57,10 @@ module Paru
|
|
54
57
|
@children.map {|row| row.to_ast},
|
55
58
|
]
|
56
59
|
end
|
60
|
+
|
61
|
+
def to_ast()
|
62
|
+
ast_contents()
|
63
|
+
end
|
57
64
|
|
58
65
|
# Convert this table end to a 2D table of markdown strings for each
|
59
66
|
# cell
|
data/lib/paru/pandoc.rb
CHANGED
@@ -230,26 +230,23 @@ module Paru
|
|
230
230
|
.match(/pandoc.* (\d+\.\d+.*)$/)[1]
|
231
231
|
.split(".")
|
232
232
|
.map {|s| s.to_i}
|
233
|
-
major_version
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
else
|
248
|
-
# Neither data directory exists, default to the new default
|
249
|
-
data_dir = xdg_data_dir
|
250
|
-
end
|
233
|
+
major_version = version[0]
|
234
|
+
|
235
|
+
# Pandoc version 2.7 introduced a new default data dir to comply
|
236
|
+
# with XDG Base Directory Specification
|
237
|
+
|
238
|
+
xdg_data_dir, old_data_dir = version_string.match(/User data directory: (.+)$/)[1].split(" or ")
|
239
|
+
|
240
|
+
if File.directory? xdg_data_dir then
|
241
|
+
data_dir = xdg_data_dir
|
242
|
+
elsif not old_data_dir.nil? and File.directory? old_data_dir then
|
243
|
+
# The new-style data directory does not exist, but the
|
244
|
+
# old-style does, so use the old-style data directory for
|
245
|
+
# backwards compatibility
|
246
|
+
data_dir = old_data_dir
|
251
247
|
else
|
252
|
-
|
248
|
+
# Neither data directory exists, default to the new default
|
249
|
+
data_dir = xdg_data_dir
|
253
250
|
end
|
254
251
|
|
255
252
|
@@info = {
|
@@ -44,8 +44,10 @@ help: true
|
|
44
44
|
# General reader options:
|
45
45
|
#####
|
46
46
|
shift_heading_level_by: 1
|
47
|
+
base_header_level: 1
|
48
|
+
strip_empty_paragraphs: true
|
47
49
|
indented_code_classes: ""
|
48
|
-
default_image_extension: ""
|
50
|
+
default_image_extension: "png"
|
49
51
|
file_scope: true
|
50
52
|
filter: [""]
|
51
53
|
lua_filter: [""]
|
@@ -59,6 +61,7 @@ abbreviations: ""
|
|
59
61
|
#####
|
60
62
|
# General writing options:
|
61
63
|
#####
|
64
|
+
sandbox: false
|
62
65
|
standalone: true
|
63
66
|
template: ""
|
64
67
|
variable: [""]
|
@@ -68,7 +71,6 @@ eol: "native"
|
|
68
71
|
dpi: 96
|
69
72
|
wrap: "auto"
|
70
73
|
columns: 78
|
71
|
-
strip_comments: true
|
72
74
|
toc: true
|
73
75
|
table_of_contents: true
|
74
76
|
toc_depth: 3
|
@@ -91,7 +93,8 @@ html_q_tags: true
|
|
91
93
|
ascii: true
|
92
94
|
reference_links: true
|
93
95
|
reference_location: "block"
|
94
|
-
|
96
|
+
markdown_headings: "atx"
|
97
|
+
atx_headers: false
|
95
98
|
top_level_division: "section"
|
96
99
|
number_sections: true
|
97
100
|
number_offset: 2
|
@@ -99,7 +102,6 @@ listings: true
|
|
99
102
|
incremental: true
|
100
103
|
slide_level: 1
|
101
104
|
section_divs: true
|
102
|
-
default_image_extension: "png"
|
103
105
|
email_obfuscation: "none"
|
104
106
|
id_prefix: ""
|
105
107
|
title_prefix: ""
|
@@ -116,9 +118,10 @@ pdf_engine_opt: [""]
|
|
116
118
|
#####
|
117
119
|
# Citation rendering
|
118
120
|
#####
|
121
|
+
citeproc: true
|
119
122
|
bibliography: ""
|
120
123
|
csl: ""
|
121
|
-
citation_abbreviations:
|
124
|
+
citation_abbreviations: ""
|
122
125
|
natbib: true
|
123
126
|
biblatex: true
|
124
127
|
#####
|
data/lib/paru.rb
CHANGED
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.4.
|
4
|
+
version: 0.4.2.3
|
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:
|
11
|
+
date: 2021-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Control pandoc with Ruby and write pandoc filters in Ruby
|
14
14
|
email: Huub@heerdebeer.org
|
@@ -47,6 +47,7 @@ files:
|
|
47
47
|
- lib/paru/filter/image.rb
|
48
48
|
- lib/paru/filter/inline.rb
|
49
49
|
- lib/paru/filter/inner_markdown.rb
|
50
|
+
- lib/paru/filter/int_value.rb
|
50
51
|
- lib/paru/filter/line_block.rb
|
51
52
|
- lib/paru/filter/line_break.rb
|
52
53
|
- lib/paru/filter/link.rb
|
@@ -109,15 +110,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
109
110
|
requirements:
|
110
111
|
- - ">="
|
111
112
|
- !ruby/object:Gem::Version
|
112
|
-
version:
|
113
|
+
version: 2.6.8
|
113
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
115
|
requirements:
|
115
116
|
- - ">="
|
116
117
|
- !ruby/object:Gem::Version
|
117
118
|
version: '0'
|
118
119
|
requirements: []
|
119
|
-
|
120
|
-
rubygems_version: 2.7.7
|
120
|
+
rubygems_version: 3.2.3
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: Paru is a ruby wrapper around pandoc
|