Package info.bliki.htmlcleaner

Examples of info.bliki.htmlcleaner.ContentToken


        fWikiModel.append(tag);
      } else {
        fWikiModel.pushNode(tag);
        if (null != bodyString) {
          if (tag instanceof INoBodyParsingTag) {
            ((TagNode) tag).addChild(new ContentToken(bodyString));
          } else {
            // recursively filter tags within the tags body string
            WikipediaPreTagParser.parseRecursive(bodyString.trim(), fWikiModel, false, true);
          }
        }
        if (tag instanceof IBodyTag) {
          fWikiModel.popNode();
        }
      }
    } catch (IllegalArgumentException e) {
      TagNode divTagNode = new TagNode("div");
      divTagNode.addAttribute("class", "error", true);
      divTagNode.addChild(new ContentToken("IllegalArgumentException: " + command + " - " + e.getMessage()));
      fWikiModel.append(divTagNode);
      e.printStackTrace();
    } catch (Throwable e) {
      e.printStackTrace();
      TagNode divTagNode = new TagNode("div");
      divTagNode.addAttribute("class", "error", true);
      divTagNode.addChild(new ContentToken(command + ": " + e.getMessage()));
      fWikiModel.append(divTagNode);
      e.printStackTrace();
    }
  }
View Full Code Here


      int level = wikiModel.incrementRecursionLevel();

      if (level > Configuration.PARSER_RECURSION_LIMIT) {
        TagNode error = new TagNode("span");
        error.addAttribute("class", "error", true);
        error.addChild(new ContentToken("Error - recursion limit exceeded parsing wiki tags."));
        localStack.append(error);
        return localStack;
      }
      // WikipediaParser parser = new WikipediaParser(rawWikitext,
      // wikiModel.isTemplateTopic(), wikiModel.getWikiListener());
      setModel(wikiModel);
      runParser();
      return localStack;
    } catch (InvalidPreWikiTag ipwt) {
      createOnlyLocalStack = true;
      throw ipwt;
    } catch (Exception e) {
      e.printStackTrace();
      TagNode error = new TagNode("span");
      error.addAttribute("class", "error", true);
      error.addChild(new ContentToken(e.getClass().getSimpleName()));
      localStack.append(error);
    } catch (Error e) {
      e.printStackTrace();
      TagNode error = new TagNode("span");
      error.addAttribute("class", "error", true);
      error.addChild(new ContentToken(e.getClass().getSimpleName()));
      localStack.append(error);
    } finally {
      wikiModel.decrementRecursionLevel();
      if (!createOnlyLocalStack) {
        // append the resursively parsed local stack to the global wiki
View Full Code Here

    aTagNode.addAttribute("rel", "nofollow", true);
    if (withoutSquareBrackets) {
      aTagNode.addAttribute("class", "external free", true);
//      aTagNode.addAttribute("title", link, true);
      append(aTagNode);
      aTagNode.addChild(new ContentToken(linkName));
    } else {
      String trimmedText = linkName.trim();
      if (trimmedText.length() > 0) {
        pushNode(aTagNode);
        if (linkName.equals(link)
            // protocol-relative URLs also get auto-numbered if there is no real alias
            || (link.length() >= 2 && link.charAt(0) == '/' && link.charAt(1) == '/'
                && link.substring(2).equals(linkName))) {
          aTagNode.addAttribute("class", "external autonumber", true);
          aTagNode.addChild(new ContentToken("[" + (++fExternalLinksCounter) + "]"));
        } else {
          aTagNode.addAttribute("class", "external text", true);
//          aTagNode.addAttribute("title", link, true);
          WikipediaParser.parseRecursive(trimmedText, this, false, true);
        }
View Full Code Here

    pushNode(aTagNode);
    if (parseRecursive) {
      WikipediaPreTagParser.parseRecursive(topicDescription.trim(), this, false, true);
    } else {
      aTagNode.addChild(new ContentToken(topicDescription));
    }
    popNode();
  }
View Full Code Here

    append(aTagNode);
    aTagNode.addAttribute("href", isbnString, true);
    aTagNode.addAttribute("class", "external text", true);
    aTagNode.addAttribute("title", isbnString, true);
    aTagNode.addAttribute("rel", "nofollow", true);
    aTagNode.addChild(new ContentToken(isbnPureText));
  }
View Full Code Here

    append(aTagNode);
    aTagNode.addAttribute("href", link, true);
    aTagNode.addAttribute("class", "external free", true);
    aTagNode.addAttribute("title", link, true);
    aTagNode.addAttribute("rel", "nofollow", true);
    aTagNode.addChild(new ContentToken(linkName));
  }
View Full Code Here

          }
        } else if (rawNamespaceTopic.charAt(colonIndex + 1) == '=') {
          // found an SMW attribute
          String attributeValue = rawNamespaceTopic.substring(colonIndex + 2);
          if (addSemanticAttribute(nameSpace, attributeValue)) {
            append(new ContentToken(attributeValue));
            return true;
          }
        }

      }
View Full Code Here

    }
  }

  public void nodeToWiki(BaseToken node, StringBuilder wikiText) {
    if (node instanceof ContentToken) {
      ContentToken contentToken = (ContentToken) node;
      String content = contentToken.getContent();
      content = content.replaceAll(" ", " ");
      // content = StringUtils.replace(content, " ", " ");
      wikiText.append(content);
    } else if (node instanceof TagNode) {
      TagNode tagNode = (TagNode) node;
View Full Code Here

    }
  }

  public void nodesToPlainText(BaseToken node, StringBuilder plainText) {
    if (node instanceof ContentToken) {
      ContentToken contentToken = (ContentToken) node;
      // TODO refactor this:
      String content = contentToken.getContent();
      content = content.replaceAll(" ", " ");
      content = content.replaceAll("&lt;", "<");
      content = content.replaceAll("&gt;", ">");
      content = content.replaceAll("&quot;", "\"");
      content = content.replaceAll("&amp;", "&");
View Full Code Here

    aTagNode.addAttribute("rel", "nofollow", true);
    if (withoutSquareBrackets) {
      aTagNode.addAttribute("class", "externallink", true);
      aTagNode.addAttribute("title", link, true);
      append(aTagNode);
      aTagNode.addChild(new ContentToken(linkName));
    } else {
      String trimmedText = linkName.trim();
      if (trimmedText.length() > 0) {
        pushNode(aTagNode);
        if (linkName.equals(link)) {
          if (withoutSquareBrackets) {
            aTagNode.addAttribute("class", "externallink", true);
            aTagNode.addAttribute("title", link, true);
            aTagNode.addChild(new ContentToken(trimmedText));
          } else {
            aTagNode.addAttribute("class", "external autonumber", true);
            aTagNode.addChild(new ContentToken("["+(++fExternalLinksCounter)+"]"));
          }
        } else {
          aTagNode.addAttribute("class", "externallink", true);
          aTagNode.addAttribute("title", link, true);
          WikipediaParser.parseRecursive(trimmedText, this, false, true);
View Full Code Here

TOP

Related Classes of info.bliki.htmlcleaner.ContentToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.