PurpleWiki::StructuralNode - Structural node object
use PurpleWiki::InlineNode; use PurpleWiki::StructuralNode; # Create a 'section' node my $node = PurpleWiki::StructuralNode->new(type=>'section'); # Insert a child node, and assign it to $currentNode my $currentNode = $node->insertChild; # Set current node's type to 'h' $currentNode->type('h'); # Set node content to a new inline node of type 'text' and of # content 'Hello, world!' $currentNode->content( [PurpleWiki::InlineNode->new(type=>'text', content=>'Hello, world!')] ); # The resulting tree is: # # SECTION # | # +--- H: [TEXT: Hello, world!] # # where "[TEXT: Hello, world!]" refers to an inline node of type # 'text' and content 'Hello, world!'.
Structural nodes are the main structural component of PurpleWiki trees, representing document constructs such as sections, paragraphs, and list items. The basic data structure is:
PurpleWiki::StructuralNode = { type => document|section|h|p|pre|indent|ul|ol|li|dl|dt|dd id => int content => [PurpleWiki::InlineNode, ...] parent => PurpleWiki::StructuralNode children => [PurpleWiki::StructuralNode, ...] }
The document, section, indent, ul, ol, and dl nodes types are structural-only; their content field will always be undefined. Only the root node of a tree should be of type document. The content field is a reference to a list of inline nodes, and represents the content of the structural node.
PurpleWiki does not currently enforce constraints for structural node types. For example, you can create a section node with content, or a p node with children, even though neither of those are technically legal.
The BNF constraints for structural nodes are:
document ::= section section ::= h|p|indent|ul|ol|dl|pre indent ::= p|indent ul ::= li|ul|ol|dl ol ::= li|ol|ul|dl dl ::= dt dd|dl|ul|ol
Constructor. Blesses hash with fields type, id, and content. Values for these fields may be passed as parameters via %options.
Creates a new structural node and pushes it onto the current node's list of children. Returns the value of the new child node. You can set the child node's fields via the %options parameter, which will be passed onto the constructor.
Returns the parent node.
Returns the reference to the list of children.
type() id() content()
Chris Dent, <cdent@blueoxen.org>
Eugene Eric Kim, <eekim@blueoxen.org>
PurpleWiki::Tree, PurpleWiki::InlineNode.
To install PurpleWiki::ACL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PurpleWiki::ACL
CPAN shell
perl -MCPAN -e shell install PurpleWiki::ACL
For more information on module installation, please visit the detailed CPAN module installation guide.