
com.vladsch.flexmark.ext.abbreviation.internal.AbbreviationRepository Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of flexmark-ext-abbreviation Show documentation
Show all versions of flexmark-ext-abbreviation Show documentation
flexmark-java extension for defining abbreviations and turning appearance of these abbreviations in text into links with titles consisting of the expansion of the abbreviation
The newest version!
package com.vladsch.flexmark.ext.abbreviation.internal;
import com.vladsch.flexmark.ext.abbreviation.Abbreviation;
import com.vladsch.flexmark.ext.abbreviation.AbbreviationBlock;
import com.vladsch.flexmark.ext.abbreviation.AbbreviationExtension;
import com.vladsch.flexmark.util.ast.KeepType;
import com.vladsch.flexmark.util.ast.Node;
import com.vladsch.flexmark.util.ast.NodeRepository;
import com.vladsch.flexmark.util.data.DataHolder;
import com.vladsch.flexmark.util.data.DataKey;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
@SuppressWarnings("WeakerAccess")
public class AbbreviationRepository extends NodeRepository {
public AbbreviationRepository(DataHolder options) {
super(AbbreviationExtension.ABBREVIATIONS_KEEP.get(options));
}
@NotNull
@Override
public DataKey getDataKey() {
return AbbreviationExtension.ABBREVIATIONS;
}
@NotNull
@Override
public DataKey getKeepDataKey() {
return AbbreviationExtension.ABBREVIATIONS_KEEP;
}
@NotNull
@Override
public Set getReferencedElements(Node parent) {
HashSet references = new HashSet<>();
visitNodes(parent, value -> {
if (value instanceof Abbreviation) {
AbbreviationBlock reference = ((Abbreviation) value).getReferenceNode(AbbreviationRepository.this);
if (reference != null) {
references.add(reference);
}
}
}, Abbreviation.class);
return references;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy