示例#1
0
 @Override
 public void visit(HeaderNode node) {
   int level = node.getLevel();
   if (level < 3 && 0 < this.pages++) {
     this.printer.print("</section><section>");
   }
   this.printTag(node, "h" + node.getLevel());
 }
  @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);
  }