use of com.vladsch.flexmark.ext.enumerated.reference.internal.EnumRefTextCollectingVisitor in project flexmark-java by vsch.
the class CoreNodeDocxRenderer method render.
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", EnumeratedReferences.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 Runnable() {
@Override
public void run() {
if (referenceFormat != null) {
docx.renderChildren(referenceFormat);
} else {
// no format, just output ordinal
docx.text(defaultText);
}
}
});
ordinal = wasOrdinal;
}
}
Aggregations