com.vladsch.flexmark.util.html.Attributes.isEmpty()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(124)

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

Attributes.isEmpty介绍

暂无

代码示例

代码示例来源:origin: vsch/flexmark-java

@Override
public T attr(Attributes attributes) {
  if (attributes != null && !attributes.isEmpty()) {
    if (currentAttributes == null) {
      currentAttributes = new Attributes(attributes);
    } else {
      currentAttributes.addValues(attributes);
    }
  }
  return (T) this;
}

代码示例来源:origin: vsch/flexmark-java

public ResolvedLink withTitle(CharSequence title) {
  String haveTitle = myAttributes == null ? null : myAttributes.getValue(Attribute.TITLE_ATTR);
  if (title == haveTitle || haveTitle != null && haveTitle.equals(title)) return this;
  Attributes attributes = new Attributes(myAttributes);
  if (title == null) {
    attributes.remove(Attribute.TITLE_ATTR);
    if (attributes.isEmpty()) attributes = null;
  } else {
    attributes.replaceValue(Attribute.TITLE_ATTR, title);
  }
  return new ResolvedLink(myLinkType, myUrl, attributes, myStatus);
}

代码示例来源:origin: vsch/flexmark-java

public ResolvedLink withTarget(CharSequence target) {
  String haveTarget = myAttributes == null ? null : myAttributes.getValue(Attribute.TARGET_ATTR);
  if (target == haveTarget || haveTarget != null && haveTarget.equals(target)) return this;
  Attributes attributes = new Attributes(myAttributes);
  if (target == null) {
    attributes.remove(Attribute.TARGET_ATTR);
    if (attributes.isEmpty()) attributes = null;
  } else {
    attributes.replaceValue(Attribute.TARGET_ATTR, target);
  }
  return new ResolvedLink(myLinkType, myUrl, attributes, myStatus);
}

代码示例来源:origin: vsch/flexmark-java

private void transferToParentOnly(String... includes) {
  if (myStateStack.isEmpty())
    throw new IllegalStateException("transferIdToParent with an empty stack");
  final Attributes attributes = new Attributes();
  for (String include : includes) {
    Attribute attribute = myState.myAttributes.get(include);
    if (attribute != null) {
      myState.myAttributes.remove(include);
      attributes.addValue(attribute);
    }
  }
  if (!attributes.isEmpty()) {
    final State parentState = myStateStack.peek();
    for (String attrName : attributes.keySet()) {
      parentState.myAttributes.addValue(attributes.get(attrName));
    }
  }
}

代码示例来源:origin: vsch/flexmark-java

private void transferToParentExcept(String... excludes) {
  if (myStateStack.isEmpty())
    throw new IllegalStateException("transferIdToParent with an empty stack");
  final Attributes attributes = new Attributes(myState.myAttributes);
  myState.myAttributes.clear();
  for (String exclude : excludes) {
    myState.myAttributes.addValue(attributes.get(exclude));
    attributes.remove(exclude);
  }
  if (!attributes.isEmpty()) {
    final State parentState = myStateStack.peek();
    for (String attrName : attributes.keySet()) {
      parentState.myAttributes.addValue(attributes.get(attrName));
    }
  }
}

代码示例来源:origin: vsch/flexmark-java

int startOffset = out.offset();
if (!attributes.isEmpty() && !myOptions.skipAttributes) {

代码示例来源:origin: vsch/flexmark-java

@Override
  public void render(TextBase node, NodeRendererContext context, HtmlWriter html) {
    if (myOptions.assignTextAttributes) {
      final Attributes nodeAttributes = context.extendRenderingNodeAttributes(AttributablePart.NODE, null);
      if (!nodeAttributes.isEmpty()) {
        // has attributes then we wrap it in a span
        html.setAttributes(nodeAttributes).withAttr().tag("span");
        context.delegateRender();
        html.closeTag("span");
        return;
      }
    }
    context.delegateRender();
  }
}));

代码示例来源:origin: vsch/flexmark-java

