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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/lib/paru/error.rb +6 -4
  3. data/lib/paru/filter/ast_manipulation.rb +90 -91
  4. data/lib/paru/filter/attr.rb +75 -69
  5. data/lib/paru/filter/block.rb +15 -14
  6. data/lib/paru/filter/block_quote.rb +14 -12
  7. data/lib/paru/filter/bullet_list.rb +17 -16
  8. data/lib/paru/filter/caption.rb +50 -48
  9. data/lib/paru/filter/cell.rb +52 -50
  10. data/lib/paru/filter/citation.rb +53 -51
  11. data/lib/paru/filter/cite.rb +34 -33
  12. data/lib/paru/filter/code.rb +51 -49
  13. data/lib/paru/filter/code_block.rb +76 -76
  14. data/lib/paru/filter/col_spec.rb +58 -56
  15. data/lib/paru/filter/definition_list.rb +51 -52
  16. data/lib/paru/filter/definition_list_item.rb +45 -43
  17. data/lib/paru/filter/div.rb +37 -35
  18. data/lib/paru/filter/document.rb +112 -115
  19. data/lib/paru/filter/emph.rb +7 -5
  20. data/lib/paru/filter/empty_block.rb +17 -16
  21. data/lib/paru/filter/empty_inline.rb +23 -22
  22. data/lib/paru/filter/figure.rb +41 -39
  23. data/lib/paru/filter/header.rb +41 -39
  24. data/lib/paru/filter/horizontal_rule.rb +7 -5
  25. data/lib/paru/filter/image.rb +13 -12
  26. data/lib/paru/filter/inline.rb +27 -26
  27. data/lib/paru/filter/inner_markdown.rb +60 -62
  28. data/lib/paru/filter/int_value.rb +19 -18
  29. data/lib/paru/filter/line_block.rb +13 -11
  30. data/lib/paru/filter/line_break.rb +7 -5
  31. data/lib/paru/filter/link.rb +34 -33
  32. data/lib/paru/filter/list.rb +37 -37
  33. data/lib/paru/filter/list_attributes.rb +52 -51
  34. data/lib/paru/filter/math.rb +66 -64
  35. data/lib/paru/filter/meta.rb +40 -39
  36. data/lib/paru/filter/meta_blocks.rb +7 -5
  37. data/lib/paru/filter/meta_bool.rb +7 -5
  38. data/lib/paru/filter/meta_inlines.rb +9 -7
  39. data/lib/paru/filter/meta_list.rb +7 -5
  40. data/lib/paru/filter/meta_map.rb +50 -49
  41. data/lib/paru/filter/meta_string.rb +7 -6
  42. data/lib/paru/filter/meta_value.rb +26 -25
  43. data/lib/paru/filter/metadata.rb +150 -88
  44. data/lib/paru/filter/node.rb +400 -406
  45. data/lib/paru/filter/note.rb +29 -29
  46. data/lib/paru/filter/null.rb +7 -5
  47. data/lib/paru/filter/ordered_list.rb +50 -49
  48. data/lib/paru/filter/para.rb +21 -20
  49. data/lib/paru/filter/plain.rb +23 -21
  50. data/lib/paru/filter/quoted.rb +28 -26
  51. data/lib/paru/filter/short_caption.rb +7 -5
  52. data/lib/paru/filter/small_caps.rb +8 -7
  53. data/lib/paru/filter/soft_break.rb +7 -5
  54. data/lib/paru/filter/space.rb +7 -5
  55. data/lib/paru/filter/span.rb +29 -27
  56. data/lib/paru/filter/str.rb +33 -32
  57. data/lib/paru/filter/strikeout.rb +7 -6
  58. data/lib/paru/filter/strong.rb +7 -6
  59. data/lib/paru/filter/subscript.rb +7 -6
  60. data/lib/paru/filter/superscript.rb +7 -6
  61. data/lib/paru/filter/table.rb +201 -210
  62. data/lib/paru/filter/table_body.rb +67 -67
  63. data/lib/paru/filter/table_end.rb +53 -55
  64. data/lib/paru/filter/table_foot.rb +8 -7
  65. data/lib/paru/filter/table_head.rb +8 -7
  66. data/lib/paru/filter/target.rb +29 -27
  67. data/lib/paru/filter/underline.rb +7 -5
  68. data/lib/paru/filter/value.rb +74 -75
  69. data/lib/paru/filter/version.rb +23 -22
  70. data/lib/paru/filter.rb +355 -331
  71. data/lib/paru/filter_error.rb +7 -5
  72. data/lib/paru/info.rb +29 -30
  73. data/lib/paru/pandoc.rb +241 -248
  74. data/lib/paru/pandoc2yaml.rb +51 -42
  75. data/lib/paru/selector.rb +193 -184
  76. data/lib/paru.rb +3 -1
  77. metadata +4 -73
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6150ea5eb07cbf87b85a54f5acdeacc38dc6fb0dff0fec57f2c0150c7fff7e31
4
- data.tar.gz: 9cc1f75bea6f4d4e5d8cfb8b8d228ec08d3b50c11bb3f091ce393972aa40d95c
3
+ metadata.gz: f8a2edbbb37d2775d83f83c568b3071bfc3f817c47581844c65e828413e1d5e9
4
+ data.tar.gz: ba0ddc768641749cd4264ad0ed4a64f1dc1ff91791254fa0efe12243156cfe6c
5
5
  SHA512:
