Module: Gitlab::Utils::Markdown
- Included in:
- Banzai::Filter::TableOfContentsFilter
- Defined in:
- lib/gitlab/utils/markdown.rb
Constant Summary collapse
- PUNCTUATION_REGEXP =
/[^\p{Word}\- ]/u
- PRODUCT_SUFFIX =
/\s*\**\((premium|ultimate|free|beta|experiment)(\s+(all|self|saas))?(\s+(beta|experiment))?\)\**/
Instance Method Summary collapse
Instance Method Details
#string_to_anchor(string) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/gitlab/utils/markdown.rb', line 9 def string_to_anchor(string) string .strip .downcase .gsub(PRODUCT_SUFFIX, '') .gsub(PUNCTUATION_REGEXP, '') # remove punctuation .tr(' ', '-') # replace spaces with dash .squeeze('-') # replace multiple dashes with one .gsub(/\A(\d+)\z/, 'anchor-\1') # digits-only hrefs conflict with issue refs end |