The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

PurpleWiki::InlineNode - Inline node object

SYNOPSIS

  use PurpleWiki::InlineNode;

  # Create node of type 'text' and content 'Hello, world!'
  my $inlineNode1 =
      PurpleWiki::InlineNode->new(type => 'text',
                                  content => 'Hello, world!');

  # Represent bolded and italicized 'Hello, world!'.
  # First, create node of type 'b'.
  my $boldNode = PurpleWiki::InlineNode->new(type => 'b');

  # Create node of type 'i'.
  my $italicsNode = PurpleWiki::InlineNode->new(type => 'i');

  # Create 'text' node with content 'Hello, world!'.
  my $textNode =
      PurpleWiki::InlineNode->new(type => 'text',
                                  content => 'Hello, world!');

  # Make 'text' node a child of 'i' node, and 'i' node a child
  # of 'b' node.
  $italicsNode->children([$textNode]);
  $boldNode->children([$italicsNode]);

DESCRIPTION

Inline nodes make up the content of structural nodes. They are mostly content containers, although some types use children to handle nested inline content, such as bold and italicized content.

The data structure looks like:

  PurpleWiki::InlineNode = {
    type     => text|nowiki|b|i|tt|wikiword|freelink|link|url|image
    href     => string
    content  => string
    children => [PurpleWiki::InlineNode, ...]
  }

Content Nodes

There are two content nodes: text and nowiki. Both use the content field, and neither allow nesting.

The nowiki type is useful for serializing trees as WikiText. For example, if you had the text:

  Brevity is the soul of wit. --WilliamShakespeare

it would make no difference to PurpleWiki internally if you treated this as either a text node or a nowiki node. In both cases, "WilliamShakespeare" is not treated as a Wiki word. However, the correct WikiText serialization is:

  <nowiki>Brevity is the soul of wit.  --WilliamShakespeare</nowiki>

Without the nowiki tags, WilliamShakespeare looks like a node of type 'wikiword', which is not the case in this example. If we did not have a nowiki type, then the View driver would have to parse the contents of the text node to see if anything ought to be surrounded by nowiki tags.

Nested Nodes

There are three types of nested nodes: b, i, and tt. The BNF constraints are as follows:

  b ::= text|nowiki|i|tt|wikiword|freelink|link|url|image
  i ::= text|nowiki|b|tt|wikiword|freelink|link|url|image
  tt ::= text|nowiki|b|i|wikiword|freelink|link|url|image

The content field of these types of nodes should be left undefined.

Suppose you had a paragraph consisting of an italicized sentence with a fixed font word:

  <i>Hello, <tt>world!</tt></i>

The corresponding inline nodes would be:

  I
  |
  +-- TEXT: 'Hello, '
  |
  +-- TT
       |
       +-- TEXT: 'world!'

In other words, you would have an i node with two children: a text node with content 'Hello, ', and a tt node. The tt node would have one child: a text node with content 'world!'.

There are four types of link nodes:

  wikiword -- WikiWord
  freelink -- free link (double bracketed links)
  link     -- links (bracketed links)
  url      -- URLs
  image    -- images

Each of these nodes use both the content and href fields. Link nodes are not nested.

AUTHORS

Chris Dent, <cdent@blueoxen.org>

Eugene Eric Kim, <eekim@blueoxen.org>

SEE ALSO

PurpleWiki::StructuralNode.