paru 1.5.0 → 1.5.1
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/error.rb +6 -4
- data/lib/paru/filter/ast_manipulation.rb +90 -91
- data/lib/paru/filter/attr.rb +75 -69
- data/lib/paru/filter/block.rb +15 -14
- data/lib/paru/filter/block_quote.rb +14 -12
- data/lib/paru/filter/bullet_list.rb +17 -16
- data/lib/paru/filter/caption.rb +50 -48
- data/lib/paru/filter/cell.rb +52 -50
- data/lib/paru/filter/citation.rb +53 -51
- data/lib/paru/filter/cite.rb +34 -33
- data/lib/paru/filter/code.rb +51 -49
- data/lib/paru/filter/code_block.rb +76 -76
- data/lib/paru/filter/col_spec.rb +58 -56
- data/lib/paru/filter/definition_list.rb +51 -52
- data/lib/paru/filter/definition_list_item.rb +45 -43
- data/lib/paru/filter/div.rb +37 -35
- data/lib/paru/filter/document.rb +112 -115
- data/lib/paru/filter/emph.rb +7 -5
- data/lib/paru/filter/empty_block.rb +17 -16
- data/lib/paru/filter/empty_inline.rb +23 -22
- data/lib/paru/filter/figure.rb +41 -39
- data/lib/paru/filter/header.rb +41 -39
- data/lib/paru/filter/horizontal_rule.rb +7 -5
- data/lib/paru/filter/image.rb +13 -12
- data/lib/paru/filter/inline.rb +27 -26
- data/lib/paru/filter/inner_markdown.rb +60 -62
- data/lib/paru/filter/int_value.rb +19 -18
- data/lib/paru/filter/line_block.rb +13 -11
- data/lib/paru/filter/line_break.rb +7 -5
- data/lib/paru/filter/link.rb +34 -33
- data/lib/paru/filter/list.rb +37 -37
- data/lib/paru/filter/list_attributes.rb +52 -51
- data/lib/paru/filter/math.rb +66 -64
- data/lib/paru/filter/meta.rb +40 -39
- data/lib/paru/filter/meta_blocks.rb +7 -5
- data/lib/paru/filter/meta_bool.rb +7 -5
- data/lib/paru/filter/meta_inlines.rb +9 -7
- data/lib/paru/filter/meta_list.rb +7 -5
- data/lib/paru/filter/meta_map.rb +50 -49
- data/lib/paru/filter/meta_string.rb +7 -6
- data/lib/paru/filter/meta_value.rb +26 -25
- data/lib/paru/filter/metadata.rb +150 -88
- data/lib/paru/filter/node.rb +400 -406
- data/lib/paru/filter/note.rb +29 -29
- data/lib/paru/filter/null.rb +7 -5
- data/lib/paru/filter/ordered_list.rb +50 -49
- data/lib/paru/filter/para.rb +21 -20
- data/lib/paru/filter/plain.rb +23 -21
- data/lib/paru/filter/quoted.rb +28 -26
- data/lib/paru/filter/short_caption.rb +7 -5
- data/lib/paru/filter/small_caps.rb +8 -7
- data/lib/paru/filter/soft_break.rb +7 -5
- data/lib/paru/filter/space.rb +7 -5
- data/lib/paru/filter/span.rb +29 -27
- data/lib/paru/filter/str.rb +33 -32
- data/lib/paru/filter/strikeout.rb +7 -6
- data/lib/paru/filter/strong.rb +7 -6
- data/lib/paru/filter/subscript.rb +7 -6
- data/lib/paru/filter/superscript.rb +7 -6
- data/lib/paru/filter/table.rb +201 -210
- data/lib/paru/filter/table_body.rb +67 -67
- data/lib/paru/filter/table_end.rb +53 -55
- data/lib/paru/filter/table_foot.rb +8 -7
- data/lib/paru/filter/table_head.rb +8 -7
- data/lib/paru/filter/target.rb +29 -27
- data/lib/paru/filter/underline.rb +7 -5
- data/lib/paru/filter/value.rb +74 -75
- data/lib/paru/filter/version.rb +23 -22
- data/lib/paru/filter.rb +355 -331
- data/lib/paru/filter_error.rb +7 -5
- data/lib/paru/info.rb +29 -30
- data/lib/paru/pandoc.rb +241 -248
- data/lib/paru/pandoc2yaml.rb +51 -42
- data/lib/paru/selector.rb +193 -184
- data/lib/paru.rb +3 -1
- metadata +4 -73
data/lib/paru/filter/strong.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# Copyright 2015, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
|
3
5
|
#
|
@@ -16,13 +18,12 @@
|
|
16
18
|
# You should have received a copy of the GNU General Public License
|
17
19
|
# along with Paru. If not, see <http://www.gnu.org/licenses/>.
|
18
20
|
#++
|
19
|
-
require_relative
|
21
|
+
require_relative 'inline'
|
20
22
|
|
21
23
|
module Paru
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
24
|
+
module PandocFilter
|
25
|
+
# A Strong inline node
|
26
|
+
class Strong < Inline
|
26
27
|
end
|
28
|
+
end
|
27
29
|
end
|
28
|
-
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# Copyright 2015, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
|
3
5
|
#
|
@@ -16,13 +18,12 @@
|
|
16
18
|
# You should have received a copy of the GNU General Public License
|
17
19
|
# along with Paru. If not, see <http://www.gnu.org/licenses/>.
|
18
20
|
#++
|
19
|
-
require_relative
|
21
|
+
require_relative 'inline'
|
20
22
|
|
21
23
|
module Paru
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
24
|
+
module PandocFilter
|
25
|
+
# A Subscript inline node
|
26
|
+
class Subscript < Inline
|
26
27
|
end
|
28
|
+
end
|
27
29
|
end
|
28
|
-
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# Copyright 2015, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
|
3
5
|
#
|
@@ -16,13 +18,12 @@
|
|
16
18
|
# You should have received a copy of the GNU General Public License
|
17
19
|
# along with Paru. If not, see <http://www.gnu.org/licenses/>.
|
18
20
|
#++
|
19
|
-
require_relative
|
21
|
+
require_relative 'inline'
|
20
22
|
|
21
23
|
module Paru
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
24
|
+
module PandocFilter
|
25
|
+
# A Superscript inline node
|
26
|
+
class Superscript < Inline
|
26
27
|
end
|
28
|
+
end
|
27
29
|
end
|
28
|
-
|
data/lib/paru/filter/table.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# Copyright 2015, 2016, 2017, 2020, 2023 Huub de Beer <Huub@heerdebeer.org>
|
3
5
|
#
|
@@ -16,218 +18,207 @@
|
|
16
18
|
# You should have received a copy of the GNU General Public License
|
17
19
|
# along with Paru. If not, see <http://www.gnu.org/licenses/>.
|
18
20
|
#++
|
19
|
-
require
|
20
|
-
require_relative
|
21
|
-
require_relative
|
22
|
-
require_relative
|
23
|
-
require_relative
|
24
|
-
require_relative
|
25
|
-
require_relative
|
26
|
-
require_relative
|
27
|
-
require_relative
|
28
|
-
|
21
|
+
require 'csv'
|
22
|
+
require_relative 'block'
|
23
|
+
require_relative 'inline'
|
24
|
+
require_relative 'caption'
|
25
|
+
require_relative 'col_spec'
|
26
|
+
require_relative 'row'
|
27
|
+
require_relative 'table_head'
|
28
|
+
require_relative 'table_foot'
|
29
|
+
require_relative 'table_body'
|
30
|
+
|
29
31
|
module Paru
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
data.concat @foot.to_array
|
104
|
-
end
|
105
|
-
|
106
|
-
data
|
107
|
-
end
|
108
|
-
|
109
|
-
# Convert this Table to a CSV file. See to_array for the config
|
110
|
-
# options
|
111
|
-
#
|
112
|
-
# @param filename [String] filename to write to
|
113
|
-
# @param config [Hash] See #to_array for config options
|
114
|
-
def to_file(filename, config = {})
|
115
|
-
CSV.open(filename, "wb") do |csv|
|
116
|
-
to_array(**config).each {|row| csv << row}
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
# Create a new Table from an 2D array and an optional
|
121
|
-
# configuration
|
122
|
-
#
|
123
|
-
# @param data [String[][]] an array of markdown strings
|
124
|
-
# @param config [Hash] configuration of the list.
|
125
|
-
# properties:
|
126
|
-
# :headers [Boolean] True if data includes headers on first
|
127
|
-
# row. Defailts to false.
|
128
|
-
# :caption [String] The table's caption
|
129
|
-
# :footers [Boolean] True if data includes footers on last row,
|
130
|
-
# default to false.
|
131
|
-
#
|
132
|
-
# @return [Table]
|
133
|
-
def self.from_array(data, config = {})
|
134
|
-
table_attribute = create_attr
|
135
|
-
|
136
|
-
caption = []
|
137
|
-
if config.has_key? :caption
|
138
|
-
caption = create_caption config[:caption]
|
139
|
-
end
|
140
|
-
|
141
|
-
col_spec = data[0].map {|c| ColSpec.new.to_ast }
|
142
|
-
|
143
|
-
head = create_endrow []
|
144
|
-
if config.has_key? :headers and config[:headers]
|
145
|
-
head = create_endrow data.first
|
146
|
-
data = data[1..-1]
|
147
|
-
end
|
148
|
-
|
149
|
-
foot = create_endrow []
|
150
|
-
if config.has_key? :footers and config[:footers]
|
151
|
-
foot = create_endrow data.last
|
152
|
-
data = data[0...-1]
|
153
|
-
end
|
154
|
-
|
155
|
-
body = create_body data
|
156
|
-
|
157
|
-
table = [
|
158
|
-
table_attribute,
|
159
|
-
caption,
|
160
|
-
col_spec,
|
161
|
-
head,
|
162
|
-
body,
|
163
|
-
foot
|
164
|
-
]
|
165
|
-
|
166
|
-
Table.new table
|
167
|
-
end
|
168
|
-
|
169
|
-
|
170
|
-
# Create a new Table from a CSV file.
|
171
|
-
#
|
172
|
-
# @param filename [String] filename to read CSV data from
|
173
|
-
# @param config [Hash] See #from_file for details
|
174
|
-
#
|
175
|
-
# @return [Table]
|
176
|
-
def self.from_file(filename, config = {})
|
177
|
-
data = []
|
178
|
-
CSV.foreach(filename) do |row|
|
179
|
-
data << row
|
180
|
-
end
|
181
|
-
|
182
|
-
return self.from_array(data, config)
|
183
|
-
end
|
184
|
-
|
185
|
-
private
|
186
|
-
|
187
|
-
def self.create_caption(contents)
|
188
|
-
[
|
189
|
-
nil,
|
190
|
-
[Node.from_markdown(contents).to_ast]
|
191
|
-
]
|
192
|
-
end
|
193
|
-
|
194
|
-
def self.create_body(data)
|
195
|
-
[[
|
196
|
-
create_attr,
|
197
|
-
0,
|
198
|
-
[],
|
199
|
-
data.map {|r| create_row(r)}
|
200
|
-
]]
|
201
|
-
end
|
202
|
-
|
203
|
-
def self.create_endrow(data)
|
204
|
-
[
|
205
|
-
create_attr,
|
206
|
-
if data.empty? then [] else [create_row(data)] end
|
207
|
-
]
|
208
|
-
end
|
209
|
-
|
210
|
-
def self.create_row(data)
|
211
|
-
[
|
212
|
-
create_attr,
|
213
|
-
data.map {|c| create_cell(c)}
|
214
|
-
]
|
215
|
-
end
|
216
|
-
|
217
|
-
def self.create_cell(contents)
|
218
|
-
[
|
219
|
-
create_attr,
|
220
|
-
{"t" => "AlignDefault", "c" => nil},
|
221
|
-
1,
|
222
|
-
1,
|
223
|
-
[Node.from_markdown(contents).to_ast]
|
224
|
-
]
|
225
|
-
end
|
226
|
-
|
227
|
-
def self.create_attr()
|
228
|
-
["", [], []]
|
229
|
-
end
|
32
|
+
module PandocFilter
|
33
|
+
# A Table node represents a table with an inline caption, column
|
34
|
+
# definition, widths, headers, and rows.
|
35
|
+
#
|
36
|
+
# @!attribute caption
|
37
|
+
# @return Caption
|
38
|
+
#
|
39
|
+
# @!attribute attr
|
40
|
+
# @return Attr
|
41
|
+
#
|
42
|
+
# @!attribute colspec
|
43
|
+
# @return ColSpec[]
|
44
|
+
#
|
45
|
+
# @!attribute head
|
46
|
+
# @return TableHead[]
|
47
|
+
#
|
48
|
+
# @!attribute foot
|
49
|
+
# @return TableHead[]
|
50
|
+
class Table < Block
|
51
|
+
attr_accessor :caption, :attr, :colspec, :head, :foot
|
52
|
+
|
53
|
+
# Create a new Table based on the contents
|
54
|
+
#
|
55
|
+
# @param contents [Array]
|
56
|
+
def initialize(contents)
|
57
|
+
@attr = Attr.new contents[0]
|
58
|
+
@caption = Caption.new contents[1]
|
59
|
+
@colspec = contents[2].map { |p| ColSpec.new p }
|
60
|
+
@head = TableHead.new contents[3]
|
61
|
+
super([])
|
62
|
+
contents[4].each do |table_body|
|
63
|
+
@children.push TableBody.new table_body
|
64
|
+
end
|
65
|
+
@foot = TableFoot.new contents[5]
|
66
|
+
end
|
67
|
+
|
68
|
+
# The AST contents of this Table node
|
69
|
+
#
|
70
|
+
# @return [Array]
|
71
|
+
def ast_contents
|
72
|
+
[
|
73
|
+
@attr.to_ast,
|
74
|
+
@caption.to_ast,
|
75
|
+
@colspec.map(&:to_ast),
|
76
|
+
@head.to_ast,
|
77
|
+
@children.map(&:to_ast),
|
78
|
+
@foot.to_ast
|
79
|
+
]
|
80
|
+
end
|
81
|
+
|
82
|
+
# Convert this table to a 2D table of markdown strings for each
|
83
|
+
# cell
|
84
|
+
#
|
85
|
+
# @param config [Hash] configuraton of the table output
|
86
|
+
# Config can contain properties :headers
|
87
|
+
#
|
88
|
+
# @return [String[][]] This Table as a 2D array of cells
|
89
|
+
# represented by their markdown strings.
|
90
|
+
def to_array(config = {})
|
91
|
+
headers = config.key?(:headers) ? config[:headers] : false
|
92
|
+
footers = config.key?(:footers) ? config[:footers] : false
|
93
|
+
|
94
|
+
data = []
|
95
|
+
data.concat @head.to_array if headers
|
96
|
+
|
97
|
+
@children.each do |row|
|
98
|
+
data.concat row.to_array
|
99
|
+
end
|
100
|
+
|
101
|
+
data.concat @foot.to_array if footers
|
102
|
+
|
103
|
+
data
|
104
|
+
end
|
230
105
|
|
106
|
+
# Convert this Table to a CSV file. See to_array for the config
|
107
|
+
# options
|
108
|
+
#
|
109
|
+
# @param filename [String] filename to write to
|
110
|
+
# @param config [Hash] See #to_array for config options
|
111
|
+
def to_file(filename, config = {})
|
112
|
+
CSV.open(filename, 'wb') do |csv|
|
113
|
+
to_array(**config).each { |row| csv << row }
|
231
114
|
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# Create a new Table from an 2D array and an optional
|
118
|
+
# configuration
|
119
|
+
#
|
120
|
+
# @param data [String[][]] an array of markdown strings
|
121
|
+
# @param config [Hash] configuration of the list.
|
122
|
+
# properties:
|
123
|
+
# :headers [Boolean] True if data includes headers on first
|
124
|
+
# row. Defailts to false.
|
125
|
+
# :caption [String] The table's caption
|
126
|
+
# :footers [Boolean] True if data includes footers on last row,
|
127
|
+
# default to false.
|
128
|
+
#
|
129
|
+
# @return [Table]
|
130
|
+
def self.from_array(data, config = {})
|
131
|
+
table_attribute = create_attr
|
132
|
+
|
133
|
+
caption = []
|
134
|
+
caption = create_caption config[:caption] if config.key? :caption
|
135
|
+
|
136
|
+
col_spec = data[0].map { |_c| ColSpec.new.to_ast }
|
137
|
+
|
138
|
+
head = create_endrow []
|
139
|
+
if config.key?(:headers) && config[:headers]
|
140
|
+
head = create_endrow data.first
|
141
|
+
data = data[1..]
|
142
|
+
end
|
143
|
+
|
144
|
+
foot = create_endrow []
|
145
|
+
if config.key?(:footers) && config[:footers]
|
146
|
+
foot = create_endrow data.last
|
147
|
+
data = data[0...-1]
|
148
|
+
end
|
149
|
+
|
150
|
+
body = create_body data
|
151
|
+
|
152
|
+
table = [
|
153
|
+
table_attribute,
|
154
|
+
caption,
|
155
|
+
col_spec,
|
156
|
+
head,
|
157
|
+
body,
|
158
|
+
foot
|
159
|
+
]
|
160
|
+
|
161
|
+
Table.new table
|
162
|
+
end
|
163
|
+
|
164
|
+
# Create a new Table from a CSV file.
|
165
|
+
#
|
166
|
+
# @param filename [String] filename to read CSV data from
|
167
|
+
# @param config [Hash] See #from_file for details
|
168
|
+
#
|
169
|
+
# @return [Table]
|
170
|
+
def self.from_file(filename, config = {})
|
171
|
+
data = []
|
172
|
+
CSV.foreach(filename) do |row|
|
173
|
+
data << row
|
174
|
+
end
|
175
|
+
|
176
|
+
from_array(data, config)
|
177
|
+
end
|
178
|
+
|
179
|
+
def self.create_caption(contents)
|
180
|
+
[
|
181
|
+
nil,
|
182
|
+
[Node.from_markdown(contents).to_ast]
|
183
|
+
]
|
184
|
+
end
|
185
|
+
|
186
|
+
def self.create_body(data)
|
187
|
+
[[
|
188
|
+
create_attr,
|
189
|
+
0,
|
190
|
+
[],
|
191
|
+
data.map { |r| create_row(r) }
|
192
|
+
]]
|
193
|
+
end
|
194
|
+
|
195
|
+
def self.create_endrow(data)
|
196
|
+
[
|
197
|
+
create_attr,
|
198
|
+
data.empty? ? [] : [create_row(data)]
|
199
|
+
]
|
200
|
+
end
|
201
|
+
|
202
|
+
def self.create_row(data)
|
203
|
+
[
|
204
|
+
create_attr,
|
205
|
+
data.map { |c| create_cell(c) }
|
206
|
+
]
|
207
|
+
end
|
208
|
+
|
209
|
+
def self.create_cell(contents)
|
210
|
+
[
|
211
|
+
create_attr,
|
212
|
+
{ 't' => 'AlignDefault', 'c' => nil },
|
213
|
+
1,
|
214
|
+
1,
|
215
|
+
[Node.from_markdown(contents).to_ast]
|
216
|
+
]
|
217
|
+
end
|
218
|
+
|
219
|
+
def self.create_attr
|
220
|
+
['', [], []]
|
221
|
+
end
|
232
222
|
end
|
223
|
+
end
|
233
224
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
4
|
# Copyright 2015, 2016, 2017, 2020 Huub de Beer <Huub@heerdebeer.org>
|
3
5
|
#
|
@@ -16,79 +18,77 @@
|
|
16
18
|
# You should have received a copy of the GNU General Public License
|
17
19
|
# along with Paru. If not, see <http://www.gnu.org/licenses/>.
|
18
20
|
#++
|
19
|
-
require_relative
|
20
|
-
require_relative
|
21
|
-
require_relative
|
21
|
+
require_relative 'block'
|
22
|
+
require_relative 'row'
|
23
|
+
require_relative 'value'
|
22
24
|
|
23
25
|
module Paru
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
26
|
+
module PandocFilter
|
27
|
+
# A TableBody node represents a row in a table's head or body
|
28
|
+
#
|
29
|
+
# @!attribute attr
|
30
|
+
# @return Attr
|
31
|
+
#
|
32
|
+
# @!attribute rowheadcolumns
|
33
|
+
# @return Value containing an Integer indicating the number of head
|
34
|
+
# columns.
|
35
|
+
#
|
36
|
+
# @!attribute rowheadercolums
|
37
|
+
# @return [Row]
|
38
|
+
#
|
39
|
+
# @!attribute rows
|
40
|
+
# @return [Row]
|
41
|
+
class TableBody < Block
|
42
|
+
attr_accessor :attr, :rowheadcolumnspec, :rowheadercolumns
|
43
|
+
|
44
|
+
# Create a new TableBody
|
45
|
+
#
|
46
|
+
# @param contents [Array] The contents of this TableBody
|
47
|
+
def initialize(contents)
|
48
|
+
@attr = Attr.new contents[0]
|
49
|
+
@rowheadcolumns = IntValue.new contents[1]
|
50
|
+
@rowheadercolumns = contents[2].map { |r| Row.new r }
|
41
51
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
@rowheadcolumns = IntValue.new contents[1]
|
48
|
-
@rowheadercolumns = contents[2].map {|r| Row.new r}
|
52
|
+
super([])
|
53
|
+
contents[3].each do |row|
|
54
|
+
@children.push Row.new row
|
55
|
+
end
|
56
|
+
end
|
49
57
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
58
|
+
# The rows in this TableBody
|
59
|
+
#
|
60
|
+
# @return [Array<Row>]
|
61
|
+
def rows
|
62
|
+
@children
|
63
|
+
end
|
55
64
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
65
|
+
# The AST contents of this TableBody
|
66
|
+
#
|
67
|
+
# @return [Array]
|
68
|
+
def ast_contents
|
69
|
+
[
|
70
|
+
@attr.to_ast,
|
71
|
+
@rowheadcolumns.to_ast,
|
72
|
+
@rowheadercolumns.map(&:to_ast),
|
73
|
+
@children.map(&:to_ast)
|
74
|
+
]
|
75
|
+
end
|
62
76
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
@rowheadcolumns.to_ast,
|
70
|
-
@rowheadercolumns.map {|r| r.to_ast},
|
71
|
-
@children.map {|child| child.to_ast}
|
72
|
-
]
|
73
|
-
end
|
77
|
+
# Create an AST representation of this Node
|
78
|
+
#
|
79
|
+
# @return [Hash]
|
80
|
+
def to_ast
|
81
|
+
ast_contents
|
82
|
+
end
|
74
83
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
# cell
|
84
|
-
#
|
85
|
-
# @return [String[][]] This Table as a 2D array of cells
|
86
|
-
# represented by their markdown strings.
|
87
|
-
def to_array()
|
88
|
-
@children.map do |row|
|
89
|
-
row.to_array
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
84
|
+
# Convert this table end to a 2D table of markdown strings for each
|
85
|
+
# cell
|
86
|
+
#
|
87
|
+
# @return [String[][]] This Table as a 2D array of cells
|
88
|
+
# represented by their markdown strings.
|
89
|
+
def to_array
|
90
|
+
@children.map(&:to_array)
|
91
|
+
end
|
93
92
|
end
|
93
|
+
end
|
94
94
|
end
|