@@ -0,0 +1,3054 @@
+package org.commonmark.ext.headerids;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0A/**%0A * Provider of unique strings to be used as an identifier%0A */%0Apublic class UniqueIdentifierProvider%0A%7B%0A    private String defaultIdentifier;%0A    private final Map%3CString, Integer%3E identityMap;%0A%0A    /**%0A     * Create a provider with the default identifier of %22id%22%0A     */%0A    public UniqueIdentifierProvider() %7B%0A        this(%22id%22);%0A    %7D%0A%0A    /**%0A     * @param defaultIdentifier default identifier to use if given a null, or empty %7B@code providedIdentity%7D%0A     *                          in %7B@link #getUniqueIdentifier(String)%7D%0A     */%0A    public UniqueIdentifierProvider(String defaultIdentifier)%0A    %7B%0A        this.defaultIdentifier = defaultIdentifier;%0A        this.identityMap = new HashMap%3C%3E();%0A    %7D%0A%0A    public String getDefaultIdentifier()%0A    %7B%0A        return defaultIdentifier;%0A    %7D%0A%0A    public void setDefaultIdentifier(String defaultIdentifier)%0A    %7B%0A        this.defaultIdentifier = defaultIdentifier;%0A    %7D%0A%0A    /**%0A     * %3Cp%3E%0A     * Provides unique strings over the lifetime of the instance%0A     * %3C/p%3E%0A     * %3Cp%3E%0A     * This method is not thread safe, concurrent calls can end up%0A     * with non-unique identifiers%0A     * %3C/p%3E%0A     * %3Cp%3E%0A     * Note that collision can occur in the case that%0A     * %3Cul%3E%0A     * %3Cli%3EString 'X' provided to getUniqueIdentifier%3C/li%3E%0A     * %3Cli%3EString 'X' provided again to getUniqueIdentifier%3C/li%3E%0A     * %3Cli%3EString 'X-1' provided to getUniqueIdentifier%3C/li%3E%0A     * %3C/ul%3E%0A     * %3C/p%3E%0A     * %3Cp%3E%0A     * In that case, the three ids provided will be%0A     * %3Cul%3E%0A     * %3Cli%3EX%3C/li%3E%0A     * %3Cli%3EX-1%3C/li%3E%0A     * %3Cli%3EX-1%3C/li%3E%0A     * %3C/ul%3E%0A     * %3C/p%3E%0A     * %3Cp%3E%0A     * Therefore if collisions are unnacceptable you should ensure that%0A     * numbers are stripped from end of %7B@code providedIdentity%7D%0A     * %3C/p%3E%0A     *%0A     * @param providedIdentity tentative identifier to be used. Will be used to check if this is unique. Will be the%0A     *                         basis for the returned identifier%0A     *%0A     * @return %7B@code providedIdentity%7D if this is the first instance that the %7B@code providedIdentity%7D has been passed%0A     * to the method. Otherwise, %7B@code providedIdentity + %22-%22 + X%7D will be returned, where X is the number of times%0A     * that %7B@code providedIdentity%7D has previously been passed in. If %7B@code providedIdentity%7D is empty, the default%0A     * identifier given in the constructor (or %22id%22 if none given) will be used.%0A     */%0A    public String getUniqueIdentifier(String providedIdentity) %7B%0A        if (providedIdentity == null %7C%7C providedIdentity.trim().length() == 0) %7B%0A            providedIdentity = defaultIdentifier;%0A        %7D%0A%0A        if (!identityMap.containsKey(providedIdentity)) %7B%0A            identityMap.put(providedIdentity, 1);%0A            return providedIdentity;%0A        %7D else %7B%0A            int currentCount = identityMap.get(providedIdentity);%0A            identityMap.put(providedIdentity, currentCount + 1);%0A            return providedIdentity + %22-%22 +currentCount;%0A        %7D%0A    %7D%0A%7D%0A

Add UniqueID Provider as public class