Class: Paru::PandocFilter::Caption
- Includes:
- InnerMarkdown
- Defined in:
- lib/paru/filter/caption.rb
Overview
A table or figure's caption, can contain an optional short caption
Instance Attribute Summary collapse
-
#short ⇒ Object
Returns the value of attribute short.
Attributes inherited from Node
Instance Method Summary collapse
-
#ast_contents ⇒ Array
The AST contents of this Caption node.
-
#has_block? ⇒ Boolean
Has this node a block?.
-
#has_short? ⇒ Boolean
Does this Caption have a short caption?.
-
#initialize(contents) ⇒ Caption
constructor
Create a new Caption based on the contents.
-
#to_ast ⇒ Hash
Create an AST representation of this Node.
Methods included from InnerMarkdown
#inner_markdown, #inner_markdown=
Methods inherited from Block
Methods inherited from Node
#ast_type, #can_act_as_both_block_and_inline?, #each, from_markdown, #get_replacement, #has_been_replaced?, #has_children?, #has_class?, #has_inline?, #has_parent?, #has_string?, #is_block?, #is_inline?, #is_leaf?, #is_node?, #is_root?, #markdown, #markdown=, #toMetadata, #to_s, #type
Methods included from ASTManipulation
#append, #delete, #each_depth_first, #find_index, #get, #insert, #prepend, #remove_at, #replace, #replace_at
Constructor Details
#initialize(contents) ⇒ Caption
Create a new Caption based on the contents
36 37 38 39 40 41 42 43 |
# File 'lib/paru/filter/caption.rb', line 36 def initialize(contents) @short = if contents[0].nil? nil else ShortCaption.new contents[0] end super(contents[1]) end |
Instance Attribute Details
#short ⇒ Object
Returns the value of attribute short.
31 32 33 |
# File 'lib/paru/filter/caption.rb', line 31 def short @short end |
Instance Method Details
#ast_contents ⇒ Array
The AST contents of this Caption node
62 63 64 65 66 67 |
# File 'lib/paru/filter/caption.rb', line 62 def ast_contents [ has_short? ? @short.to_ast : nil, @children.map(&:to_ast) ] end |
#has_block? ⇒ Boolean
Has this node a block?
55 56 57 |
# File 'lib/paru/filter/caption.rb', line 55 def has_block? true end |
#has_short? ⇒ Boolean
Does this Caption have a short caption?
48 49 50 |
# File 'lib/paru/filter/caption.rb', line 48 def has_short? !@short.nil? end |
#to_ast ⇒ Hash
Create an AST representation of this Node
72 73 74 |
# File 'lib/paru/filter/caption.rb', line 72 def to_ast ast_contents end |