6
- metadata.gz: b09e3fa5e9d25cbacf2b663d464a3717375fdfeece027c38838c4b3cd2c427b7f3cdd55db72fb562b53843bbd5173424158b38066c9456d0e481feca53debf54
7
- data.tar.gz: 4306a0799e8dad73dc442cba841417fcb578ebda84f14efe2306a73dc4f5f0f9a49361911e252981d709a3e1e593e5ae61b48c682940fedf25ed7cae9cf5faf7
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, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
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
- # An error class to use as a basis for paru specific errors.
21
- class Error < RuntimeError
22
- end
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, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
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
- module PandocFilter
21
- # ASTManipulation is a mixin for Node with some standard tree
22
- # manipulation methods such as inserting or removing nodes, replacing
23
- # nodes, and so on.
24
- module ASTManipulation
25
-
26
- # Find index of child
27
- #
28
- # @param child [Node] the child to find the index for
29
- #
30
- # @return [Number] the index of child or nil
31
- def find_index(child)
32
- @children.find_index child
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
- # 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
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
- # 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
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
- # 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
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
- # 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
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
- # 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
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
- # 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
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
- # 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
- if old_child_index then
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
- # 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
90
+ replace_at old_child_index, new_child
91
+ end
101
92
 
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
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
- if has_been_replaced?
113
- node = get_replacement
114
- else
115
- node = self
116
- end
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
- node.each {|child| child.each_depth_first(&block)} if node.has_children?
119
- end
112
+ node = if has_been_replaced?
113
+ get_replacement
114
+ else
115
+ self
116
+ end
120
117
 
121
- end
118
+ node.each { |child| child.each_depth_first(&block) } if node.has_children?
119
+ end
122
120
  end
121
+ end
123
122
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
- # Copyright 2015, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
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
- module PandocFilter
21
- # Attr represents an attribute object for a node. It contains of an id, a
22
- # list of class names and a list of key-value pairs.
23
- #
24
- # @see https://hackage.haskell.org/package/pandoc-types-1.17.0.5/docs/Text-Pandoc-Definition.html#t:Attr
25
- #
26
- # @!attribute id
27
- # @return [String]
28
- #
29
- # @!attribute classes
30
- # @return [Array<String>]
31
- class Attr
32
- include Enumerable
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
- attr_accessor :id, :classes
50
+ @data = data.to_h
51
+ end
35
52
 
36
- # Create a new attributes object
37
- #
38
- # @param attributes [Array = []] the attributes as [id, [class names],
39
- # [key-value pairs]]
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
- @classes = classes || []
46
- @classes = [@classes] unless @classes.is_a? Array
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
- @data = Hash[data] || {}
49
- end
65
+ @data[key]
66
+ end
50
67
 
