Class: Danger::Toc::Constructors::GithubConstructor

Inherits:
KramdownConstructor
  • Object
show all
Defined in:
lib/toc/constructors/github_constructor.rb

Constant Summary collapse

PUNCTUATION_REGEXP =
/[^\p{Word}\- ]/u

Instance Method Summary collapse

Methods inherited from KramdownConstructor

#convert, #flatten

Instance Method Details

#basic_generate_id(str) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/toc/constructors/github_constructor.rb', line 7

def basic_generate_id(str)
  # Get source code from https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/toc_filter.rb#L38
  id = str.downcase
  id.gsub!(PUNCTUATION_REGEXP, '') # remove punctuation
  id.tr!(' ', '-') # replace spaces with dash
  id
end