diff --git a/lib/asciidoctor/foodogsquared-extensions.rb b/lib/asciidoctor/foodogsquared-extensions.rb index af6de49..73dc9e4 100644 --- a/lib/asciidoctor/foodogsquared-extensions.rb +++ b/lib/asciidoctor/foodogsquared-extensions.rb @@ -2,6 +2,9 @@ require 'asciidoctor' require 'asciidoctor/extensions' + +require_relative 'helpers' + require_relative 'man-inline-macro/extension' require_relative 'swhid-inline-macro/extension' require_relative 'swhid-include-processor/extension' diff --git a/lib/asciidoctor/helpers.rb b/lib/asciidoctor/helpers.rb new file mode 100644 index 0000000..e2e7351 --- /dev/null +++ b/lib/asciidoctor/helpers.rb @@ -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