@Override
public T tag(CharSequence tagName, boolean voidElement) {
  if (tagName.length() == 0 || tagName.charAt(0) == '/') return closeTag(tagName);
  Attributes attributes = null;
  if (withAttributes) {
    attributes = currentAttributes;
    currentAttributes = null;
    withAttributes = false;
  }
  out.append("<");
  out.append(tagName);
  if (attributes != null && !attributes.isEmpty()) {
    for (Attribute attribute : attributes.values()) {
      CharSequence attributeValue = attribute.getValue();
      if (attribute.isNonRendering()) continue;
      out.append(" ");
      out.append(Escaping.escapeHtml(attribute.getName(), true));
      out.append("=\"");
      out.append(Escaping.escapeHtml(attributeValue, true));
      out.append("\"");
    }
  }
  if (voidElement) {
    out.append(" />");
  } else {
    out.append(">");
    tagOpened(tagName);
  }
  return (T) this;
}

代码示例来源:origin: com.vladsch.flexmark/flexmark-util

@Override
public T attr(Attributes attributes) {
  if (attributes != null && !attributes.isEmpty()) {
    if (currentAttributes == null) {
      currentAttributes = new Attributes(attributes);
    } else {
      currentAttributes.addValues(attributes);
    }
  }
  return (T) this;
}

代码示例来源:origin: com.vladsch.flexmark/flexmark

public ResolvedLink withTitle(CharSequence title) {
  String haveTitle = myAttributes == null ? null : myAttributes.getValue(Attribute.TITLE_ATTR);
  if (title == haveTitle || haveTitle != null && haveTitle.equals(title)) return this;
  Attributes attributes = new Attributes(myAttributes);
  if (title == null) {
    attributes.remove(Attribute.TITLE_ATTR);
    if (attributes.isEmpty()) attributes = null;
  } else {
    attributes.replaceValue(Attribute.TITLE_ATTR, title);
  }
  return new ResolvedLink(myLinkType, myUrl, attributes, myStatus);
}

代码示例来源:origin: com.vladsch.flexmark/flexmark

public ResolvedLink withTarget(CharSequence target) {
  String haveTarget = myAttributes == null ? null : myAttributes.getValue(Attribute.TARGET_ATTR);
  if (target == haveTarget || haveTarget != null && haveTarget.equals(target)) return this;
  Attributes attributes = new Attributes(myAttributes);
  if (target == null) {
    attributes.remove(Attribute.TARGET_ATTR);
    if (attributes.isEmpty()) attributes = null;
  } else {
    attributes.replaceValue(Attribute.TARGET_ATTR, target);
  }
  return new ResolvedLink(myLinkType, myUrl, attributes, myStatus);
}

代码示例来源:origin: com.vladsch.flexmark/flexmark-ext-attributes

@Override
  public void render(TextBase node, NodeRendererContext context, HtmlWriter html) {
    if (myOptions.assignTextAttributes) {
      final Attributes nodeAttributes = context.extendRenderingNodeAttributes(AttributablePart.NODE, null);
      if (!nodeAttributes.isEmpty()) {
        // has attributes then we wrap it in a span
        html.setAttributes(nodeAttributes).withAttr().tag("span");
        context.delegateRender();
        html.closeTag("span");
        return;
      }
    }
    context.delegateRender();
  }
}));

代码示例来源:origin: com.vladsch.flexmark/flexmark-util

@Override
public T tag(CharSequence tagName, boolean voidElement) {
  if (tagName.length() == 0 || tagName.charAt(0) == '/') return closeTag(tagName);
  Attributes attributes = null;
  if (withAttributes) {
    attributes = currentAttributes;
    currentAttributes = null;
    withAttributes = false;
  }
  out.append("<");
  out.append(tagName);
  if (attributes != null && !attributes.isEmpty()) {
    for (Attribute attribute : attributes.values()) {
      CharSequence attributeValue = attribute.getValue();
      if (attribute.isNonRendering()) continue;
      out.append(" ");
      out.append(Escaping.escapeHtml(attribute.getName(), true));
      out.append("=\"");
      out.append(Escaping.escapeHtml(attributeValue, true));
      out.append("\"");
    }
  }
  if (voidElement) {
    out.append(" />");
  } else {
    out.append(">");
    tagOpened(tagName);
  }
  return (T) this;
}

相关文章