com.vladsch.flexmark.util.html.Attributes类的使用及代码示例

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

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

Attributes介绍

暂无

代码示例

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

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

@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

@Override
public T attr(CharSequence attrName, CharSequence value) {
  if (currentAttributes == null) {
    currentAttributes = new Attributes();
  }
  currentAttributes.addValue(attrName, value);
  return (T) this;
}

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

String calculateNodeId(Node node) {
  String id = htmlIdGenerator.getId(node);
  if (attributeProviderFactories.size() != 0) {
    Attributes attributes = new Attributes();
    if (id != null) attributes.replaceValue("id", id);
    for (AttributeProvider attributeProvider : myAttributeProviders) {
      attributeProvider.setAttributes(node, AttributablePart.ID, attributes);
    }
    id = attributes.getValue("id");
  }
  return id == null ? "" : id;
}

代码示例来源: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 Attribute replaceValue(Attribute attribute) {
  return replaceValue(attribute.getName(), attribute.getValue());
}

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

if (attributeNodeName.isNotNull() && !attributeNodeName.isBlank()) {
  if (!attributeNodeName.equals(CLASS_ATTR)) {
    attributes.remove(attributeNodeName);
  attributes.addValue(attributeNodeName, attributeNode.getValue());
} else {
  attributes.addValue(CLASS_ATTR, attributeNode.getValue());
} else if (attributeNode.isId()) {
  if (node instanceof AnchorRefTarget) {
    attributes.remove(Attribute.ID_ATTR);
    attributes.addValue(Attribute.ID_ATTR, attributeNode.getValue());

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

public Attributes getNonNullAttributes() {
  if (myAttributes == null) {
    myAttributes = new Attributes();
  }
  return myAttributes;
}

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

private void setLinkAttributes(AttributablePart part, Attributes attributes) {
  if (part == LINK) {
    String linkStatus = attributes.getValue(LINK_STATUS_ATTR);
    if (LinkStatus.NOT_FOUND.isStatus(linkStatus)) {
      attributes.addValue("class", missingTargetClass);
    } else if (ZzzzzzExtension.LOCAL_ONLY.isStatus(linkStatus)) {
      attributes.addValue("class", localOnlyTargetClass);
    }
  }
}

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

private void render(EnumeratedReferenceLink node, final DocxRendererContext docx) {
  final String text = node.getText().toString();
  if (text.isEmpty()) {
    // placeholder for ordinal
    docx.text(String.valueOf(ordinal));
  } else {
    final Node referenceFormat = enumeratedOrdinals.getFormatNode(text);
    int wasOrdinal = ordinal;
    ordinal = enumeratedOrdinals.getOrdinal(text);
    final String defaultText = String.format("%s %d", EnumeratedReferenceRepository.getType(text), ordinal);
    String title = referenceFormat != null ? new EnumRefTextCollectingVisitor(ordinal).collectAndGetText(referenceFormat) : defaultText;
    Attributes attributes = new Attributes();
    if (title != null) {
      attributes.replaceValue(Attribute.TITLE_ATTR, title);
    }
    attributes = docx.extendRenderingNodeAttributes(AttributablePart.NODE, attributes);
    renderURL(node.getText(), docx, "#" + text, attributes, new EnumeratedReferenceRenderer(docx, referenceFormat, defaultText));
    ordinal = wasOrdinal;
  }
}

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

int startOffset = out.offset();
if (!attributes.isEmpty() && !myOptions.skipAttributes) {
  out.append("{");
  for (String attrName : attributes.keySet()) {
    String value = attributes.getValue(attrName);
    out.append(sep);
  myState.myAttributes.clear();

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

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

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

public String getTarget() {
  return myAttributes == null ? null : myAttributes.getValue(Attribute.TARGET_ATTR);
}

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

private long getSizeInfo(Attributes attributes, String name, double pageDimension) {
  Double value = -1.0;
  if (attributes.contains(name)) {
    String attributeValue = attributes.getValue(name).trim();
    boolean relative = false;
    if (attributeValue.endsWith("%")) {

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

public Attributes addValues(Attributes attributes) {
  for (Attribute attribute : attributes.values()) {
    addValue(attribute.getName(), attribute.getValue());
  }
  return this;
}

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

public Attribute addValue(Attribute attribute) {
  return addValue(attribute.getName(), attribute.getValue());
}

代码示例来源: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: 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();
  }
}));

相关文章