Create a helper file for the Asciidoctor extension

This commit is contained in:
Gabriel Arazas 2023-04-03 23:34:59 +08:00
parent 809f08e382
commit 86a1afa512
2 changed files with 13 additions and 0 deletions

View File

@ -2,6 +2,9 @@
require 'asciidoctor' require 'asciidoctor'
require 'asciidoctor/extensions' require 'asciidoctor/extensions'
require_relative 'helpers'
require_relative 'man-inline-macro/extension' require_relative 'man-inline-macro/extension'
require_relative 'swhid-inline-macro/extension' require_relative 'swhid-inline-macro/extension'
require_relative 'swhid-include-processor/extension' require_relative 'swhid-include-processor/extension'

View File

@ -0,0 +1,10 @@
# frozen_string_literal: true
# Code copied from https://gist.github.com/komasaru/b3f22d5bcb8555deea1707b84d294045.
class String
def to_snake
self.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.downcase
end
end