@Override
  public void visit(ParaNode node) {
    boolean printParagraphTag = true;

    List<Node> childNodes = node.getChildren();

    for (Node childNode : childNodes) {
      List<Node> grandchildNodes = childNode.getChildren();

      for (Node grandchildNode : grandchildNodes) {
        if (grandchildNode instanceof TextNode) {
          TextNode textNode = (TextNode) grandchildNode;

          String text = textNode.getText();

          if (text.equals("+$$$") || text.equals("$$$")) {
            visitChildren(node);

            printParagraphTag = false;
          }
        }
      }
    }

    if (printParagraphTag) {
      printTag(node, "p");
    }
  }
  @Override
  public void visit(HeaderNode node) {
    if (node.getLevel() != 1) {
      List<Node> childNodes = node.getChildren();

      if (!childNodes.isEmpty()) {
        Node childNode = childNodes.get(0);

        if (childNode instanceof TextNode) {
          TextNode textNode = (TextNode) childNodes.get(0);

          String text = textNode.getText();

          text = text.toLowerCase();

          text = text.replaceAll("[^a-z0-9 ]", "");

          text = text.trim();

          text = text.replace(' ', '-');

          printer.print("<a id=\"" + text + "\"></a>");
        }
      }
    }

    super.visit(node);
  }
Ejemplo n.º 3
0
  public PicWithCaptionNode(String src, Node node) {
    super(node);

    _src = src;

    List<Node> nodes = node.getChildren();

    if ((nodes != null) && !nodes.isEmpty() && (nodes.get(0) instanceof TextNode)) {

      TextNode textNode = (TextNode) nodes.get(0);

      _alt = textNode.getText();
    } else {
      _alt = _BLANK;
    }
  }
Ejemplo n.º 4
0
 @Override
 public void visit(TextNode node) {
   if (this.pages < 2 && StringUtils.isEmptyOrNull(this.title)) {
     this.title = node.getText();
   }
   super.visit(node);
 }
  @Override
  public void visit(TextNode node) {
    String text = node.getText();

    if (text.equals("+$$$")) {
      printer.print("<div class=\"sidebar\">");
      printer.print("<div class=\"sidebar-image\"></div>");
      printer.print("<div class=\"sidebar-text\">");
    } else if (text.equals("$$$")) {
      printer.print("</div></div>");
    } else if (abbreviations.isEmpty()) {
      printer.print(text);
    } else {
      printWithAbbreviations(text);
    }
  }