org.jsoup.parser.Tag.isSelfClosing()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中org.jsoup.parser.Tag.isSelfClosing()方法的一些代码示例,展示了Tag.isSelfClosing()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tag.isSelfClosing()方法的具体详情如下:
包路径:org.jsoup.parser.Tag
类名称:Tag
方法名:isSelfClosing

Tag.isSelfClosing介绍

[英]Get if this tag is self closing.
[中]获取此标签是否自动关闭。

代码示例

代码示例来源:origin: org.jsoup/jsoup

void outerHtmlTail(Appendable accum, int depth, Document.OutputSettings out) throws IOException {
  if (!(childNodes.isEmpty() && tag.isSelfClosing())) {
    if (out.prettyPrint() && (!childNodes.isEmpty() && (
        tag.formatAsBlock() || (out.outline() && (childNodes.size()>1 || (childNodes.size()==1 && !(childNodes.get(0) instanceof TextNode))))
    )))
      indent(accum, depth, out);
    accum.append("</").append(tagName()).append('>');
  }
}

代码示例来源:origin: org.jsoup/jsoup

void outerHtmlHead(final Appendable accum, int depth, final Document.OutputSettings out) throws IOException {
  if (out.prettyPrint() && (tag.formatAsBlock() || (parent() != null && parent().tag().formatAsBlock()) || out.outline())) {
    if (accum instanceof StringBuilder) {
      if (((StringBuilder) accum).length() > 0)
        indent(accum, depth, out);
    } else {
      indent(accum, depth, out);
    }
  }
  accum.append('<').append(tagName());
  if (attributes != null) attributes.html(accum, out);
  // selfclosing includes unknown tags, isEmpty defines tags that are always empty
  if (childNodes.isEmpty() && tag.isSelfClosing()) {
    if (out.syntax() == Document.OutputSettings.Syntax.html && tag.isEmpty())
      accum.append('>');
    else
      accum.append(" />"); // <img> in html, <img /> in xml
  }
  else
    accum.append('>');
}

代码示例来源:origin: perfectsense/brightspot-cms

String html = element.outerHtml();
if (element.tag().isSelfClosing()) {
  viewNodes.add(new StringRichTextViewNode<>(html, htmlToView));

代码示例来源:origin: astamuse/asta4d

Element insertEmpty(Token.StartTag startTag) {
  Tag tag = Tag.valueOf(startTag.name());
  Element el = new Element(tag, baseUri, startTag.attributes);
  insertNode(el);
  if (startTag.isSelfClosing()) {
    if (tag.isKnownTag()) {
      if (tag.isSelfClosing())
        tokeniser.acknowledgeSelfClosingFlag(); // if not acked, promulagates error
    } else {
      // unknown tag, remember this is self closing for output
      tag.setSelfClosing();
      tokeniser.acknowledgeSelfClosingFlag(); // not an distinct error
    }
  }
  return el;
}

相关文章