internal string MakeUniqueHeaderID(string strHeaderText, int startOffset, int length) { if (!AutoHeadingIDs) { return(null); } // Extract a pandoc style cleaned header id from the header text string strBase = m_SpanFormatter.MakeID(strHeaderText, startOffset, length); // If nothing left, use "section" if (String.IsNullOrEmpty(strBase)) { strBase = "section"; } // Make sure it's unique by append -n counter string strWithSuffix = strBase; int counter = 1; while (m_UsedHeaderIDs.ContainsKey(strWithSuffix)) { strWithSuffix = strBase + "-" + counter.ToString(); counter++; } // Store it m_UsedHeaderIDs.Add(strWithSuffix, true); // Return it return(strWithSuffix); }