chat-block-processor: create the helper functions

This commit is contained in:
Gabriel Arazas 2023-04-03 23:19:00 +08:00
parent fc2aec087d
commit 6aed7fda1e
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC

View File

@ -1,5 +1,13 @@
# frozen_string_literal: true # frozen_string_literal: true
def to_kebab_case string
string.gsub(/\s+/, '-') # Replace all spaces with dashes.
.gsub(/[^a-zA-Z0-9-]/, '') # Remove all non-alphanumerical (and dashes) characters.
.gsub(/-+/, '-') # Reduce all dashes into only one.
.gsub(/^-|-+$/, '') # Remove all leading and trailing dashes.
.downcase
end
class ChatBlock < Asciidoctor::Extensions::BlockProcessor class ChatBlock < Asciidoctor::Extensions::BlockProcessor
use_dsl use_dsl