51
- # For each key-value pair of this attributes object
52
- def each
53
- @data.each
54
- end
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
- # Get the value for key in this attributes object
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
- # Does this attributes object have this key?
67
- #
68
- # @param name [String] key to find
69
- #
70
- # @return [Boolean] true if this key exist, false otherwise
71
- def has_key?(name)
72
- @data.key? name
73
- end
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
- # Does this attributes object have a class?
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
- # Convert this attributes object to an AST representation
86
- #
87
- # @return [Array] Array containing id, class name list, and
88
- # key-value pair list
89
- def to_ast
90
- [
91
- @id,
92
- @classes,
93
- @data.to_a
94
- ]
95
- end
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
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
- # Copyright 2015, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
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 "./node.rb"
21
+ require_relative 'node'
20
22
 
21
23
  module Paru
22
- module PandocFilter
23
- # A Block level node.
24
- # @see https://hackage.haskell.org/package/pandoc-types-1.17.0.5/docs/Text-Pandoc-Definition.html#t:Block
25
- class Block < Node
26
-
27
- # Is this node a block?
28
- #
29
- # @return [Boolean] true
30
- def is_block?
31
- true
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, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
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 "./block.rb"
21
+ require_relative 'block'
20
22
 
21
23
  module Paru
22
- module PandocFilter
23
- # A BlockQuote node. Contains a list of Blocks
24
- class BlockQuote < Block
25
- # Has this node a block?
26
- #
27
- # @return [Boolean] true
28
- def has_block?
29
- true
30
- end
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, 2016, 2017 Huub de Beer <Huub@heerdebeer.org>
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 "./list.rb"
21
+ require_relative 'list'
20
22
 
21
23
  module Paru
22
- module PandocFilter
23
- # BulletList, contains a list of list of Block nodes.
24
- class BulletList < List
25
-
26
- # Create a new BulletList from an array of markdown strings
27
- #
28
- # @param items [String[]] array of markdown strings as items of
29
- # the new BulletList
30
- # @return [BulletList]
31
- def self.from_array(items)
32
- ast_items = items.map {|item| [Block.from_markdown(item).to_ast]}
33
- BulletList.new ast_items
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
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
- # Copyright 2020, 2023 Huub de Beer <Huub@heerdebeer.org>
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 "./block.rb"
20
- require_relative "./inner_markdown.rb"
21
- require_relative "./short_caption.rb"
21
+ require_relative 'block'
22
+ require_relative 'inner_markdown'
23
+ require_relative 'short_caption'
22
24
 
23
25
  module Paru
24
- module PandocFilter
25
- # A table or figure's caption, can contain an optional short caption
26
- class Caption < Block
27
- include InnerMarkdown
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
- attr_accessor :short
31
+ attr_accessor :short
30
32
 
31
- # Create a new Caption based on the contents
32
- #
33
- # @param contents [Array]
34
- def initialize(contents)
35
- if contents[0].nil?
36
- @short = nil
37
- else
38
- @short = ShortCaption.new contents[0]
39
- end
40
- super(contents[1])
41
- end
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
- # Does this Caption have a short caption?
44
- #
45
- # @return [Boolean]
46
- def has_short?()
47
- not @short.nil?
48
- end
45
+ # Does this Caption have a short caption?
46
+ #
47
+ # @return [Boolean]
48
+ def has_short?
49
+ !@short.nil?
50
+ end
49
51
 
50
- # Has this node a block?
51
- #
52
- # @return [Boolean] true
53
- def has_block?
54
- true
55
- end
52
+ # Has this node a block?
53
+ #
54
+ # @return [Boolean] true
55
+ def has_block?
56
+ true
57
+ end
56
58
 
57
- # The AST contents of this Caption node
58
- #
59
- # @return [Array]
60
- def ast_contents()
61
- [
62
- if has_short? then @short.to_ast else nil end,
63
- @children.map {|row| row.to_ast}
64
- ]
65
- end
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
- # Create an AST representation of this Node
68
- #
69
- # @return [Hash]
70
- def to_ast()
71
- ast_contents()
72
- end
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