class Paru::PandocFilter::DefinitionList
A DefinitionList
is a list of term-definition pairs, respecitively an Inline
list and a Block
list.
Public Class Methods
Source
# File lib/paru/filter/definition_list.rb, line 59 def self.from_array(definitions) ast_items = definitions.map do |definition| term = Block.from_markdown(definition[0]).ast_contents defin = List.from_markdown(definition[1]) if not defin.has_block? para = Para.new [] para.inner_markdown = definition[1] defin = [para.to_ast] else defin = defin.children.map{|c| c.to_ast} end [term, [defin]] end DefinitionList.new ast_items end
Create a new DefinitionList
based on a hash of term => definitions
@param definitions [Array] Array of arrays with terms and their definitions @return [DefinitionList]
Source
# File lib/paru/filter/definition_list.rb, line 30 def initialize(contents) super [] contents.each do |item| child = DefinitionListItem.new item child.parent = self @children.push child end end
Create a new DefinitionList
node
@param contents [Array] the contents of this definition list.
Calls superclass method
Public Instance Methods
Source
# File lib/paru/filter/definition_list.rb, line 41 def ast_contents @children.map {|child| child.to_ast} end
Create an AST representation of this DefinitionList
node
Source
# File lib/paru/filter/definition_list.rb, line 48 def to_array() @children.map do |def_item| def_item.to_array end end
Convert this DefinitionList
to a hash of term => definitions
@return [Array]