本文整理了Java中com.vladsch.flexmark.util.html.Attributes.replaceValue()
方法的一些代码示例,展示了Attributes.replaceValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Attributes.replaceValue()
方法的具体详情如下:
包路径:com.vladsch.flexmark.util.html.Attributes
类名称:Attributes
方法名:replaceValue
[英]Attribute dependent value replacement class and style append new values to existing ones others set it to the new value
[中]依赖于属性的值替换类和样式将新值附加到现有值其他人将其设置为新值
代码示例来源:origin: vsch/flexmark-java
public Attribute replaceValue(Attribute attribute) {
return replaceValue(attribute.getName(), attribute.getValue());
}
代码示例来源:origin: vsch/flexmark-java
if (options.maxImageWidth > 0 && options.maxImageWidth < width) {
cx = options.maxImageWidth;
attributes.replaceValue("width", String.valueOf(cx));
代码示例来源: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
@Override
public String getNodeId(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 : attributeProviders) {
attributeProvider.setAttributes(this.renderingNode, AttributablePart.ID, attributes);
}
id = attributes.getValue("id");
}
return id;
}
代码示例来源:origin: vsch/flexmark-java
void processAttributes(Node node) {
Attributes attributes = myState.myAttributes;
if (myOptions.outputAttributesIdAttr || !myOptions.outputAttributesNamesRegex.isEmpty()) {
final org.jsoup.nodes.Attributes nodeAttributes = node.attributes();
boolean idDone = false;
if (myOptions.outputAttributesIdAttr) {
String id = nodeAttributes.get("id");
if (id == null || id.isEmpty()) {
id = nodeAttributes.get("name");
}
if (id != null && !id.isEmpty()) {
attributes.replaceValue("id", id);
idDone = true;
}
}
if (!myOptions.outputAttributesNamesRegex.isEmpty()) {
for (org.jsoup.nodes.Attribute attribute : nodeAttributes) {
if (idDone && (attribute.getKey().equals("id") || attribute.getKey().equals("name"))) {
continue;
}
if (attribute.getKey().matches(myOptions.outputAttributesNamesRegex)) {
attributes.replaceValue(attribute.getKey(), 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 render(final Image node, final DocxRendererContext docx) {
String altText = new TextCollectingVisitor().collectAndGetText(node);
ResolvedLink resolvedLink = docx.resolveLink(LinkType.IMAGE, node.getUrl().unescape(), null, null);
String url = resolvedLink.getUrl();
Attributes attributes = resolvedLink.getNonNullAttributes();
if (!node.getUrlContent().isEmpty()) {
// reverse URL encoding of =, &
String content = Escaping.percentEncodeUrl(node.getUrlContent()).replace("+", "%2B").replace("%3D", "=").replace("%26", "&");
url += content;
}
if (!altText.isEmpty()) {
attributes.replaceValue("alt", altText);
}
attributes = docx.extendRenderingNodeAttributes(AttributablePart.NODE, attributes);
//String alt = node.getText().unescape();
renderImage(docx, url, attributes);
}
代码示例来源: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
attributes.replaceValue("alt", shortcut.alt);
if (sz != null) {
l = sz.getVal().longValue();
attributes.replaceValue("height", String.valueOf(Math.round(l / 2 / options.docEmojiImageVertSize)));
attributes.replaceValue("width", String.valueOf(Math.round(l / 2 / options.docEmojiImageVertSize)));
} else if (!emojiOptions.attrImageSize.isEmpty()) {
attributes.replaceValue("height", emojiOptions.attrImageSize);
attributes.replaceValue("width", emojiOptions.attrImageSize);
attributes.replaceValue("align", emojiOptions.attrAlign);
代码示例来源: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: vsch/flexmark-java
resolvedLink.getNonNullAttributes().replaceValue(Attribute.TITLE_ATTR, reference.getTitle().unescape());
} else {
resolvedLink.getNonNullAttributes().remove(Attribute.TITLE_ATTR);
attributes.replaceValue("alt", altText);
代码示例来源: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);
内容来源于网络,如有侵权,请联系作者删除!