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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8a2edbbb37d2775d83f83c568b3071bfc3f817c47581844c65e828413e1d5e9
|
4
|
+
data.tar.gz: ba0ddc768641749cd4264ad0ed4a64f1dc1ff91791254fa0efe12243156cfe6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46c86674922f8d99eb8c0c507aae32efd86fcc14c78e94ba09fa9fc284a4a8cade7499aee6ba0b58142eba21099c9309d6e62863b32f3b3307872ee14d5c0df7
|
7
|
+
data.tar.gz: 2c63b6428068bf6c6b0622d5fb1706798d0b6aa935b8593f5174af091be7656f789df3dd6510fa6dfb1be07495334313ef73e9eb194dc2a8b7b1afff8af25ace
|
data/lib/paru/error.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
|
-
# Copyright 2015
|
4
|
+
# Copyright 2015--2025 Huub de Beer <Huub@heerdebeer.org>
|
3
5
|
#
|
4
6
|
# This file is part of Paru
|
5
7
|
#
|
@@ -17,7 +19,7 @@
|
|
17
19
|
# along with Paru. If not, see <http://www.gnu.org/licenses/>.
|
18
20
|
#++
|
19
21
|
module Paru
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
# An error class to use as a basis for paru specific errors.
|
23
|
+
class Error < RuntimeError
|
24
|
+
end
|
23
25
|
end
|
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
|
-
# Copyright 2015
|
4
|
+
# Copyright 2015--2025 Huub de Beer <Huub@heerdebeer.org>
|
3
5
|
#
|
4
6
|
# This file is part of Paru
|
5
7
|
#
|
@@ -17,107 +19,104 @@
|
|
17
19
|
# along with Paru. If not, see <http://www.gnu.org/licenses/>.
|
18
20
|
#++
|
19
21
|
module Paru
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
|
22
|
+
module PandocFilter
|
23
|
+
# ASTManipulation is a mixin for Node with some standard tree
|
24
|
+
# manipulation methods such as inserting or removing nodes, replacing
|
25
|
+
# nodes, and so on.
|
26
|
+
module ASTManipulation
|
27
|
+
# Find index of child
|
28
|
+
#
|
29
|
+
# @param child [Node] the child to find the index for
|
30
|
+
#
|
31
|
+
# @return [Number] the index of child or nil
|
32
|
+
def find_index(child)
|
33
|
+
@children.find_index child
|
34
|
+
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
# Get the child node at index
|
37
|
+
#
|
38
|
+
# @param index [Number] the index of the child to get
|
39
|
+
#
|
40
|
+
# @return [Node] the child at index
|
41
|
+
def get(index)
|
42
|
+
@children[index]
|
43
|
+
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
# Insert child node among this node's children at position index.
|
46
|
+
#
|
47
|
+
# @param index [Integer] the position to insert the child
|
48
|
+
# @param child [Node] the child to insert
|
49
|
+
def insert(index, child)
|
50
|
+
@children.insert index, child
|
51
|
+
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
53
|
+
# Delete child from this node's children.
|
54
|
+
#
|
55
|
+
# @param child [Node] the child node to delete.
|
56
|
+
def delete(child)
|
57
|
+
@children.delete child
|
58
|
+
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
60
|
+
# Remove the child at position index from this node's children
|
61
|
+
#
|
62
|
+
# @param index [Integer] the position of the child to remove
|
63
|
+
def remove_at(index)
|
64
|
+
@children.delete_at index
|
65
|
+
end
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
# Append a child to the list with this node's children.
|
68
|
+
#
|
69
|
+
# @param child [Node] the child to append.
|
70
|
+
def append(child)
|
71
|
+
@children.push child
|
72
|
+
end
|
73
|
+
alias << append
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
75
|
+
# Prepend a child to the list with this node's children.
|
76
|
+
#
|
77
|
+
# @param child [Node] the child to prepend.
|
78
|
+
def prepend(child)
|
79
|
+
insert 0, child
|
80
|
+
end
|
81
81
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
replace_at old_child_index, new_child
|
90
|
-
end
|
91
|
-
end
|
82
|
+
# Replace a child from this node's children with a new child.
|
83
|
+
#
|
84
|
+
# @param old_child [Node] the child to replace
|
85
|
+
# @param new_child [Node] the replacement child
|
86
|
+
def replace(old_child, new_child)
|
87
|
+
old_child_index = find_index old_child
|
88
|
+
return unless old_child_index
|
92
89
|
|
93
|
-
|
94
|
-
|
95
|
-
#
|
96
|
-
# @param index [Integer] the position of the child to replace
|
97
|
-
# @param new_child [Node] the replacement child
|
98
|
-
def replace_at(index, new_child)
|
99
|
-
@children[index] = new_child
|
100
|
-
end
|
90
|
+
replace_at old_child_index, new_child
|
91
|
+
end
|
101
92
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
yield self
|
93
|
+
# Replace the child at position index from this node's children
|
94
|
+
# with a new child.
|
95
|
+
#
|
96
|
+
# @param index [Integer] the position of the child to replace
|
97
|
+
# @param new_child [Node] the replacement child
|
98
|
+
def replace_at(index, new_child)
|
99
|
+
@children[index] = new_child
|
100
|
+
end
|
111
101
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
102
|
+
# Walk the node tree starting at this node, depth first, and apply
|
103
|
+
# block to each node in the tree
|
104
|
+
#
|
105
|
+
# @param block [Proc] the block to apply to each node in this node
|
106
|
+
# tree
|
107
|
+
#
|
108
|
+
# @yield [Node]
|
109
|
+
def each_depth_first(&block)
|
110
|
+
yield self
|
117
111
|
|
118
|
-
|
119
|
-
|
112
|
+
node = if has_been_replaced?
|
113
|
+
get_replacement
|
114
|
+
else
|
115
|
+
self
|
116
|
+
end
|
120
117
|
|
121
|
-
|
118
|
+
node.each { |child| child.each_depth_first(&block) } if node.has_children?
|
119
|
+
end
|
122
120
|
end
|
121
|
+
end
|
123
122
|
end
|
data/lib/paru/filter/attr.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
|
-
# Copyright 2015
|
4
|
+
# Copyright 2015--2025 Huub de Beer <Huub@heerdebeer.org>
|
3
5
|
#
|
4
6
|
# This file is part of Paru
|
5
7
|
#
|
@@ -17,82 +19,86 @@
|
|
17
19
|
# along with Paru. If not, see <http://www.gnu.org/licenses/>.
|
18
20
|
#++
|
19
21
|
module Paru
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
module PandocFilter
|
23
|
+
# Attr represents an attribute object for a node. It contains of an id, a
|
24
|
+
# list of class names and a list of key-value pairs.
|
25
|
+
#
|
26
|
+
# @see https://hackage.haskell.org/package/pandoc-types-1.17.0.5/docs/Text-Pandoc-Definition.html#t:Attr
|
27
|
+
#
|
28
|
+
# @!attribute id
|
29
|
+
# @return [String]
|
30
|
+
#
|
31
|
+
# @!attribute classes
|
32
|
+
# @return [Array<String>]
|
33
|
+
class Attr
|
34
|
+
include Enumerable
|
35
|
+
|
36
|
+
attr_accessor :id, :classes
|
37
|
+
|
38
|
+
# Create a new attributes object
|
39
|
+
#
|
40
|
+
# @param attributes [Array = []] the attributes as [id, [class names],
|
41
|
+
# [key-value pairs]]
|
42
|
+
def initialize(attributes = [])
|
43
|
+
id, classes, data = attributes
|
44
|
+
|
45
|
+
@id = id || ''
|
46
|
+
|
47
|
+
@classes = classes || []
|
48
|
+
@classes = [@classes] unless @classes.is_a? Array
|
33
49
|
|
34
|
-
|
50
|
+
@data = data.to_h
|
51
|
+
end
|
35
52
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
def initialize(attributes = [])
|
41
|
-
id, classes, data = attributes
|
42
|
-
|
43
|
-
@id = id || ""
|
53
|
+
# For each key-value pair of this attributes object
|
54
|
+
def each
|
55
|
+
@data.each
|
56
|
+
end
|
44
57
|
|
45
|
-
|
46
|
-
|
58
|
+
# Get the value for key in this attributes object
|
59
|
+
#
|
60
|
+
# @param key [String] the key to get the value for. Nil if it does
|
61
|
+
# not exists
|
62
|
+
def [](key)
|
63
|
+
return unless @data.key? key
|
47
64
|
|
48
|
-
|
49
|
-
|
65
|
+
@data[key]
|
66
|
+
end
|
50
67
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
68
|
+
# Does this attributes object have this key?
|
69
|
+
#
|
70
|
+
# @param name [String] key to find
|
71
|
+
#
|
72
|
+
# @return [Boolean] true if this key exist, false otherwise
|
73
|
+
def has_key?(name)
|
74
|
+
@data.key? name
|
75
|
+
end
|
55
76
|
|
56
|
-
|
57
|
-
#
|
58
|
-
# @param key [String] the key to get the value for. Nil if it does
|
59
|
-
# not exists
|
60
|
-
def [](key)
|
61
|
-
if @data.key? key
|
62
|
-
@data[key]
|
63
|
-
end
|
64
|
-
end
|
77
|
+
alias key? has_key?
|
65
78
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
79
|
+
# Does this attributes object have a class?
|
80
|
+
#
|
81
|
+
# @param name [String] the class name to search for.
|
82
|
+
#
|
83
|
+
# @return [Boolean] true if this class name exist, false
|
84
|
+
# otherwise.
|
85
|
+
def has_class?(name)
|
86
|
+
@classes.include? name
|
87
|
+
end
|
74
88
|
|
75
|
-
|
76
|
-
#
|
77
|
-
# @param name [String] the class name to search for.
|
78
|
-
#
|
79
|
-
# @return [Boolean] true if this class name exist, false
|
80
|
-
# otherwise.
|
81
|
-
def has_class?(name)
|
82
|
-
@classes.include? name
|
83
|
-
end
|
89
|
+
alias class? has_class?
|
84
90
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
end
|
91
|
+
# Convert this attributes object to an AST representation
|
92
|
+
#
|
93
|
+
# @return [Array] Array containing id, class name list, and
|
94
|
+
# key-value pair list
|
95
|
+
def to_ast
|
96
|
+
[
|
97
|
+
@id,
|
98
|
+
@classes,
|
99
|
+
@data.to_a
|
100
|
+
]
|
101
|
+
end
|
97
102
|
end
|
103
|
+
end
|
98
104
|
end
|
data/lib/paru/filter/block.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
|
-
# Copyright 2015
|
4
|
+
# Copyright 2015--2025 Huub de Beer <Huub@heerdebeer.org>
|
3
5
|
#
|
4
6
|
# This file is part of Paru
|
5
7
|
#
|
@@ -16,20 +18,19 @@
|
|
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 'node'
|
20
22
|
|
21
23
|
module Paru
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
24
|
+
module PandocFilter
|
25
|
+
# A Block level node.
|
26
|
+
# @see https://hackage.haskell.org/package/pandoc-types-1.17.0.5/docs/Text-Pandoc-Definition.html#t:Block
|
27
|
+
class Block < Node
|
28
|
+
# Is this node a block?
|
29
|
+
#
|
30
|
+
# @return [Boolean] true
|
31
|
+
def is_block?
|
32
|
+
true
|
33
|
+
end
|
34
34
|
end
|
35
|
+
end
|
35
36
|
end
|
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
|
-
# Copyright 2015
|
4
|
+
# Copyright 2015--2025 Huub de Beer <Huub@heerdebeer.org>
|
3
5
|
#
|
4
6
|
# This file is part of Paru
|
5
7
|
#
|
@@ -16,18 +18,18 @@
|
|
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 'block'
|
20
22
|
|
21
23
|
module Paru
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
24
|
+
module PandocFilter
|
25
|
+
# A BlockQuote node. Contains a list of Blocks
|
26
|
+
class BlockQuote < Block
|
27
|
+
# Has this node a block?
|
28
|
+
#
|
29
|
+
# @return [Boolean] true
|
30
|
+
def has_block?
|
31
|
+
true
|
32
|
+
end
|
32
33
|
end
|
34
|
+
end
|
33
35
|
end
|
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
|
-
# Copyright 2015
|
4
|
+
# Copyright 2015--2025 Huub de Beer <Huub@heerdebeer.org>
|
3
5
|
#
|
4
6
|
# This file is part of Paru
|
5
7
|
#
|
@@ -16,22 +18,21 @@
|
|
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 'list'
|
20
22
|
|
21
23
|
module Paru
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
24
|
+
module PandocFilter
|
25
|
+
# BulletList, contains a list of list of Block nodes.
|
26
|
+
class BulletList < List
|
27
|
+
# Create a new BulletList from an array of markdown strings
|
28
|
+
#
|
29
|
+
# @param items [String[]] array of markdown strings as items of
|
30
|
+
# the new BulletList
|
31
|
+
# @return [BulletList]
|
32
|
+
def self.from_array(items)
|
33
|
+
ast_items = items.map { |item| [Block.from_markdown(item).to_ast] }
|
34
|
+
BulletList.new ast_items
|
35
|
+
end
|
36
36
|
end
|
37
|
+
end
|
37
38
|
end
|
data/lib/paru/filter/caption.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#--
|
2
|
-
# Copyright 2020
|
4
|
+
# Copyright 2020--2025 Huub de Beer <Huub@heerdebeer.org>
|
3
5
|
#
|
4
6
|
# This file is part of Paru
|
5
7
|
#
|
@@ -16,60 +18,60 @@
|
|
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 'inner_markdown'
|
23
|
+
require_relative 'short_caption'
|
22
24
|
|
23
25
|
module Paru
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
module PandocFilter
|
27
|
+
# A table or figure's caption, can contain an optional short caption
|
28
|
+
class Caption < Block
|
29
|
+
include InnerMarkdown
|
28
30
|
|
29
|
-
|
31
|
+
attr_accessor :short
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
33
|
+
# Create a new Caption based on the contents
|
34
|
+
#
|
35
|
+
# @param contents [Array]
|
36
|
+
def initialize(contents)
|
37
|
+
@short = if contents[0].nil?
|
38
|
+
nil
|
39
|
+
else
|
40
|
+
ShortCaption.new contents[0]
|
41
|
+
end
|
42
|
+
super(contents[1])
|
43
|
+
end
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
# Does this Caption have a short caption?
|
46
|
+
#
|
47
|
+
# @return [Boolean]
|
48
|
+
def has_short?
|
49
|
+
!@short.nil?
|
50
|
+
end
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
# Has this node a block?
|
53
|
+
#
|
54
|
+
# @return [Boolean] true
|
55
|
+
def has_block?
|
56
|
+
true
|
57
|
+
end
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
59
|
+
# The AST contents of this Caption node
|
60
|
+
#
|
61
|
+
# @return [Array]
|
62
|
+
def ast_contents
|
63
|
+
[
|
64
|
+
has_short? ? @short.to_ast : nil,
|
65
|
+
@children.map(&:to_ast)
|
66
|
+
]
|
67
|
+
end
|
66
68
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
69
|
+
# Create an AST representation of this Node
|
70
|
+
#
|
71
|
+
# @return [Hash]
|
72
|
+
def to_ast
|
73
|
+
ast_contents
|
74
|
+
end
|
74
75
|
end
|
76
|
+
end
|
75
77
|
end
|