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

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

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

Attributes.remove介绍

暂无

代码示例

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

void excludeAttributes(String... excludes) {
  for (String exclude : excludes) {
    myState.myAttributes.remove(exclude);
  }
}

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

public Attribute remove(Attribute attribute) {
  return remove(attribute.getName());
}

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

void transferIdToParent() {
  if (myStateStack.isEmpty())
    throw new IllegalStateException("transferIdToParent with an empty stack");
  final Attribute attribute = myState.myAttributes.get("id");
  myState.myAttributes.remove("id");
  if (attribute != null && !attribute.getValue().isEmpty()) {
    State state = myStateStack.peek();
    if (state != null) {
      state.myAttributes.addValue("id", attribute.getValue());
    }
  }
}

代码示例来源: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

if (attributeNodeName.isNotNull() && !attributeNodeName.isBlank()) {
  if (!attributeNodeName.equals(CLASS_ATTR)) {
    attributes.remove(attributeNodeName);
    attributes.remove(Attribute.ID_ATTR);
    attributes.addValue(Attribute.ID_ATTR, attributeNode.getValue());

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

private void render(final Link node, final DocxRendererContext docx) {
  ResolvedLink resolvedLink = docx.resolveLink(LinkType.LINK, node.getUrl().unescape(), null, null);
  // we have a title part, use that
  Attributes attributes = resolvedLink.getNonNullAttributes();
  if (node.getTitle().isNotNull()) {
    attributes.replaceValue(Attribute.TITLE_ATTR, node.getTitle().unescape());
  } else {
    attributes.remove(Attribute.TITLE_ATTR);
  }
  attributes = docx.extendRenderingNodeAttributes(AttributablePart.NODE, attributes);
  renderURL(node.getUrl(), docx, resolvedLink.getUrl(), attributes, new ChildRenderer(docx, node));
}

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

@SuppressWarnings("MethodMayBeStatic")
void render(Image node, NodeRendererContext context, HtmlWriter html) {
  if (!(context.isDoNotRenderLinks() || isSuppressedLinkPrefix(node.getUrl(), context))) {
    String altText = new TextCollectingVisitor().collectAndGetText(node);
    ResolvedLink resolvedLink = context.resolveLink(LinkType.IMAGE, node.getUrl().unescape(), null, null);
    String url = resolvedLink.getUrl();
    if (!node.getUrlContent().isEmpty()) {
      // reverse URL encoding of =, &
      String content = Escaping.percentEncodeUrl(node.getUrlContent()).replace("+", "%2B").replace("%3D", "=").replace("%26", "&");
      url += content;
    }
    html.attr("src", url);
    html.attr("alt", altText);
    // we have a title part, use that
    if (node.getTitle().isNotNull()) {
      resolvedLink.getNonNullAttributes().replaceValue(Attribute.TITLE_ATTR, node.getTitle().unescape());
    } else {
      resolvedLink.getNonNullAttributes().remove(Attribute.TITLE_ATTR);
    }
    html.attr(resolvedLink.getAttributes());
    html.srcPos(node.getChars()).withAttr(resolvedLink).tagVoid("img");
  }
}

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

public Attribute remove(Attribute attribute) {
  return remove(attribute.getName());
}

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

resolvedLink.getNonNullAttributes().replaceValue(Attribute.TITLE_ATTR, reference.getTitle().unescape());
} else {
  resolvedLink.getNonNullAttributes().remove(Attribute.TITLE_ATTR);

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

void render(Link node, NodeRendererContext context, HtmlWriter html) {
  if (context.isDoNotRenderLinks() || isSuppressedLinkPrefix(node.getUrl(), context)) {
    context.renderChildren(node);
  } else {
    ResolvedLink resolvedLink = context.resolveLink(LinkType.LINK, node.getUrl().unescape(), null, null);
    html.attr("href", resolvedLink.getUrl());
    // we have a title part, use that
    if (node.getTitle().isNotNull()) {
      resolvedLink.getNonNullAttributes().replaceValue(Attribute.TITLE_ATTR, node.getTitle().unescape());
    } else {
      resolvedLink.getNonNullAttributes().remove(Attribute.TITLE_ATTR);
    }
    html.attr(resolvedLink.getAttributes());
    html.srcPos(node.getChars()).withAttr(resolvedLink).tag("a");
    renderChildrenSourceLineWrapped(node, node.getText(), context, html);
    html.tag("/a");
  }
}

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

resolvedLink.getNonNullAttributes().replaceValue(Attribute.TITLE_ATTR, reference.getTitle().unescape());
} else {
  resolvedLink.getNonNullAttributes().remove(Attribute.TITLE_ATTR);

代码示例来源: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: vsch/flexmark-java

resolvedLink.getNonNullAttributes().replaceValue(Attribute.TITLE_ATTR, reference.getTitle().unescape());
} else {
  resolvedLink.getNonNullAttributes().remove(Attribute.TITLE_ATTR);

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

resolvedLink.getNonNullAttributes().replaceValue(Attribute.TITLE_ATTR, reference.getTitle().unescape());
} else {
  resolvedLink.getNonNullAttributes().remove(Attribute.TITLE_ATTR);

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

resolvedLink.getNonNullAttributes().replaceValue(Attribute.TITLE_ATTR, reference.getTitle().unescape());
} else {
  resolvedLink.getNonNullAttributes().remove(Attribute.TITLE_ATTR);

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

void render(Link node, NodeRendererContext context, HtmlWriter html) {
  if (context.isDoNotRenderLinks() || isSuppressedLinkPrefix(node.getUrl(), context)) {
    context.renderChildren(node);
  } else {
    ResolvedLink resolvedLink = context.resolveLink(LinkType.LINK, node.getUrl().unescape(), null, null);
    html.attr("href", resolvedLink.getUrl());
    // we have a title part, use that
    if (node.getTitle().isNotNull()) {
      resolvedLink.getNonNullAttributes().replaceValue(Attribute.TITLE_ATTR, node.getTitle().unescape());
    } else {
      resolvedLink.getNonNullAttributes().remove(Attribute.TITLE_ATTR);
    }
    html.attr(resolvedLink.getAttributes());
    html.srcPos(node.getChars()).withAttr(resolvedLink).tag("a");
    renderChildrenSourceLineWrapped(node, node.getText(), context, html);
    html.tag("/a");
  }
}

相关文章