19#include <unordered_map>
31 std::unordered_map<std::string,int>
idCount;
48 if (
Config_getEnum(MARKDOWN_ID_STYLE)==MARKDOWN_ID_STYLE_t::GITHUB &&
49 (anchor.empty() || anchor.front() ==
'-' || std::isdigit(anchor.front())))
61 std::lock_guard lock(
p->mutex);
65 auto createDoxygenStyleAnchor = [&]()
68 result =
prefix+std::to_string(
p->anchorCount++);
71 auto createGitHubStyleAnchor = [&]()
75 while (pos<label.length())
98 createDoxygenStyleAnchor();
103 int &count =
p->idCount[result];
107 result+=
"-"+std::to_string(count);
115 case MARKDOWN_ID_STYLE_t::DOXYGEN:
116 createDoxygenStyleAnchor();
118 case MARKDOWN_ID_STYLE_t::GITHUB:
119 createGitHubStyleAnchor();
123 p->anchorsUsed.insert(result);
130 std::lock_guard lock(
p->mutex);
131 return p->anchorsUsed.find(anchor)!=
p->anchorsUsed.end();
136 std::lock_guard lock(
p->mutex);
137 return p->idCount[anchor]++;
142 return Config_getEnum(MARKDOWN_ID_STYLE)==MARKDOWN_ID_STYLE_t::DOXYGEN &&
bool isGenerated(const std::string &anchor) const
Returns true iff anchor is one of the generated anchors.
static AnchorGenerator & instance()
Returns the singleton instance.
static std::string addPrefixIfNeeded(const std::string &anchor)
std::string generate(const std::string &title)
generates an anchor for a section with title.
int reserve(const std::string &anchor)
Reserves a non-generated anchor.
static bool looksGenerated(const std::string &anchor)
Returns true if anchor is a potentially generated anchor.
std::unique_ptr< Private > p
This is an alternative implementation of QCString.
bool startsWith(const char *s) const
#define Config_getEnum(name)
std::unordered_set< std::string > StringUnorderedSet
StringUnorderedSet anchorsUsed
std::unordered_map< std::string, int > idCount
bool isUTF8PunctuationCharacter(uint32_t unicode)
Check if the given Unicode character represents a punctuation character.
uint32_t getUnicodeForUTF8CharAt(const std::string &input, size_t pos)
Returns the 32bit Unicode value matching character at byte position pos in the UTF8 encoded input.
std::string convertUTF8ToLower(const std::string &input)
Converts the input string into a lower case version, also taking into account non-ASCII characters th...
uint8_t getUTF8CharNumBytes(char c)
Returns the number of bytes making up a single UTF8 character given the first byte in the sequence.
std::string getUTF8CharAt(const std::string &input, size_t pos)
Returns the UTF8 character found at byte position pos in the input string.
Various UTF8 related helper functions.