class Danger::Toc::Constructors::GithubConstructor

Constants

PUNCTUATION_REGEXP

Public Instance Methods

basic_generate_id(str) click to toggle source
# 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