@Test
  public void testParseSimpleLinkTag() {
    WikiPageNode wikiPageNode = getWikiPageNode("link-1.creole");

    Assert.assertNotNull(wikiPageNode);

    ParagraphNode paragraphNode = (ParagraphNode) wikiPageNode.getChildASTNode(0);

    LineNode lineNode = (LineNode) paragraphNode.getChildASTNode(0);

    Assert.assertEquals(1, lineNode.getChildASTNodesCount());

    LinkNode linkNode = (LinkNode) lineNode.getChildASTNode(0);

    Assert.assertEquals("link", linkNode.getLink());

    CollectionNode collectionNode = linkNode.getAltCollectionNode();

    Assert.assertNotNull(collectionNode);
    Assert.assertEquals(1, collectionNode.size());

    List<ASTNode> astNodes = collectionNode.getASTNodes();

    UnformattedTextNode unformattedTextNode = (UnformattedTextNode) astNodes.get(0);

    CollectionNode unformattedTextNodes = (CollectionNode) unformattedTextNode.getChildASTNode(0);

    unformattedTextNode = (UnformattedTextNode) unformattedTextNodes.get(0);

    Assert.assertEquals("alternative text", unformattedTextNode.getContent());
  }
  public void visit(LinkNode linkNode) {
    append("<a href=\"");
    append(HtmlUtil.escape(linkNode.getLink()));
    append("\">");

    if (linkNode.hasAltCollectionNode()) {
      CollectionNode altCollectionNode = linkNode.getAltCollectionNode();

      traverse(altCollectionNode.getASTNodes());
    } else {
      append(HtmlUtil.escape(linkNode.getLink()));
    }

    append("</a>");
  }
  public void visit(ImageNode imageNode) {
    append("<img src=\"");
    append(HtmlUtil.escape(imageNode.getLink()));
    append("\" ");

    if (imageNode.hasAltCollectionNode()) {
      append("alt=\"");

      CollectionNode altCollectionNode = imageNode.getAltNode();

      traverse(altCollectionNode.getASTNodes());

      append("\"");
    }

    append("/>");
  }
  @Test
  public void testParseSimpleLinkTagWithoutDescription2() {
    WikiPageNode wikiPageNode = getWikiPageNode("link-3.creole");

    Assert.assertNotNull(wikiPageNode);

    ParagraphNode paragraphNode = (ParagraphNode) wikiPageNode.getChildASTNode(0);

    LineNode lineNode = (LineNode) paragraphNode.getChildASTNode(0);

    Assert.assertEquals(5, lineNode.getChildASTNodesCount());

    List<ASTNode> astNodes = lineNode.getChildASTNodes();

    for (ASTNode astNode : astNodes) {
      if (!(astNode instanceof LinkNode)) {
        continue;
      }

      LinkNode linkNode = (LinkNode) astNode;

      Assert.assertEquals("L", linkNode.getLink());

      CollectionNode collectionNode = linkNode.getAltCollectionNode();

      Assert.assertNotNull(collectionNode);
      Assert.assertEquals(1, collectionNode.size());

      List<ASTNode> collectionNodeASTNodes = collectionNode.getASTNodes();

      UnformattedTextNode unformattedTextNode = (UnformattedTextNode) collectionNodeASTNodes.get(0);

      collectionNode = (CollectionNode) unformattedTextNode.getChildASTNode(0);

      unformattedTextNode = (UnformattedTextNode) collectionNode.get(0);

      Assert.assertEquals("A", unformattedTextNode.getContent());
    }
  }
 public void visit(CollectionNode collectionNode) {
   for (ASTNode astNode : collectionNode.getASTNodes()) {
     astNode.accept(this);
   }
 }